|
|
a1c89c5 |
From 8ea913b2eaadbd92e069ea6b71cc5f5df409decf Mon Sep 17 00:00:00 2001
|
|
|
a1c89c5 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
a1c89c5 |
Date: Fri, 23 Sep 2011 01:43:28 +0200
|
|
|
a1c89c5 |
Subject: [PATCH] coverity: fix a couple of bugs found by coverity
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
---
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
[ removed hunks for code which does not exist in F15 -- michich ]
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
Index: systemd-26/src/binfmt.c
|
|
|
a1c89c5 |
===================================================================
|
|
|
a1c89c5 |
--- systemd-26.orig/src/binfmt.c
|
|
|
a1c89c5 |
+++ systemd-26/src/binfmt.c
|
|
|
a1c89c5 |
@@ -33,7 +33,7 @@
|
|
|
a1c89c5 |
#include "util.h"
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
static int delete_rule(const char *rule) {
|
|
|
a1c89c5 |
- char *x, *fn, *e;
|
|
|
a1c89c5 |
+ char *x, *fn = NULL, *e;
|
|
|
a1c89c5 |
int r;
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
assert(rule[0]);
|
|
|
a1c89c5 |
Index: systemd-26/src/conf-parser.c
|
|
|
a1c89c5 |
===================================================================
|
|
|
a1c89c5 |
--- systemd-26.orig/src/conf-parser.c
|
|
|
a1c89c5 |
+++ systemd-26/src/conf-parser.c
|
|
|
a1c89c5 |
@@ -194,9 +194,12 @@ int config_parse(const char *filename, F
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
if (c)
|
|
|
a1c89c5 |
continuation = c;
|
|
|
a1c89c5 |
- else if (!(continuation = strdup(l))) {
|
|
|
a1c89c5 |
- r = -ENOMEM;
|
|
|
a1c89c5 |
- goto finish;
|
|
|
a1c89c5 |
+ else {
|
|
|
a1c89c5 |
+ continuation = strdup(l);
|
|
|
a1c89c5 |
+ if (!continuation) {
|
|
|
a1c89c5 |
+ r = -ENOMEM;
|
|
|
a1c89c5 |
+ goto finish;
|
|
|
a1c89c5 |
+ }
|
|
|
a1c89c5 |
}
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
continue;
|
|
|
a1c89c5 |
Index: systemd-26/src/load-fragment.c
|
|
|
a1c89c5 |
===================================================================
|
|
|
a1c89c5 |
--- systemd-26.orig/src/load-fragment.c
|
|
|
a1c89c5 |
+++ systemd-26/src/load-fragment.c
|
|
|
a1c89c5 |
@@ -498,6 +498,7 @@ static int config_parse_exec(
|
|
|
a1c89c5 |
if (!n[0]) {
|
|
|
a1c89c5 |
log_error("[%s:%u] Invalid command line, ignoring: %s", filename, line, rvalue);
|
|
|
a1c89c5 |
strv_free(n);
|
|
|
a1c89c5 |
+ free(path);
|
|
|
a1c89c5 |
return 0;
|
|
|
a1c89c5 |
}
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
Index: systemd-26/src/modules-load.c
|
|
|
a1c89c5 |
===================================================================
|
|
|
a1c89c5 |
--- systemd-26.orig/src/modules-load.c
|
|
|
a1c89c5 |
+++ systemd-26/src/modules-load.c
|
|
|
a1c89c5 |
@@ -73,7 +73,6 @@ int main(int argc, char *argv[]) {
|
|
|
a1c89c5 |
continue;
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
log_error("Failed to open %s: %m", *fn);
|
|
|
a1c89c5 |
- free(fn);
|
|
|
a1c89c5 |
r = EXIT_FAILURE;
|
|
|
a1c89c5 |
continue;
|
|
|
a1c89c5 |
}
|
|
|
a1c89c5 |
Index: systemd-26/src/path.c
|
|
|
a1c89c5 |
===================================================================
|
|
|
a1c89c5 |
--- systemd-26.orig/src/path.c
|
|
|
a1c89c5 |
+++ systemd-26/src/path.c
|
|
|
a1c89c5 |
@@ -558,7 +558,7 @@ static void path_fd_event(Unit *u, int f
|
|
|
a1c89c5 |
assert(l > 0);
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
if (!(buf = malloc(l))) {
|
|
|
a1c89c5 |
- log_error("Failed to allocate buffer: %s", strerror(-ENOMEM));
|
|
|
a1c89c5 |
+ log_error("Failed to allocate buffer: %s", strerror(ENOMEM));
|
|
|
a1c89c5 |
goto fail;
|
|
|
a1c89c5 |
}
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
Index: systemd-26/src/strv.c
|
|
|
a1c89c5 |
===================================================================
|
|
|
a1c89c5 |
--- systemd-26.orig/src/strv.c
|
|
|
a1c89c5 |
+++ systemd-26/src/strv.c
|
|
|
a1c89c5 |
@@ -202,12 +202,19 @@ char **strv_merge_concat(char **a, char
|
|
|
a1c89c5 |
if (!(r = new(char*, strv_length(a)+strv_length(b)+1)))
|
|
|
a1c89c5 |
return NULL;
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
- for (k = r; *a; k++, a++)
|
|
|
a1c89c5 |
- if (!(*k = strdup(*a)))
|
|
|
a1c89c5 |
- goto fail;
|
|
|
a1c89c5 |
- for (; *b; k++, b++)
|
|
|
a1c89c5 |
- if (!(*k = strappend(*b, suffix)))
|
|
|
a1c89c5 |
+ k = r;
|
|
|
a1c89c5 |
+ if (a)
|
|
|
a1c89c5 |
+ for (; *a; k++, a++) {
|
|
|
a1c89c5 |
+ *k = strdup(*a);
|
|
|
a1c89c5 |
+ if (!*k)
|
|
|
a1c89c5 |
+ goto fail;
|
|
|
a1c89c5 |
+ }
|
|
|
a1c89c5 |
+
|
|
|
a1c89c5 |
+ for (; *b; k++, b++) {
|
|
|
a1c89c5 |
+ *k = strappend(*b, suffix);
|
|
|
a1c89c5 |
+ if (!*k)
|
|
|
a1c89c5 |
goto fail;
|
|
|
a1c89c5 |
+ }
|
|
|
a1c89c5 |
|
|
|
a1c89c5 |
*k = NULL;
|
|
|
a1c89c5 |
return r;
|