summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hedenfal <martinh@cvs.openbsd.org>2010-06-14 13:46:09 +0000
committerMartin Hedenfal <martinh@cvs.openbsd.org>2010-06-14 13:46:09 +0000
commit3675d8a3972f73c68dd8797cfad94fb95f3f114c (patch)
tree9121539dfa4e781a11a7be92567df0c5e9f084ac
parent11f02b14e7c65a059b959b3d10c12503175ffde8 (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@
-rw-r--r--usr.sbin/snmpd/ber.c12
-rw-r--r--usr.sbin/ypldap/ber.c12
2 files changed, 12 insertions, 12 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;
diff --git a/usr.sbin/ypldap/ber.c b/usr.sbin/ypldap/ber.c
index 84b167e3263..5c8688e10bc 100644
--- a/usr.sbin/ypldap/ber.c
+++ b/usr.sbin/ypldap/ber.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ber.c,v 1.6 2010/06/08 17:52:47 martinh Exp $ */
+/* $OpenBSD: ber.c,v 1.7 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;