firmware-utils: bcm4908img: fix uninitialized var usage
authorRafał Miłecki <rafal@milecki.pl>
Thu, 8 Apr 2021 07:10:20 +0000 (09:10 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Thu, 8 Apr 2021 08:50:59 +0000 (10:50 +0200)
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
tools/firmware-utils/src/bcm4908img.c

index d97e54e0f6b4924cb1d7098c21da8632fc5d0ce8..402d3171908122f926bd87dd41304efc53a3fb80 100644 (file)
@@ -567,8 +567,8 @@ out:
 static int bcm4908img_extract(int argc, char **argv) {
        struct bcm4908img_info info;
        const char *pathname = NULL;
+       const char *type = NULL;
        uint8_t buf[1024];
-       const char *type;
        size_t offset;
        size_t length;
        size_t bytes;
@@ -600,7 +600,11 @@ static int bcm4908img_extract(int argc, char **argv) {
                goto err_close;
        }
 
-       if (!strcmp(type, "cferom")) {
+       if (!type) {
+               err = -EINVAL;
+               fprintf(stderr, "No data to extract specified\n");
+               goto err_close;
+       } else if (!strcmp(type, "cferom")) {
                offset = info.cferom_offset;
                length = info.bootfs_offset - offset;
                if (!length) {
@@ -625,7 +629,7 @@ static int bcm4908img_extract(int argc, char **argv) {
 
        if (!length) {
                err = -EINVAL;
-               fprintf(stderr, "No data to extract specified\n");
+               fprintf(stderr, "Failed to find requested data in input image\n");
                goto err_close;
        }