diff options
author | Martin Hedenfal <martinh@cvs.openbsd.org> | 2010-06-14 13:46:09 +0000 |
---|---|---|
committer | Martin Hedenfal <martinh@cvs.openbsd.org> | 2010-06-14 13:46:09 +0000 |
commit | 3675d8a3972f73c68dd8797cfad94fb95f3f114c (patch) | |
tree | 9121539dfa4e781a11a7be92567df0c5e9f084ac /usr.sbin/snmpd | |
parent | 11f02b14e7c65a059b959b3d10c12503175ffde8 (diff) |
Fixes unlinking the first element inside a set or a sequence, and
fix reading empty sequences/sets. This minimizes the changes against
ldapd.
"looks good" pyr@, ok reyk@
Diffstat (limited to 'usr.sbin/snmpd')
-rw-r--r-- | usr.sbin/snmpd/ber.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/snmpd/ber.c b/usr.sbin/snmpd/ber.c index 30eb8c7c1af..65d1ec6ba12 100644 --- a/usr.sbin/snmpd/ber.c +++ b/usr.sbin/snmpd/ber.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ber.c,v 1.21 2010/06/08 17:52:47 martinh Exp $ */ +/* $OpenBSD: ber.c,v 1.22 2010/06/14 13:46:08 martinh Exp $ */ /* * Copyright (c) 2007 Reyk Floeter <reyk@vantronix.net> @@ -101,7 +101,7 @@ ber_unlink_elements(struct ber_element *prev) if ((prev->be_encoding == BER_TYPE_SEQUENCE || prev->be_encoding == BER_TYPE_SET) && - prev->be_sub == NULL) { + prev->be_sub != NULL) { elm = prev->be_sub; prev->be_sub = NULL; } else { @@ -1136,18 +1136,18 @@ ber_read_element(struct ber *ber, struct ber_element *elm) return -1; } next = elm->be_sub; - do { + while (len > 0) { r = ber_read_element(ber, next); if (r == -1) return -1; - if (next->be_next == NULL) { + len -= r; + if (len > 0 && next->be_next == NULL) { if ((next->be_next = ber_get_element(0)) == NULL) return -1; } next = next->be_next; - len -= r; - } while (len > 0); + } break; } return totlen; |