All of lore.kernel.org
 help / color / mirror / Atom feed
From: wuguanghao <wuguanghao3@huawei.com>
To: <linux-ext4@vger.kernel.org>, <artem.blagodarenko@gmail.com>
Cc: <liuzhiqiang26@huawei.com>, <linfeilong@huawei.com>,
	<wuguanghao3@huawei.com>
Subject: [PATCH v2 07/12] argv_parse: check return value of malloc in argv_parse()
Date: Wed, 30 Jun 2021 16:27:19 +0800	[thread overview]
Message-ID: <20210630082724.50838-8-wuguanghao3@huawei.com> (raw)
In-Reply-To: <20210630082724.50838-2-wuguanghao3@huawei.com>

From: Zhiqiang Liu <liuzhiqiang26@huawei.com>

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 <liuzhiqiang26@huawei.com>
Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
---
 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..1f50f9e5 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)
-- 
2.19.1


  parent reply	other threads:[~2021-06-30  8:27 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-30  8:27 [PATCH v2 01/12] profile_create_node: set magic before strdup(name) to avoid memory leak wuguanghao
2021-06-30  8:27 ` [PATCH v2 02/12] tdb_transaction_recover: fix " wuguanghao
2021-07-16  3:19   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 03/12] zap_sector: " wuguanghao
2021-07-16  3:20   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 04/12] ss_add_info_dir: fix memory leak and check whether wuguanghao
2021-07-16  3:27   ` Theodore Y. Ts'o
2021-07-17  3:10     ` Zhiqiang Liu
2021-06-30  8:27 ` [PATCH v2 05/12] ss_create_invocation: fix memory leak and check whether NULL pointer wuguanghao
2021-07-16  3:34   ` Theodore Y. Ts'o
2021-07-19 11:08     ` Zhiqiang Liu
2021-06-30  8:27 ` [PATCH v2 06/12] append_pathname: check the value returned by realloc wuguanghao
2021-07-16  3:39   ` Theodore Y. Ts'o
2021-06-30  8:27 ` wuguanghao [this message]
2021-07-16  3:41   ` [PATCH v2 07/12] argv_parse: check return value of malloc in argv_parse() Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 08/12] misc: fix potential segmentation fault problem in scandir() wuguanghao
2021-07-16  3:44   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 09/12] lib/ss/error.c: check return value malloc in ss_name() wuguanghao
2021-07-16  3:46   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 10/12] hashmap: change return value type of ext2fs_hashmap_add() wuguanghao
2021-07-16  3:55   ` Theodore Y. Ts'o
2021-06-30  8:27 ` [PATCH v2 11/12] misc/lsattr: check whether path is NULL in lsattr_dir_proc() wuguanghao
2021-07-16  3:58   ` Theodore Y. Ts'o
2021-07-17  1:39     ` Zhiqiang Liu
2021-06-30  8:27 ` [PATCH v2 12/12] ext2ed: fix potential NULL pointer dereference in dupstr() wuguanghao
2021-07-16  3:59   ` Theodore Y. Ts'o
2021-07-16  3:18 ` [PATCH v2 01/12] profile_create_node: set magic before strdup(name) to avoid memory leak Theodore Y. Ts'o
  -- strict thread matches above, loose matches on Subject: below --
2021-05-31  1:23 [PATCH V2 00/12] e2fsprogs: some bugfixs and some code cleanups Wu Guanghao
2021-05-31  1:31 ` [PATCH V2 07/12] argv_parse: check return value of malloc in argv_parse() Wu Guanghao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210630082724.50838-8-wuguanghao3@huawei.com \
    --to=wuguanghao3@huawei.com \
    --cc=artem.blagodarenko@gmail.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.