When I use the command "strings" like this: "strings -0 file" will trap in infinite loop. The binutils version is 2.17.50.0.6. Has this bug been fixed? If not, here is my patch. Thank you. Chu Li Signed-off-by: Chu Li <chul@cn.fujitsu.com> ---------------------------------------------- diff --git a/strings.c b/strings.c index 4c68ea8..8ee2783 100644 --- a/strings.c +++ b/strings.c @@ -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.
Fixed by http://sourceware.org/ml/binutils/2008-02/msg00067.html
(In reply to comment #2) > Fixed by > http://sourceware.org/ml/binutils/2008-02/msg00067.html 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. Regards
Created attachment 2262 [details] Improve handlign of -<number> command line option
Hi Chu, 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. Cheers Nick
Hi, 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 recognized. So I made a patch for it. Hope it is useful. Regards Chuli
Created attachment 2268 [details] Used for "-n num" when num is hexadecimal or octal
Created attachment 2269 [details] Revised patch which removes integer_arg()
Hi Chu, 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 function entirely. I hope that this resolves the issue for you. Cheers Nick binutils/ChangeLog 2008-02-15 Chu Li <chul@cn.fujitsu.com> Nick Clifton <nickc@redhat.com> PR binutils/5713 * 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.
Hi, I think it's OK now.