diff mbox

[4/5] libblkid: fix sizeof(foo) vs sizeof(*foo) malloc() bug

Message ID 1388726998-14349-4-git-send-email-tytso@mit.edu
State Accepted, archived
Headers show

Commit Message

Theodore Ts'o Jan. 3, 2014, 5:29 a.m. UTC
Addresses-Coverity-Bug: #709510

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/blkid/probe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Eric Sandeen Jan. 3, 2014, 4:44 p.m. UTC | #1
On 1/2/14, 11:29 PM, Theodore Ts'o wrote:
> Addresses-Coverity-Bug: #709510
> 
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

Heh, that's been around a while!

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  lib/blkid/probe.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
> index bd31fe0..6f74bd4 100644
> --- a/lib/blkid/probe.c
> +++ b/lib/blkid/probe.c
> @@ -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;
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c
index bd31fe0..6f74bd4 100644
--- a/lib/blkid/probe.c
+++ b/lib/blkid/probe.c
@@ -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;