Whamcloud - gitweb
libblkid: fix sizeof(foo) vs sizeof(*foo) malloc() bug
authorTheodore Ts'o <tytso@mit.edu>
Fri, 3 Jan 2014 02:54:03 +0000 (21:54 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 5 Jan 2014 00:11:37 +0000 (19:11 -0500)
Addresses-Coverity-Bug: #709510

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
lib/blkid/probe.c

index bd31fe0..6f74bd4 100644 (file)
@@ -1003,7 +1003,7 @@ static int probe_udf(struct blkid_probe *probe,
           (block sizes larger than 2K will be null padded) */
        for (bs = 1; bs < 16; bs++) {
                isosb = (struct iso_volume_descriptor *)
-                       get_buffer(probe, bs*2048+32768, sizeof(isosb));
+                       get_buffer(probe, bs*2048+32768, sizeof(*isosb));
                if (!isosb)
                        return 1;
                if (isosb->vd_id[0])
@@ -1015,7 +1015,7 @@ static int probe_udf(struct blkid_probe *probe,
                if (j > 1) {
                        isosb = (struct iso_volume_descriptor *)
                                get_buffer(probe, j*bs*2048+32768,
-                                          sizeof(isosb));
+                                          sizeof(*isosb));
                        if (!isosb)
                                return 1;
                }
@@ -1223,7 +1223,7 @@ static int probe_hfsplus(struct blkid_probe *probe,
                off = (alloc_first_block * 512) +
                        (embed_first_block * alloc_block_size);
                buf = get_buffer(probe, off + (id->bim_kboff * 1024),
-                                sizeof(sbd));
+                                sizeof(*sbd));
                if (!buf)
                        return 1;