summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2005-08-31 14:26:20 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:36:15 -0500
commitadf31c5042497cbdf10d3542672bf8a5d0956216 (patch)
treef3f7f1bcf49c2ae52ea15f55b5e1557d7b9bbe45
parent06db5396966819b3124034d25d814cc0843bd6e9 (diff)
downloadsamba-adf31c5042497cbdf10d3542672bf8a5d0956216.tar.gz
samba-adf31c5042497cbdf10d3542672bf8a5d0956216.tar.bz2
samba-adf31c5042497cbdf10d3542672bf8a5d0956216.zip
r9826: Add some more OOM checks
(This used to be commit 213bcb7e16290da0c26492ced65509a63942d4ce)
-rw-r--r--source4/param/generic.c22
-rw-r--r--source4/scripting/ejs/smbcalls_param.c4
2 files changed, 23 insertions, 3 deletions
diff --git a/source4/param/generic.c b/source4/param/generic.c
index 6866ffbf56..b6d2fd0449 100644
--- a/source4/param/generic.c
+++ b/source4/param/generic.c
@@ -68,6 +68,9 @@ static struct param *param_get_add(struct param_context *ctx, const char *sectio
if (section == NULL) {
section = talloc_zero(ctx, struct param_section);
+ if (section == NULL)
+ return NULL;
+
section->name = talloc_strdup(section, section_name);
DLIST_ADD(ctx->sections, section);
}
@@ -75,6 +78,9 @@ static struct param *param_get_add(struct param_context *ctx, const char *sectio
p = param_section_get(section, name);
if (p == NULL) {
p = talloc_zero(section, struct param);
+ if (p == NULL)
+ return NULL;
+
p->name = talloc_strdup(p, name);
DLIST_ADD(section->parameters, p);
}
@@ -146,6 +152,9 @@ void param_set_int(struct param_context *ctx, const char *section, const char *p
{
struct param *p = param_get_add(ctx, section, param);
+ if (!p)
+ return;
+
p->value = talloc_asprintf(p, "%d", value);
}
@@ -163,6 +172,9 @@ void param_set_ulong(struct param_context *ctx, const char *section, const char
{
struct param *p = param_get_add(ctx, section, name);
+ if (!p)
+ return;
+
p->value = talloc_asprintf(p, "%lu", value);
}
@@ -173,6 +185,9 @@ static BOOL param_sfunc (const char *name, void *_ctx)
if (section == NULL) {
section = talloc_zero(ctx, struct param_section);
+ if (section == NULL)
+ return False;
+
section->name = talloc_strdup(section, name);
DLIST_ADD(ctx->sections, section);
@@ -191,6 +206,9 @@ static BOOL param_pfunc (const char *name, const char *value, void *_ctx)
if (!p) {
p = talloc_zero(ctx->sections, struct param);
+ if (p == NULL)
+ return False;
+
p->name = talloc_strdup(p, name);
p->value = talloc_strdup(p, value);
DLIST_ADD(ctx->sections->parameters, p);
@@ -211,8 +229,10 @@ struct param_context *param_init(TALLOC_CTX *mem_ctx)
int param_read(struct param_context *ctx, const char *fn)
{
ctx->sections = talloc_zero(ctx, struct param_section);
+ if (ctx->sections == NULL)
+ return -1;
+
ctx->sections->name = talloc_strdup(ctx->sections, "global");
-
if (!pm_process( fn, param_sfunc, param_pfunc, ctx)) {
return -1;
}
diff --git a/source4/scripting/ejs/smbcalls_param.c b/source4/scripting/ejs/smbcalls_param.c
index ddd2b44c82..578df1b087 100644
--- a/source4/scripting/ejs/smbcalls_param.c
+++ b/source4/scripting/ejs/smbcalls_param.c
@@ -70,7 +70,7 @@ static int ejs_param_get_list(MprVarHandle eid, int argc, char **argv)
const char **ret;
if (argc != 1 && argc != 2) {
- ejsSetErrorMsg(eid, "param.get invalid argument count");
+ ejsSetErrorMsg(eid, "param.get_list invalid argument count");
return -1;
}
@@ -83,7 +83,7 @@ static int ejs_param_get_list(MprVarHandle eid, int argc, char **argv)
ret = param_get_string_list(ctx, NULL, argv[0], NULL);
}
- if (ret) {
+ if (ret != NULL) {
mpr_Return(eid, mprList("array", ret));
} else {
mpr_Return(eid, mprCreateUndefinedVar());