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  linux-cve-announce  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]
Message-ID: <d2bbf42c-9702-27e2-b3bb-9339a0afb6bd@huawei.com>
Date:   Fri, 31 Dec 2021 09:30:59 +0800
From:   Zhiqiang Liu <liuzhiqiang26@...wei.com>
To:     zhanchengbin <zhanchengbin1@...wei.com>,
        Theodore Ts'o <tytso@....edu>
CC:     <linux-ext4@...r.kernel.org>, <linfeilong@...wei.com>
Subject: Re: [PATCH] setup_tdb : fix memory leak

friendly ping..

On 2021/12/10 11:35, zhanchengbin wrote:
> ping
>
> 在 2021/11/30 14:40, zhanchengbin 写道:
>> In setup_tdb(), need free tdb_dir before return,
>> otherwise it will cause memory leak.
>>
>> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@...wei.com>
>> Signed-off-by: zhanchengbin <zhanchengbin1@...wei.com>
>> ---
>>   e2fsck/dirinfo.c | 13 +++++++++----
>>   1 file changed, 9 insertions(+), 4 deletions(-)
>>
>> diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c
>> index 49d624c5..a2b36d8e 100644
>> --- a/e2fsck/dirinfo.c
>> +++ b/e2fsck/dirinfo.c
>> @@ -49,7 +49,7 @@ static void setup_tdb(e2fsck_t ctx, ext2_ino_t num_dirs)
>>       ext2_ino_t        threshold;
>>       errcode_t        retval;
>>       mode_t            save_umask;
>> -    char            *tdb_dir, uuid[40];
>> +    char            *tdb_dir = NULL, uuid[40];
>>       int            fd, enable;
>>
>>       profile_get_string(ctx->profile, "scratch_files", "directory", 0, 0,
>> @@ -61,11 +61,11 @@ static void setup_tdb(e2fsck_t ctx, ext2_ino_t num_dirs)
>>
>>       if (!enable || !tdb_dir || access(tdb_dir, W_OK) ||
>>           (threshold && num_dirs <= threshold))
>> -        return;
>> +        goto error;
>>
>>       retval = ext2fs_get_mem(strlen(tdb_dir) + 64, &db->tdb_fn);
>>       if (retval)
>> -        return;
>> +        goto error;
>>
>>       uuid_unparse(ctx->fs->super->s_uuid, uuid);
>>       sprintf(db->tdb_fn, "%s/%s-dirinfo-XXXXXX", tdb_dir, uuid);
>> @@ -74,7 +74,7 @@ static void setup_tdb(e2fsck_t ctx, ext2_ino_t num_dirs)
>>       umask(save_umask);
>>       if (fd < 0) {
>>           db->tdb = NULL;
>> -        return;
>> +        goto error;
>>       }
>>
>>       if (num_dirs < 99991)
>> @@ -83,6 +83,11 @@ static void setup_tdb(e2fsck_t ctx, ext2_ino_t num_dirs)
>>       db->tdb = tdb_open(db->tdb_fn, num_dirs, TDB_NOLOCK | TDB_NOSYNC,
>>                  O_RDWR | O_CREAT | O_TRUNC, 0600);
>>       close(fd);
>> +
>> +error:
>> +    if(tdb_dir) {
>> +        free(tdb_dir);
>> +    }
>>   }
>>   #endif
>>
>
> .

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ