From 4cd389f2fb76b2bddc58ed080d754f7934b21a13 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Thu, 25 Jul 2019 12:20:45 +1200 Subject: [PATCH] ldb dn crash test case --- lib/ldb/tests/ldb_dn_crash.c | 33 +++++++++++++++++++++++++++++++++ lib/ldb/wscript | 5 +++++ 2 files changed, 38 insertions(+) create mode 100644 lib/ldb/tests/ldb_dn_crash.c diff --git a/lib/ldb/tests/ldb_dn_crash.c b/lib/ldb/tests/ldb_dn_crash.c new file mode 100644 index 00000000000..e5b7eeddd45 --- /dev/null +++ b/lib/ldb/tests/ldb_dn_crash.c @@ -0,0 +1,33 @@ +/* + * Unix SMB/CIFS implementation. + * + * Copyright (C) 2018 Andreas Schneider + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include + +int main(void) { + const char *s; + struct ldb_context *ldb = ldb_init(NULL, NULL); + struct ldb_dn *dn = ldb_dn_new(ldb, ldb, "<"); + int result = ldb_dn_validate(dn); + if (result == false) { + printf("GOOD, we failed!\n"); + return 0; + } + s = ldb_dn_canonical_string(ldb, dn); + printf("apparent success: %s\n", s); +} diff --git a/lib/ldb/wscript b/lib/ldb/wscript index ea53c60b15b..fdb9b23de6d 100644 --- a/lib/ldb/wscript +++ b/lib/ldb/wscript @@ -497,6 +497,11 @@ def build(bld): deps='cmocka ldb', install=False) + bld.SAMBA_BINARY('ldb_dn_crash', + source='tests/ldb_dn_crash.c', + deps='ldb', + install=False) + bld.SAMBA_BINARY('ldb_match_test', source='tests/ldb_match_test.c', deps='cmocka ldb', -- 2.20.1