diff options
author | mmcc <mmcc@cvs.openbsd.org> | 2015-12-24 17:23:45 +0000 |
---|---|---|
committer | mmcc <mmcc@cvs.openbsd.org> | 2015-12-24 17:23:45 +0000 |
commit | 4d3b347fb84e3d8fb580a216bdfe9066719e9bd0 (patch) | |
tree | 368d95ccadeb933b9db17211a1abae2370e327cb /usr.sbin | |
parent | 17fb1cc448d6009086ce11dba0b6b3c3257cb6bb (diff) |
use strndup instead of malloc/strncpy/nul
ok krw@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ldapd/search.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/usr.sbin/ldapd/search.c b/usr.sbin/ldapd/search.c index d2fa8bab8cf..bcb194b23e0 100644 --- a/usr.sbin/ldapd/search.c +++ b/usr.sbin/ldapd/search.c @@ -1,4 +1,4 @@ -/* $OpenBSD: search.c,v 1.15 2015/06/03 02:24:36 millert Exp $ */ +/* $OpenBSD: search.c,v 1.16 2015/12/24 17:23:44 mmcc Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martin@bzero.se> @@ -215,12 +215,11 @@ check_search_entry(struct btval *key, struct btval *val, struct search *search) return 0; } - if ((dn0 = malloc(key->size + 1)) == NULL) { + if ((dn0 = strndup(key->data, key->size)) == NULL) { log_warn("malloc"); return 0; } - strncpy(dn0, key->data, key->size); - dn0[key->size] = 0; + if (!authorized(search->conn, search->ns, ACI_READ, dn0, LDAP_SCOPE_BASE)) { /* LDAP_INSUFFICIENT_ACCESS */ |