xfs
[Top] [All Lists]

Re: [PATCH 06/11] xfsprogs: xfs_db: check null derefernce after block_to

To: xfs@xxxxxxxxxxx
Subject: Re: [PATCH 06/11] xfsprogs: xfs_db: check null derefernce after block_to_bt
From: Eric Sandeen <sandeen@xxxxxxxxxxx>
Date: Wed, 2 Dec 2015 23:43:13 -0600
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1449055167-19936-7-git-send-email-t.vivek@xxxxxxxxxxx>
References: <1449055167-19936-1-git-send-email-t.vivek@xxxxxxxxxxx> <1449055167-19936-7-git-send-email-t.vivek@xxxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
I think this is ok; another "should never happen" scenario,
so the ASSERT seems fine.

Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>

On 12/2/15 5:19 AM, Vivek Trivedi wrote:
> add assert if block_to_bt returns NULL to avoid null pointer
> dereference and get backtrace.
> Reported by coverity.
> 
> Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
> ---
>  db/btblock.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/db/btblock.c b/db/btblock.c
> index 46140fc..91593f8 100644
> --- a/db/btblock.c
> +++ b/db/btblock.c
> @@ -180,6 +180,7 @@ btblock_key_offset(
>       struct xfs_db_btree     *bt = block_to_bt(block);
>       int                     offset;
>  
> +     ASSERT(bt != NULL);
>       ASSERT(startoff == 0);
>       ASSERT(block->bb_level != 0);
>  
> @@ -201,6 +202,7 @@ btblock_ptr_offset(
>       int                     offset;
>       int                     maxrecs;
>  
> +     ASSERT(bt != NULL);
>       ASSERT(startoff == 0);
>       ASSERT(block->bb_level != 0);
>  
> @@ -225,6 +227,7 @@ btblock_rec_offset(
>       struct xfs_db_btree     *bt = block_to_bt(block);
>       int                     offset;
>  
> +     ASSERT(bt != NULL);
>       ASSERT(startoff == 0);
>       ASSERT(block->bb_level == 0);
>  
> 

<Prev in Thread] Current Thread [Next in Thread>