[util] Treat empty integer strings as invalid

Signed-off-by: Michael Brown <mcb30@ipxe.org>
pull/111/merge
Michael Brown 2020-06-19 16:56:02 +01:00
parent 770a7bd43a
commit 2000297011
2 changed files with 3 additions and 3 deletions

View File

@ -207,14 +207,14 @@ static int parse_options ( const int argc, char **argv,
switch ( c ) { switch ( c ) {
case 'v': case 'v':
opts->vendor = strtoul ( optarg, &end, 16 ); opts->vendor = strtoul ( optarg, &end, 16 );
if ( *end ) { if ( *end || ( ! *optarg ) ) {
eprintf ( "Invalid vendor \"%s\"\n", optarg ); eprintf ( "Invalid vendor \"%s\"\n", optarg );
exit ( 2 ); exit ( 2 );
} }
break; break;
case 'd': case 'd':
opts->device = strtoul ( optarg, &end, 16 ); opts->device = strtoul ( optarg, &end, 16 );
if ( *end ) { if ( *end || ( ! *optarg ) ) {
eprintf ( "Invalid device \"%s\"\n", optarg ); eprintf ( "Invalid device \"%s\"\n", optarg );
exit ( 2 ); exit ( 2 );
} }

View File

@ -996,7 +996,7 @@ static int parse_options ( const int argc, char **argv,
switch ( c ) { switch ( c ) {
case 's': case 's':
opts->subsystem = strtoul ( optarg, &end, 0 ); opts->subsystem = strtoul ( optarg, &end, 0 );
if ( *end ) { if ( *end || ( ! *optarg ) ) {
eprintf ( "Invalid subsytem \"%s\"\n", eprintf ( "Invalid subsytem \"%s\"\n",
optarg ); optarg );
exit ( 2 ); exit ( 2 );