summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-10-28 04:10:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:45:23 -0500
commite0ab3485eeeee130cf43b333562f30f09a29cfd8 (patch)
tree0a6322d50ddcb1eb8248ea803019fb6f2d8ae748
parentd812957a3162d37ec355b2e2673f3e7297626da7 (diff)
downloadsamba-e0ab3485eeeee130cf43b333562f30f09a29cfd8.tar.gz
samba-e0ab3485eeeee130cf43b333562f30f09a29cfd8.tar.bz2
samba-e0ab3485eeeee130cf43b333562f30f09a29cfd8.zip
r11354: - generate a ejs error on bad ldif to add/modify
- fixed a double free error in ldb.close() (This used to be commit 7f797e7097cffa1f5b5bac34e100af77d4026f89)
-rw-r--r--source4/scripting/ejs/smbcalls_ldb.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/source4/scripting/ejs/smbcalls_ldb.c b/source4/scripting/ejs/smbcalls_ldb.c
index ec2748a426..83d5f1ae44 100644
--- a/source4/scripting/ejs/smbcalls_ldb.c
+++ b/source4/scripting/ejs/smbcalls_ldb.c
@@ -129,7 +129,7 @@ static int ejs_ldbAddModify(MprVarHandle eid, int argc, struct MprVar **argv,
const char *ldifstring;
struct ldb_context *ldb;
struct ldb_ldif *ldif;
- int ret = 0;
+ int ret = 0, count=0;
if (argc != 1) {
ejsSetErrorMsg(eid, "ldb.add/modify invalid arguments");
@@ -148,11 +148,17 @@ static int ejs_ldbAddModify(MprVarHandle eid, int argc, struct MprVar **argv,
}
while ((ldif = ldb_ldif_read_string(ldb, &ldifstring))) {
+ count++;
ret = fn(ldb, ldif->msg);
talloc_free(ldif);
if (ret != 0) break;
}
+ if (count == 0) {
+ ejsSetErrorMsg(eid, "ldb.add/modify invalid ldif");
+ return -1;
+ }
+
mpr_Return(eid, mprCreateBoolVar(ret == 0));
return 0;
}
@@ -384,8 +390,6 @@ static int ejs_ldbClose(MprVarHandle eid, int argc, struct MprVar **argv)
return -1;
}
- talloc_free(ldb);
-
mprSetThisPtr(eid, "db", NULL);
mpr_Return(eid, mprCreateBoolVar(True));
return 0;