summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ldapd/attributes.c
diff options
context:
space:
mode:
authormartinh <martinh@openbsd.org>2010-10-19 09:34:41 +0000
committermartinh <martinh@openbsd.org>2010-10-19 09:34:41 +0000
commit16beda35277f5571113c1305b0adc56cc679983b (patch)
treefe835bb1971a076d7f09cac5743c9cd7dadaa690 /usr.sbin/ldapd/attributes.c
parentWhen checking if the input buffer is large enough to hold an LDAP request, (diff)
downloadwireguard-openbsd-16beda35277f5571113c1305b0adc56cc679983b.tar.xz
wireguard-openbsd-16beda35277f5571113c1305b0adc56cc679983b.zip
Fix a segmentation fault when adding an attribute to an empty entry.
Diffstat (limited to 'usr.sbin/ldapd/attributes.c')
-rw-r--r--usr.sbin/ldapd/attributes.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.sbin/ldapd/attributes.c b/usr.sbin/ldapd/attributes.c
index 966969d5cbb..b89c75f8d43 100644
--- a/usr.sbin/ldapd/attributes.c
+++ b/usr.sbin/ldapd/attributes.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: attributes.c,v 1.2 2010/07/13 12:54:51 martinh Exp $ */
+/* $OpenBSD: attributes.c,v 1.3 2010/10/19 09:34:41 martinh Exp $ */
/*
* Copyright (c) 2009 Martin Hedenfalk <martin@bzero.se>
@@ -99,7 +99,9 @@ ldap_add_attribute(struct ber_element *entry, const char *attr,
}
last = entry->be_sub;
- while (last && last->be_next != NULL)
+ if (last == NULL)
+ last = entry;
+ else while (last != NULL && last->be_next != NULL)
last = last->be_next;
if ((elm = ber_add_sequence(last)) == NULL)