diff options
author | rob <rob@cvs.openbsd.org> | 2018-06-29 15:18:04 +0000 |
---|---|---|
committer | rob <rob@cvs.openbsd.org> | 2018-06-29 15:18:04 +0000 |
commit | 5c54f70a04a01fbf7edc97d7a8b26f24f82ce0f5 (patch) | |
tree | 1e9b83b2e8f12323c6ee94f4d338b1a8785be0e4 /usr.bin/ldap/ber.c | |
parent | 267e3b2f28ab6cce44177df6d68069f25b7a902a (diff) |
Synchronize ber.c and ber.h across ldap, ldapd, and ypldap, and reduce diff
with snmpd. More tweaks to come once things are fully synchronized.
Feedback from claudio and Robert Klein.
Ok claudio@
Diffstat (limited to 'usr.bin/ldap/ber.c')
-rw-r--r-- | usr.bin/ldap/ber.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/usr.bin/ldap/ber.c b/usr.bin/ldap/ber.c index 91a0a7cf648..f2266296e3a 100644 --- a/usr.bin/ldap/ber.c +++ b/usr.bin/ldap/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.4 2018/06/27 20:38:10 rob Exp $ */ +/* $OpenBSD: ber.c,v 1.5 2018/06/29 15:18:03 rob Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -729,7 +729,7 @@ ber_scanf_elements(struct ber_element *ber, char *fmt, ...) goto fail; ber = parent[level--]; ret++; - continue; + break; default: goto fail; } @@ -822,6 +822,19 @@ ber_read_elements(struct ber *ber, struct ber_element *elm) } void +ber_free_element(struct ber_element *root) +{ + if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE || + root->be_encoding == BER_TYPE_SET)) + ber_free_elements(root->be_sub); + if (root->be_free && (root->be_encoding == BER_TYPE_OCTETSTRING || + root->be_encoding == BER_TYPE_BITSTRING || + root->be_encoding == BER_TYPE_OBJECT)) + free(root->be_val); + free(root); +} + +void ber_free_elements(struct ber_element *root) { if (root->be_sub && (root->be_encoding == BER_TYPE_SEQUENCE || @@ -1030,6 +1043,12 @@ get_len(struct ber *b, ssize_t *len) return 1; } + if (u == 0x80) { + /* Indefinite length not supported. */ + errno = EINVAL; + return -1; + } + n = u & ~BER_TAG_MORE; if (sizeof(ssize_t) < n) { errno = ERANGE; @@ -1049,12 +1068,6 @@ get_len(struct ber *b, ssize_t *len) return -1; } - if (s == 0) { - /* invalid encoding */ - errno = EINVAL; - return -1; - } - *len = s; return r; } |