From patchwork Mon May 31 01:26:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wuguanghao X-Patchwork-Id: 1485520 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Ftd1D56Pgz9sVm for ; Mon, 31 May 2021 11:26:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbhEaB2S (ORCPT ); Sun, 30 May 2021 21:28:18 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:2414 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbhEaB2S (ORCPT ); Sun, 30 May 2021 21:28:18 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Ftcwv4cXZz67L7 for ; Mon, 31 May 2021 09:22:55 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:26:36 +0800 Received: from [10.174.179.184] (10.174.179.184) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:26:36 +0800 Subject: [PATCH V2 03/12] zap_sector: fix memory leak From: Wu Guanghao To: , =?utf-8?b?0JHQu9Cw0LPQvtC00LDRgNC10L3QutC+?= =?utf-8?b?INCQ0YDRgtGR0Lw=?= CC: , References: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> Message-ID: <3fbdb06d-e897-72da-14c9-89ed680e070f@huawei.com> Date: Mon, 31 May 2021 09:26:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In zap_sector(), need free buf before return, otherwise it will cause memory leak. Signed-off-by: Wu Guanghao Signed-off-by: Zhiqiang Liu Reviewed-by: Wu Bo --- misc/mke2fs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- diff --git a/misc/mke2fs.c b/misc/mke2fs.c index afbcf486..2f229534 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -585,8 +585,10 @@ static void zap_sector(ext2_filsys fs, int sect, int nsect) else { magic = (unsigned int *) (buf + BSD_LABEL_OFFSET); if ((*magic == BSD_DISKMAGIC) || - (*magic == BSD_MAGICDISK)) + (*magic == BSD_MAGICDISK)) { + free(buf); return; + } } } From patchwork Mon May 31 01:28:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wuguanghao X-Patchwork-Id: 1485521 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Ftd3G2lY5z9sVm for ; Mon, 31 May 2021 11:28:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229912AbhEaBaE (ORCPT ); Sun, 30 May 2021 21:30:04 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:2792 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbhEaBaD (ORCPT ); Sun, 30 May 2021 21:30:03 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Ftcxq6SCxzWq5x for ; Mon, 31 May 2021 09:23:43 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:28:23 +0800 Received: from [10.174.179.184] (10.174.179.184) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:28:23 +0800 Subject: [PATCH V2 04/12] ss_add_info_dir: fix memory leak and check whether,NULL pointer From: Wu Guanghao To: , =?utf-8?b?0JHQu9Cw0LPQvtC00LDRgNC10L3QutC+?= =?utf-8?b?INCQ0YDRgtGR0Lw=?= CC: , References: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> Message-ID: <03398446-66ea-01cb-e21a-b4841f325254@huawei.com> Date: Mon, 31 May 2021 09:28:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In ss_add_info_dir(), need free info->info_dirs before return, otherwise it will cause memory leak. At the same time, it is necessary to check whether dirs[n_dirs] is a null pointer, otherwise a segmentation fault will occur. Signed-off-by: Wu Guanghao Signed-off-by: Zhiqiang Liu Reviewed-by: Wu Bo --- lib/ss/help.c | 5 +++++ 1 file changed, 5 insertions(+) -- diff --git a/lib/ss/help.c b/lib/ss/help.c index 5204401b..429f410e 100644 --- a/lib/ss/help.c +++ b/lib/ss/help.c @@ -148,6 +148,7 @@ void ss_add_info_dir(int sci_idx, char *info_dir, int *code_ptr) dirs = (char **)realloc((char *)dirs, (unsigned)(n_dirs + 2)*sizeof(char *)); if (dirs == (char **)NULL) { + free(info->info_dirs); info->info_dirs = (char **)NULL; *code_ptr = errno; return; @@ -155,6 +156,10 @@ void ss_add_info_dir(int sci_idx, char *info_dir, int *code_ptr) info->info_dirs = dirs; dirs[n_dirs + 1] = (char *)NULL; dirs[n_dirs] = malloc((unsigned)strlen(info_dir)+1); + if (dirs[n_dirs] == (char *)NULL) { + *code_ptr = errno; + return; + } strcpy(dirs[n_dirs], info_dir); *code_ptr = 0; } From patchwork Mon May 31 01:30:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wuguanghao X-Patchwork-Id: 1485522 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Ftd5f00Mfz9sVm for ; Mon, 31 May 2021 11:30:29 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbhEaBcH (ORCPT ); Sun, 30 May 2021 21:32:07 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:6079 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbhEaBcG (ORCPT ); Sun, 30 May 2021 21:32:06 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Ftd2Q5N1BzYmkL for ; Mon, 31 May 2021 09:27:42 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:30:25 +0800 Received: from [10.174.179.184] (10.174.179.184) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:30:24 +0800 Subject: [PATCH V2 06/12] append_pathname: check the value returned by realloc to avoid segfault From: Wu Guanghao To: , =?utf-8?b?0JHQu9Cw0LPQvtC00LDRgNC10L3QutC+?= =?utf-8?b?INCQ0YDRgtGR0Lw=?= CC: , References: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> Message-ID: <892d9908-2346-f410-3e25-87bd0b458a2e@huawei.com> Date: Mon, 31 May 2021 09:30:24 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In append_pathname(), we need to add a new path to save the value returned by realloc, otherwise the name->path may be NULL, causing segfault Signed-off-by: Wu Guanghao Signed-off-by: Zhiqiang Liu --- contrib/fsstress.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -- diff --git a/contrib/fsstress.c b/contrib/fsstress.c index 2a983482..530bd920 100644 --- a/contrib/fsstress.c +++ b/contrib/fsstress.c @@ -599,7 +599,7 @@ void add_to_flist(int ft, int id, int parent) void append_pathname(pathname_t * name, char *str) { int len; - + char *path; len = strlen(str); #ifdef DEBUG if (len && *str == '/' && name->len == 0) { @@ -609,7 +609,13 @@ void append_pathname(pathname_t * name, char *str) } #endif - name->path = realloc(name->path, name->len + 1 + len); + path = realloc(name->path, name->len + 1 + len); + if (path == NULL) { + fprintf(stderr, "fsstress: append_pathname realloc failed\n"); + chdir(homedir); + abort(); + } + name->path = path; strcpy(&name->path[name->len], str); name->len += len; } From patchwork Mon May 31 01:31:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wuguanghao X-Patchwork-Id: 1485523 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Ftd6v5655z9sVb for ; Mon, 31 May 2021 11:31:35 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbhEaBdN (ORCPT ); Sun, 30 May 2021 21:33:13 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:6080 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbhEaBdL (ORCPT ); Sun, 30 May 2021 21:33:11 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Ftd3h5DkzzYmyV for ; Mon, 31 May 2021 09:28:48 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:31:31 +0800 Received: from [10.174.179.184] (10.174.179.184) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:31:30 +0800 Subject: [PATCH V2 07/12] argv_parse: check return value of malloc in argv_parse() From: Wu Guanghao To: , =?utf-8?b?0JHQu9Cw0LPQvtC00LDRgNC10L3QutC+?= =?utf-8?b?INCQ0YDRgtGR0Lw=?= CC: , References: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> Message-ID: <40063d0f-09dd-c7e6-fbd4-19b4438284ee@huawei.com> Date: Mon, 31 May 2021 09:31:30 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In argv_parse(), return value of malloc should be checked whether it is NULL, otherwise, it may cause a segfault error. Signed-off-by: Zhiqiang Liu Signed-off-by: Wu Guanghao --- lib/support/argv_parse.c | 2 ++ 1 file changed, 2 insertions(+) -- diff --git a/lib/support/argv_parse.c b/lib/support/argv_parse.c index d22f6344..1ef9c014 100644 --- a/lib/support/argv_parse.c +++ b/lib/support/argv_parse.c @@ -116,6 +116,8 @@ int argv_parse(char *in_buf, int *ret_argc, char ***ret_argv) if (argv == 0) { argv = malloc(sizeof(char *)); free(buf); + if (!argv) + return -1; } argv[argc] = 0; if (ret_argc) From patchwork Mon May 31 01:32:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wuguanghao X-Patchwork-Id: 1485524 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ext4-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4Ftd8V5R85z9sVb for ; Mon, 31 May 2021 11:32:58 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229941AbhEaBeg (ORCPT ); Sun, 30 May 2021 21:34:36 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:2415 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbhEaBef (ORCPT ); Sun, 30 May 2021 21:34:35 -0400 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Ftd493LFMz66wH for ; Mon, 31 May 2021 09:29:13 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:32:55 +0800 Received: from [10.174.179.184] (10.174.179.184) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 31 May 2021 09:32:54 +0800 Subject: [PATCH V2 10/12] hashmap: change return value type of, ext2fs_hashmap_add() From: Wu Guanghao To: , =?utf-8?b?0JHQu9Cw0LPQvtC00LDRgNC10L3QutC+?= =?utf-8?b?INCQ0YDRgtGR0Lw=?= CC: , References: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> Message-ID: <48cc9049-3538-1010-f45a-2475a3ff5166@huawei.com> Date: Mon, 31 May 2021 09:32:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <00ad4a90-8a40-24c1-98d9-eb5f0da42436@huawei.com> X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In ext2fs_hashmap_add(), new entry is allocated by calling malloc(). If malloc() return NULL, it will cause a segmentation fault problem. Here, we change return value type of ext2fs_hashmap_add() from void to int. If allocating new entry fails, we will return 1, and the callers should also verify the return value of ext2fs_hashmap_add(). Signed-off-by: Zhiqiang Liu Signed-off-by: Wu Guanghao --- contrib/android/base_fs.c | 12 +++++++++--- lib/ext2fs/fileio.c | 10 ++++++++-- lib/ext2fs/hashmap.c | 12 ++++++++++-- lib/ext2fs/hashmap.h | 4 ++-- 4 files changed, 29 insertions(+), 9 deletions(-) -- diff --git a/contrib/android/base_fs.c b/contrib/android/base_fs.c index 652317e2..d3e00d18 100644 --- a/contrib/android/base_fs.c +++ b/contrib/android/base_fs.c @@ -110,10 +110,16 @@ struct ext2fs_hashmap *basefs_parse(const char *file, const char *mountpoint) if (!entries) goto end; - while ((entry = basefs_readline(f, mountpoint, &err))) - ext2fs_hashmap_add(entries, entry, entry->path, + while ((entry = basefs_readline(f, mountpoint, &err))) { + err = ext2fs_hashmap_add(entries, entry, entry->path, strlen(entry->path)); - + if (err) { + free_base_fs_entry(entry); + fclose(f); + ext2fs_hashmap_free(entries); + return NULL; + } + } if (err) { fclose(f); ext2fs_hashmap_free(entries); diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c index a0b5d971..818f7f05 100644 --- a/lib/ext2fs/fileio.c +++ b/lib/ext2fs/fileio.c @@ -475,8 +475,14 @@ errcode_t ext2fs_file_write(ext2_file_t file, const void *buf, if (new_block) { new_block->physblock = file->physblock; - ext2fs_hashmap_add(fs->block_sha_map, new_block, - new_block->sha, sizeof(new_block->sha)); + int ret = ext2fs_hashmap_add(fs->block_sha_map, + new_block, new_block->sha, + sizeof(new_block->sha)); + if (ret) { + retval = EXT2_ET_NO_MEMORY; + free(new_block); + goto fail; + } } if (bmap_flags & BMAP_SET) { diff --git a/lib/ext2fs/hashmap.c b/lib/ext2fs/hashmap.c index ffe61ce9..7278edaf 100644 --- a/lib/ext2fs/hashmap.c +++ b/lib/ext2fs/hashmap.c @@ -36,6 +36,9 @@ struct ext2fs_hashmap *ext2fs_hashmap_create( { struct ext2fs_hashmap *h = calloc(sizeof(struct ext2fs_hashmap) + sizeof(struct ext2fs_hashmap_entry) * size, 1); + if (!h) + return NULL; + h->size = size; h->free = free_fct; h->hash = hash_fct; @@ -43,12 +46,15 @@ struct ext2fs_hashmap *ext2fs_hashmap_create( return h; } -void ext2fs_hashmap_add(struct ext2fs_hashmap *h, void *data, const void *key, - size_t key_len) +int ext2fs_hashmap_add(struct ext2fs_hashmap *h, + void *data, const void *key, size_t key_len) { uint32_t hash = h->hash(key, key_len) % h->size; struct ext2fs_hashmap_entry *e = malloc(sizeof(*e)); + if (!e) + return -1; + e->data = data; e->key = key; e->key_len = key_len; @@ -62,6 +68,8 @@ void ext2fs_hashmap_add(struct ext2fs_hashmap *h, void *data, const void *key, h->first = e; if (!h->last) h->last = e; + + return 0; } void *ext2fs_hashmap_lookup(struct ext2fs_hashmap *h, const void *key, diff --git a/lib/ext2fs/hashmap.h b/lib/ext2fs/hashmap.h index dcfa7455..0c09d2bd 100644 --- a/lib/ext2fs/hashmap.h +++ b/lib/ext2fs/hashmap.h @@ -27,8 +27,8 @@ struct ext2fs_hashmap_entry { struct ext2fs_hashmap *ext2fs_hashmap_create( uint32_t(*hash_fct)(const void*, size_t), void(*free_fct)(void*), size_t size); -void ext2fs_hashmap_add(struct ext2fs_hashmap *h, void *data, const void *key, - size_t key_len); +int ext2fs_hashmap_add(struct ext2fs_hashmap *h, + void *data, const void *key,size_t key_len); void *ext2fs_hashmap_lookup(struct ext2fs_hashmap *h, const void *key, size_t key_len); void *ext2fs_hashmap_iter_in_order(struct ext2fs_hashmap *h,