lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 25 Feb 2021 07:51:09 -0800
From:   harshad shirwadkar <harshadshirwadkar@...il.com>
To:     Zhiqiang Liu <liuzhiqiang26@...wei.com>
Cc:     Ext4 Developers List <linux-ext4@...r.kernel.org>,
        "Theodore Y. Ts'o" <tytso@....edu>,
        linfeilong <linfeilong@...wei.com>,
        lihaotian <lihaotian9@...wei.com>,
        "lijinlin (A)" <lijinlin3@...wei.com>
Subject: Re: [PATCH] debugfs: fix memory leak problem in read_list()

On Sat, Feb 20, 2021 at 12:41 AM Zhiqiang Liu <liuzhiqiang26@...wei.com> wrote:
>
>
> In read_list func, if strtoull() fails in while loop,
> we will return the error code directly. Then, memory of
> variable lst will be leaked without setting to *list.
>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@...wei.com>
> Signed-off-by: linfeilong <linfeilong@...wei.com>
> ---
>  debugfs/util.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/debugfs/util.c b/debugfs/util.c
> index be6b550e..9e880548 100644
> --- a/debugfs/util.c
> +++ b/debugfs/util.c
> @@ -530,12 +530,16 @@ errcode_t read_list(char *str, blk64_t **list, size_t *len)
>
>                 errno = 0;
>                 y = x = strtoull(tok, &e, 0);
> -               if (errno)
> -                       return errno;
> +               if (errno) {
> +                       retval = errno;
> +                       break;
> +               }
Shouldn't we have `goto err;` here instead of break? strtoull failure
here indicates that no valid value was found, so instead of returning
the allocated memory, we should just free the memory and return error.

- Harshad
>                 if (*e == '-') {
>                         y = strtoull(e + 1, NULL, 0);
> -                       if (errno)
> -                               return errno;
> +                       if (errno) {
> +                               retval = errno;
> +                               break;
> +                       }
>                 } else if (*e != 0) {
>                         retval = EINVAL;
>                         break;
> --
> 2.19.1
>
>

Powered by blists - more mailing lists