summaryrefslogtreecommitdiff
path: root/src/systemctl
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2014-07-25 15:38:31 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-07-26 15:08:41 -0400
commit7de80bfe2e61d5818601ccfddbadad3b7703ed70 (patch)
treeb8b90c03198f2f2125d13e175b2223e6239894f0 /src/systemctl
parent6d314eca15f6cbda38d82774b210f784d3d4f52a (diff)
Always check asprintf return code
There is a small number of the places in sources where we don't check asprintf() return code and assume that after error the function returns NULL pointer via the first argument. That's wrong, after error the content of pointer is undefined.
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index fc325095ac..f3d7fc8d6e 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -4999,11 +4999,10 @@ static int enable_sysv_units(const char *verb, char **args) {
_cleanup_free_ char *path = NULL;
if (!isempty(arg_root))
- asprintf(&path, "%s/%s/%s", arg_root, *k, name);
+ j = asprintf(&path, "%s/%s/%s", arg_root, *k, name);
else
- asprintf(&path, "%s/%s", *k, name);
-
- if (!path) {
+ j = asprintf(&path, "%s/%s", *k, name);
+ if (j < 0) {
r = log_oom();
goto finish;
}
@@ -5017,10 +5016,10 @@ static int enable_sysv_units(const char *verb, char **args) {
continue;
if (!isempty(arg_root))
- asprintf(&p, "%s/" SYSTEM_SYSVINIT_PATH "/%s", arg_root, name);
+ j = asprintf(&p, "%s/" SYSTEM_SYSVINIT_PATH "/%s", arg_root, name);
else
- asprintf(&p, SYSTEM_SYSVINIT_PATH "/%s", name);
- if (!p) {
+ j = asprintf(&p, SYSTEM_SYSVINIT_PATH "/%s", name);
+ if (j < 0) {
r = log_oom();
goto finish;
}