s4-ldb: allow for non-null terminated ldb_val in ldb_dn_from_ldb_val
authorAndrew Tridgell <tridge@samba.org>
Wed, 21 Oct 2009 11:18:16 +0000 (22:18 +1100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 21 Oct 2009 11:43:58 +0000 (22:43 +1100)
The strlen() could go past the end of a non-null terminated value

source4/lib/ldb/common/ldb_dn.c

index fa3865e77f42daee248b4c4a8586b99c1a9f5d2d..2ba17b2a6b29595279a4d34ca35f916af4ae7385 100644 (file)
@@ -98,7 +98,7 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx,
        if (! ldb) return NULL;
 
        if (strdn && strdn->data
-           && (strlen((const char*)strdn->data) != strdn->length)) {
+           && (strnlen((const char*)strdn->data, strdn->length) != strdn->length)) {
                /* The RDN must not contain a character with value 0x0 */
                return NULL;
        }