]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libfdisk: (script) make sure buffer is initialized
authorKarel Zak <kzak@redhat.com>
Wed, 12 Aug 2020 17:36:51 +0000 (19:36 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 12 Aug 2020 17:39:34 +0000 (19:39 +0200)
Just to make static analyzers happy.

Signed-off-by: Karel Zak <kzak@redhat.com>
libfdisk/src/script.c

index 2a3d1b818bcec72d715a1742b0643f9841b5bd7e..81d42594525c6ea4c0d6f12a6b7bd097bff177b9 100644 (file)
@@ -1329,11 +1329,13 @@ int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t b
 
        assert(dp);
        assert(f);
+       assert(bufsz);
 
        DBG(SCRIPT, ul_debugobj(dp, " parsing line %zu", dp->nlines));
 
        /* read the next non-blank non-comment line */
        do {
+               buf[0] = '\0';
                if (dp->fn_fgets) {
                        if (dp->fn_fgets(dp, buf, bufsz, f) == NULL)
                                return 1;
@@ -1376,7 +1378,7 @@ int fdisk_script_read_line(struct fdisk_script *dp, FILE *f, char *buf, size_t b
  */
 int fdisk_script_read_file(struct fdisk_script *dp, FILE *f)
 {
-       char buf[BUFSIZ];
+       char buf[BUFSIZ] = { '\0' };
        int rc = 1;
 
        assert(dp);
@@ -1624,7 +1626,7 @@ static int test_read(struct fdisk_test *ts, int argc, char *argv[])
 
 static int test_stdin(struct fdisk_test *ts, int argc, char *argv[])
 {
-       char buf[BUFSIZ];
+       char buf[BUFSIZ] = { '\0' };
        struct fdisk_script *dp;
        struct fdisk_context *cxt;
        int rc = 0;