From mboxrd@z Thu Jan 1 00:00:00 1970 From: Shinya Kuribayashi Date: Fri, 28 Dec 2007 12:43:48 +0900 Subject: [U-Boot-Users] [PATCH 1/2] cmd_mii.c: Fix a NULL pointer dereference In-Reply-To: <477348BA.5090201@necel.com> References: <477348BA.5090201@necel.com> Message-ID: <477470F4.2000009@necel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Issuing `mii' command with no arguments causes NULL pointer dereference as parse_line() assignes NULL to argv[1] in such case. Make sure `argc' >= 2 before referencing argv[1], or print the usage message. Signed-off-by: Shinya Kuribayashi Signed-off-by: Andrew Dyer --- common/cmd_mii.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-) diff --git a/common/cmd_mii.c b/common/cmd_mii.c index b771322..b99bd06 100644 --- a/common/cmd_mii.c +++ b/common/cmd_mii.c @@ -438,6 +438,11 @@ int do_mii (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) int rcode = 0; char *devname; + if (argc < 2) { + printf("Usage:\n%s\n", cmdtp->usage); + return 1; + } + #if defined(CONFIG_8xx) || defined(CONFIG_MCF532x) mii_init (); #endif