summaryrefslogtreecommitdiff
path: root/usr.bin/ldap/ber.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/ldap/ber.c')
-rw-r--r--usr.bin/ldap/ber.c29
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;
}