Re: fwcontrol update

Sean Bruno <[email protected]>
Newsgroups gmane.os.freebsd.devel.firewire
Message-ID <[email protected]>
Dieter wrote:
> case 'b':
>
> 	if (priority_budget < 0 || priority_budget > INT32_MAX)
>         	errx(EX_USAGE, "%s: invalid number: %s", __func__, optarg);
>
> case 'f':
>
> 	if ( (adjust_gap_count < 0) || (adjust_gap_count > INT32_MAX) )
>         	err(EX_USAGE, "%s:adjust_gap_count out of range", __func__);
>
>
> I think "out of range" is better than "invalid number".
> -5 is a valid number.
> 	current_board = strtol(optarg, NULL, 0);
> Just a minor nit, feel free to ignore this one.  :-)
>
> ================================================================================
>
>   
Agreed.  It's a nit, but I'll change it.
>> case 'c':
>>           crom_string = malloc(strlen(optarg)+1);
>>           if (crom_string == NULL)
>>              err(EX_SOFTWARE, "%s:crom_string malloc", __func__);
>>           if ( (strtol(crom_string, NULL, 0) < 0) || strtol(crom_string, NULL, 0) > MAX_BOARDS)
>>              err(EX_USAGE, "%s:Invalid value for node", __func__);
>>           strcpy(crom_string, optarg);
>>     
>
> Strtol() reads freshly malloc-ed memory before anything has been put there.
>
> Perhaps:
>
> case 'c':
> 	{
> 	long node_num;
> 	node_num = strtol(optarg, NULL, 0);
> 	if ( (node_num < 0) || (node_num > MAX_BOARDS) )
> 		err(EX_USAGE, "%s:node out of range", __func__);
> 	crom_string = malloc(strlen(optarg)+1);
> 	if (crom_string == NULL)
> 		err(EX_SOFTWARE, "%s:crom_string malloc", __func__);
> 	strcpy(crom_string, optarg);
>
> 	...
>
> 	}
> case 'd':
>
>
> ================================================================================
>
>   
This is a big ol' whoops on my part.  The whole "malloc" and copy thing 
just seems pointless and needs to be consolidated into just a "strtol()" 
instead.

> case 'u':
>
> 	current_board = strtol(optarg, NULL, 0);
>
> Does this need a range check?
>
> ================================================================================
>   
Probably should be a range check( current_board < 0 and current_board > 
MAX_BOARDS).

-- 
Sean Bruno
MiraLink Corporation
6015 NE 80th Ave, Ste 100
Portland, OR 97218
Phone 503-621-5143
Fax 503-621-5199
MSN: [email protected]
Google:  [email protected]
Yahoo:  [email protected]

_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-firewire
To unsubscribe, send any mail to "[email protected]"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.