From 0bcbbbf1abf76bf3aa8af5657308cac61f7de602 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Thu, 5 Sep 2019 23:07:21 +0200 Subject: [PATCH] system: fix uninitialized variables in firmware validation code MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This fixes: system.c: In function 'validate_firmware_image': system.c:403:6: error: 'fd' may be used uninitialized in this function [-Werror=maybe-uninitialized] if (fd >= 0) { ^ system.c:446:4: error: 'jsobj' may be used uninitialized in this function [-Werror=maybe-uninitialized] blobmsg_add_object(&b, jsobj); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: e990e215e8a3 ("system: add "validate_firmware_image" ubus method") Signed-off-by: Rafał Miłecki --- system.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system.c b/system.c index 94bef1b..ad24a30 100644 --- a/system.c +++ b/system.c @@ -386,8 +386,8 @@ static int proc_signal(struct ubus_context *ctx, struct ubus_object *obj, static int validate_firmware_image_call(const char *file) { const char *path = "/usr/libexec/validate_firmware_image"; + json_object *jsobj = NULL; json_tokener *tok; - json_object *jsobj; char buf[64]; ssize_t len; int fds[2]; @@ -402,6 +402,7 @@ static int validate_firmware_image_call(const char *file) return -errno; case 0: /* Set stdin & stderr to /dev/null */ + fd = open("/dev/null", O_RDWR); if (fd >= 0) { dup2(fd, 0); dup2(fd, 2); -- 2.25.1