diff mbox series

[LEDE-DEV,LEDE-DEV,2/3] fstools: fix potential memory leak

Message ID 2018032916250165473610@rosinson.com
State Changes Requested
Delegated to: John Crispin
Headers show
Series [LEDE-DEV,LEDE-DEV,1/3] fstools: add exfat filesystem support | expand

Commit Message

Rosy Song March 29, 2018, 8:25 a.m. UTC
Fix potential memory leak in fstools

Signed-off-by: Rosy Song <rosysong@rosinson.com>
---
 libblkid-tiny/libblkid-tiny.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.13.3



Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev

Comments

John Crispin April 2, 2018, 3:25 p.m. UTC | #1
On 29/03/18 10:25, rosysong@rosinson.com wrote:
> Fix potential memory leak in fstools
>
> Signed-off-by: Rosy Song <rosysong@rosinson.com>
Hi,

the description is wrong, this fixes a potential null pointer deref and 
i dont really see how probing of a FS would work without a magic so we 
probably wont ever hit this case ?

     John

> ---
>   libblkid-tiny/libblkid-tiny.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libblkid-tiny/libblkid-tiny.c b/libblkid-tiny/libblkid-tiny.c
> index ccfaf63..12cab6f 100644
> --- a/libblkid-tiny/libblkid-tiny.c
> +++ b/libblkid-tiny/libblkid-tiny.c
> @@ -282,7 +282,7 @@ int probe_block(char *block, struct blkid_struct_probe *pr)
>   
>   		mag = &idinfos[i]->magics[0];
>   
> -		while (mag->magic) {
> +		while (mag && mag->magic) {
>   			int off = (mag->kboff * 1024) + mag->sboff;
>   			char magic[32] = { 0 };
>   
> -- 
> 2.13.3
>
>
>
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
> _______________________________________________
> Lede-dev mailing list
> Lede-dev@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev
Rosy Song April 5, 2018, 7:23 a.m. UTC | #2
I am not sure, maybe you are right, we will never the case. 
But I known this patch can avoid the case when probing a FS
fail with current magics.


rosysong@rosinson.com
 
From: John Crispin
Date: 2018-04-02 23:25
To: rosysong@rosinson.com; lede-dev
Subject: Re: [LEDE-DEV] [LEDE-DEV,2/3] fstools: fix potential memory leak
 
 
On 29/03/18 10:25, rosysong@rosinson.com wrote:
> Fix potential memory leak in fstools
>
> Signed-off-by: Rosy Song <rosysong@rosinson.com>
Hi,
 
the description is wrong, this fixes a potential null pointer deref and
i dont really see how probing of a FS would work without a magic so we
probably wont ever hit this case ?
 
    John
 
> ---
>   libblkid-tiny/libblkid-tiny.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libblkid-tiny/libblkid-tiny.c b/libblkid-tiny/libblkid-tiny.c
> index ccfaf63..12cab6f 100644
> --- a/libblkid-tiny/libblkid-tiny.c
> +++ b/libblkid-tiny/libblkid-tiny.c
> @@ -282,7 +282,7 @@ int probe_block(char *block, struct blkid_struct_probe *pr)
>  
>   	mag = &idinfos[i]->magics[0];
>  
> -	while (mag->magic) {
> +	while (mag && mag->magic) {
>   	int off = (mag->kboff * 1024) + mag->sboff;
>   	char magic[32] = { 0 };
>  
> --
> 2.13.3
diff mbox series

Patch

diff --git a/libblkid-tiny/libblkid-tiny.c b/libblkid-tiny/libblkid-tiny.c
index ccfaf63..12cab6f 100644
--- a/libblkid-tiny/libblkid-tiny.c
+++ b/libblkid-tiny/libblkid-tiny.c
@@ -282,7 +282,7 @@  int probe_block(char *block, struct blkid_struct_probe *pr)
 
 		mag = &idinfos[i]->magics[0];
 
-		while (mag->magic) {
+		while (mag && mag->magic) {
 			int off = (mag->kboff * 1024) + mag->sboff;
 			char magic[32] = { 0 };