]> 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>
Fri, 13 Nov 2020 10:48:31 +0000 (11:48 +0100)
Just to make static analyzers happy.

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

index 8f3c137a524e5ba1e1b407415634ff433253eac4..5a21be2922518b51c5f26a1f223375c7484fb68a 100644 (file)
@@ -1325,11 +1325,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;
@@ -1372,7 +1374,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);
@@ -1584,7 +1586,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;