Date: Mon, 18 Aug 2008 12:13:29 +0100 From: Dieter <freebsd@sopwith.solgatos.com> To: Sean Bruno <sbruno@miralink.com> Cc: Scott Long <scottl@samsco.org>, freebsd-firewire@freebsd.org Subject: Re: fwcontrol update Message-ID: <200808181913.TAA21449@sopwith.solgatos.com> In-Reply-To: Your message of "Sun, 17 Aug 2008 10:43:17 PDT." <48A86335.8060508@miralink.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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. Just a minor nit, feel free to ignore this one. :-) ================================================================================ > 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': ================================================================================ case 'u': current_board = strtol(optarg, NULL, 0); Does this need a range check? ================================================================================
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808181913.TAA21449>