When I use the command "strings" like this: "strings -0 file" will trap in
The binutils version is 18.104.22.168.6. Has this bug been fixed?
If not, here is my patch.
Signed-off-by: Chu Li <email@example.com>
diff --git a/strings.c b/strings.c
index 4c68ea8..8ee2783 100644
@@ -274,6 +274,9 @@ main (int argc, char **argv)
+ if(string_min == 0)
+ fatal (_("invalid number %d"), string_min);
if (string_min < 0)
string_min = 4;
Created attachment 2227 [details]
After applying this patch, when use "strings -0 file", "invalid number 0" will be reported.
(In reply to comment #2)
> Fixed by
I found using "strings -n 0 file" or "strings --bytes=0 file", "invalid number
0" will be reported. So "strings -0 file" should report "invalid number 0" not
just use "4" as min-length.
I think my patch may be more appropriate.
Created attachment 2262 [details]
Improve handlign of -<number> command line option
I agree, strings should be consistent with the error messages that it generates.
There is also another problem, in that currently:
strings -1 -2 <file>
will print all the strings of 12 bytes of more in <file> rather than, as might
reasonably be assumed, all strings of 2 bytes or more.
I have uploaded a patch to address both these points. Please try it out and
let me know what you think.
I have tried it out. It' Ok now. And I found if the "num" is the hex number
in "-n num" option , the result is a little strange and 0xA can't be
So I made a patch for it. Hope it is useful.
Created attachment 2268 [details]
Used for "-n num" when num is hexadecimal or octal
Created attachment 2269 [details]
Revised patch which removes integer_arg()
Thanks for pointing that out. In fact the integer_arg() function is
completely redundant as the C library function strtoul() does everything that is
needed. So I have applied a revised version of the patch which removes the
I hope that this resolves the issue for you.
2008-02-15 Chu Li <firstname.lastname@example.org>
Nick Clifton <email@example.com>
* strings.c (integer_arg): Delete function.
(string_min): Initialise to 4.
(main): Use strtoul to parse integer arguments.
Move check for an invalid string length to after all the arguments
have been parsed.
(usage): Use indentation to indicate that -<n> is a another form
of the --bytes= command line option.
I think it's OK now.