This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[patch] strings -n <arg> parsing explicit error
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: binutils at sourceware dot org
- Date: Tue, 25 Nov 2008 19:45:06 +0100
- Subject: [patch] strings -n <arg> parsing explicit error
Hi,
a change
http://sourceware.org/ml/binutils-cvs/2008-02/msg00083.html
changed the original error text:
$ strings -n foo bar
strings: invalid integer argument foo
into a worse error text
$ strings -n foo bar
strings: invalid minimum string length 0
Fix it up back to error out again with more clear:
$ strings -n foo bar
strings: invalid integer argument foo
Regression tested on x86_64-unknown-linux-gnu.
Thanks,
Jan
2008-11-25 Jan Kratochvil <jan.kratochvil@redhat.com>
* strings.c (main): New variable `s'. STRING_MIN parsing got an
explicit `fatal' call for invalid input number strings.
--- binutils/strings.c 25 Aug 2008 04:38:13 -0000 1.42
+++ binutils/strings.c 25 Nov 2008 18:43:34 -0000
@@ -155,6 +155,7 @@ main (int argc, char **argv)
int optc;
int exit_status = 0;
bfd_boolean files_given = FALSE;
+ char *s;
#if defined (HAVE_SETLOCALE)
setlocale (LC_ALL, "");
@@ -192,7 +193,9 @@ main (int argc, char **argv)
usage (stdout, 0);
case 'n':
- string_min = (int) strtoul (optarg, NULL, 0);
+ string_min = (int) strtoul (optarg, &s, 0);
+ if (s != NULL && *s != 0)
+ fatal (_("invalid integer argument %s"), optarg);
break;
case 'o':
@@ -242,7 +245,9 @@ main (int argc, char **argv)
usage (stderr, 1);
default:
- string_min = (int) strtoul (argv[optind - 1] + 1, NULL, 0);
+ string_min = (int) strtoul (argv[optind - 1] + 1, &s, 0);
+ if (s != NULL && *s != 0)
+ fatal (_("invalid integer argument %s"), argv[optind - 1] + 1);
break;
}
}