summaryrefslogtreecommitdiff
path: root/source4/scripting
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-07-10 01:10:09 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:19:29 -0500
commit76ecf81428c161a98a5621b55a64cb8515f80585 (patch)
tree542798f01d1582b00d7d20a93effba33f98ee1fc /source4/scripting
parentc6881d1e650fd284a366af76f5a214a5de05cc0c (diff)
downloadsamba-76ecf81428c161a98a5621b55a64cb8515f80585.tar.gz
samba-76ecf81428c161a98a5621b55a64cb8515f80585.tar.bz2
samba-76ecf81428c161a98a5621b55a64cb8515f80585.zip
r8273: fixed some memory leaks in smbscript. This required converting
file_load() to use talloc, which impacted quite a few bits of code, including our smb.conf processing. took the opportunity to remove the gloabls in params.c while doing this (This used to be commit b220756cb4f1d201ba3e771ca67e4bfae5eae748)
Diffstat (limited to 'source4/scripting')
-rw-r--r--source4/scripting/ejs/ejsrpc.c21
-rw-r--r--source4/scripting/ejs/ejsrpc.h2
-rw-r--r--source4/scripting/ejs/smbcalls_rpc.c19
-rw-r--r--source4/scripting/ejs/smbscript.c3
4 files changed, 16 insertions, 29 deletions
diff --git a/source4/scripting/ejs/ejsrpc.c b/source4/scripting/ejs/ejsrpc.c
index cd7e0c9211..f2c2b258e4 100644
--- a/source4/scripting/ejs/ejsrpc.c
+++ b/source4/scripting/ejs/ejsrpc.c
@@ -26,27 +26,6 @@
#include "librpc/gen_ndr/ndr_lsa.h"
#include "scripting/ejs/ejsrpc.h"
-NTSTATUS ejs_pull_rpc(int eid, const char *callname,
- struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull)
-{
- struct ejs_rpc *ejs = talloc(ptr, struct ejs_rpc);
- NT_STATUS_HAVE_NO_MEMORY(ejs);
- ejs->eid = eid;
- ejs->callname = callname;
- return ejs_pull(ejs, v, ptr);
-}
-
-
-NTSTATUS ejs_push_rpc(int eid, const char *callname,
- struct MprVar *v, const void *ptr, ejs_push_function_t ejs_push)
-{
- struct ejs_rpc *ejs = talloc(ptr, struct ejs_rpc);
- NT_STATUS_HAVE_NO_MEMORY(ejs);
- ejs->eid = eid;
- ejs->callname = callname;
- return ejs_push(ejs, v, ptr);
-}
-
/*
set the switch var to be used by the next union switch
*/
diff --git a/source4/scripting/ejs/ejsrpc.h b/source4/scripting/ejs/ejsrpc.h
index 6914988bc8..e410535b6c 100644
--- a/source4/scripting/ejs/ejsrpc.h
+++ b/source4/scripting/ejs/ejsrpc.h
@@ -46,8 +46,6 @@ NTSTATUS smbcalls_register_ejs(const char *name,
int ejs_rpc_call(int eid, int argc, struct MprVar **argv, const char *callname,
ejs_pull_function_t ejs_pull, ejs_push_function_t ejs_push);
-NTSTATUS ejs_pull_rpc(int eid, const char *callname, struct MprVar *v, void *ptr, ejs_pull_function_t ejs_pull);
-NTSTATUS ejs_push_rpc(int eid, const char *callname, struct MprVar *v, const void *ptr, ejs_push_function_t ejs_push);
NTSTATUS ejs_pull_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name);
NTSTATUS ejs_push_struct_start(struct ejs_rpc *ejs, struct MprVar **v, const char *name);
diff --git a/source4/scripting/ejs/smbcalls_rpc.c b/source4/scripting/ejs/smbcalls_rpc.c
index 12b0d95e8e..8a5389fbab 100644
--- a/source4/scripting/ejs/smbcalls_rpc.c
+++ b/source4/scripting/ejs/smbcalls_rpc.c
@@ -105,6 +105,7 @@ done:
void *ptr;
struct rpc_request *req;
int callnum;
+ struct ejs_rpc *ejs;
if (argc != 2 ||
argv[0]->type != MPR_TYPE_OBJECT ||
@@ -132,15 +133,24 @@ done:
}
callnum = call - iface->calls;
+ ejs = talloc(mprMemCtx(), struct ejs_rpc);
+ if (ejs == NULL) {
+ status = NT_STATUS_NO_MEMORY;
+ goto done;
+ }
+
+ ejs->eid = eid;
+ ejs->callname = callname;
+
/* allocate the C structure */
- ptr = talloc_zero_size(mprMemCtx(), call->struct_size);
+ ptr = talloc_zero_size(ejs, call->struct_size);
if (ptr == NULL) {
status = NT_STATUS_NO_MEMORY;
goto done;
}
/* convert the mpr object into a C structure */
- status = ejs_pull_rpc(eid, callname, io, ptr, ejs_pull);
+ status = ejs_pull(ejs, io, ptr);
if (!NT_STATUS_IS_OK(status)) {
goto done;
}
@@ -154,7 +164,6 @@ done:
req = dcerpc_ndr_request_send(p, NULL, iface, callnum, ptr, ptr);
if (req == NULL) {
status = NT_STATUS_NO_MEMORY;
- talloc_free(ptr);
goto done;
}
status = dcerpc_ndr_request_recv(req);
@@ -164,10 +173,10 @@ done:
ndr_print_function_debug(call->ndr_print, call->name, NDR_OUT, ptr);
}
- status = ejs_push_rpc(eid, callname, io, ptr, ejs_push);
+ status = ejs_push(ejs, io, ptr);
- talloc_free(ptr);
done:
+ talloc_free(ejs);
ejsSetReturnValue(eid, mprNTSTATUS(status));
if (NT_STATUS_EQUAL(status, NT_STATUS_INTERNAL_ERROR)) {
return -1;
diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c
index 244ae0b42a..f7556b5384 100644
--- a/source4/scripting/ejs/smbscript.c
+++ b/source4/scripting/ejs/smbscript.c
@@ -94,12 +94,13 @@ void ejs_exception(const char *reason)
for (i=1;argv[i];i++) {
argv_list = str_list_add(argv_list, argv[i]);
}
+ talloc_steal(mem_ctx, argv_list);
v = mprList("ARGV", argv_list);
mprSetPropertyValue(&v, "length", mprCreateIntegerVar(i-1));
mprCreateProperty(ejsGetGlobalObject(eid), "ARGV", &v);
/* load the script and advance past interpreter line*/
- script = file_load(fname, &script_size);
+ script = file_load(fname, &script_size, mem_ctx);
if ((script_size > 2) && script[0] == '#' && script[1] == '!') {
script += 2;