Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Apr 2013 13:20:02 GMT
From:      Luiz Otavio O Souza <loos.br@gmail.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/177872: [patch] etherswitchcfg(8) crashes if called with no argument for vlangroups members
Message-ID:  <201304181320.r3IDK2to044566@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/177872; it has been noted by GNATS.

From: Luiz Otavio O Souza <loos.br@gmail.com>
To: Luiz Otavio O Souza <loos.br@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/177872: [patch] etherswitchcfg(8) crashes if called with no argument for vlangroups members
Date: Thu, 18 Apr 2013 10:07:23 -0300

 --Apple-Mail-4--711296950
 Content-Transfer-Encoding: quoted-printable
 Content-Type: text/plain;
 	charset=us-ascii
 
 Here is the correct fix. It fix all the cases where it can happen (i.e. =
 etherswitchctl vlangroupX vlan, etherswitchctl vlangroupX members, =
 etherswitchcfg port1 vlangroup, etherswitchcfg port1 media, etc.).
 
 
 On Apr 17, 2013, at 5:48 PM, Luiz Otavio O Souza wrote:
 
 > Please, don't commit the fix in this PR, it's wrong. I'll submit the =
 correct fix later.
 
 
 
 --Apple-Mail-4--711296950
 Content-Disposition: attachment;
 	filename=etherswitchcfg-check-arguments.diff
 Content-Type: application/octet-stream;
 	name="etherswitchcfg-check-arguments.diff"
 Content-Transfer-Encoding: 7bit
 
 Index: sbin/etherswitchcfg/etherswitchcfg.c
 ===================================================================
 --- sbin/etherswitchcfg/etherswitchcfg.c	(revision 249621)
 +++ sbin/etherswitchcfg/etherswitchcfg.c	(working copy)
 @@ -466,8 +466,11 @@
  		case MODE_PORT:
  		case MODE_VLANGROUP:
  			for(i=0; cmds[i].name != NULL; i++) {
 -				if (cfg.mode == cmds[i].mode && strcmp(argv[0], cmds[i].name) == 0
 -					&& argc >= cmds[i].args) {
 +				if (cfg.mode == cmds[i].mode && strcmp(argv[0], cmds[i].name) == 0) {
 +					if (argc < (cmds[i].args + 1)) {
 +						printf("%s needs an argument\n", cmds[i].name);
 +						break;
 +					}
  					(cmds[i].f)(&cfg, argv);
  					argc -= cmds[i].args;
  					argv += cmds[i].args;
 
 --Apple-Mail-4--711296950--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304181320.r3IDK2to044566>