mirror of
https://github.com/troglobit/finit.git
synced 2026-10-28 12:30:44 +00:00
Audit rlimit support, handle possible NULL pointer
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
f249210c04
commit
d96d1a3023
1 file changed
+10
-6
@@ -191,15 +191,16 @@ void conf_parse_rlimit(char *line)
|
|||||||
else if (tok && !strcmp(tok, "hard"))
|
else if (tok && !strcmp(tok, "hard"))
|
||||||
set = &rlim.rlim_max;
|
set = &rlim.rlim_max;
|
||||||
else
|
else
|
||||||
goto fail;
|
goto error;
|
||||||
|
|
||||||
tok = strtok(NULL, " \t");
|
tok = strtok(NULL, " \t");
|
||||||
if (!tok)
|
if (!tok)
|
||||||
goto fail;
|
goto error;
|
||||||
|
|
||||||
for (name = rlimit_names; name->name; name++)
|
for (name = rlimit_names; name->name; name++) {
|
||||||
if (!strcmp(tok, name->name))
|
if (!strcmp(tok, name->name))
|
||||||
resource = name->val;
|
resource = name->val;
|
||||||
|
}
|
||||||
|
|
||||||
if (resource < 0)
|
if (resource < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
@@ -208,9 +209,9 @@ void conf_parse_rlimit(char *line)
|
|||||||
if (!tok)
|
if (!tok)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!strcmp(tok, "infinity"))
|
if (!strcmp(tok, "infinity")) {
|
||||||
new = RLIM_INFINITY;
|
new = RLIM_INFINITY;
|
||||||
else {
|
} else {
|
||||||
const char *err = NULL;
|
const char *err = NULL;
|
||||||
|
|
||||||
new = strtonum(tok, 0, 2 << 31, &err);
|
new = strtonum(tok, 0, 2 << 31, &err);
|
||||||
@@ -228,7 +229,10 @@ void conf_parse_rlimit(char *line)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
FLOG_WARN("Failed parsing/setting %s rlimit", name->name ? : "unknown");
|
FLOG_WARN("rlimit: Failed setting rlimit %s", name->name ? : "unknown");
|
||||||
|
return;
|
||||||
|
error:
|
||||||
|
FLOG_WARN("rlimit: parse error");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void parse_static(char *line)
|
static void parse_static(char *line)
|
||||||
|
|||||||
Reference in new issue
Block a user