bin/177872: [patch] etherswitchcfg(8) crashes if called with no argument for vlangroups members

Luiz Otavio O Souza loos.br at gmail.com
Thu Apr 18 13:20:02 UTC 2013


The following reply was made to PR bin/177872; it has been noted by GNATS.

From: Luiz Otavio O Souza <loos.br at gmail.com>
To: Luiz Otavio O Souza <loos.br at gmail.com>
Cc: bug-followup at 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--


More information about the freebsd-bugs mailing list