Summary: | strings: use '-0' as option will meet infinite loop | ||
---|---|---|---|
Product: | binutils | Reporter: | chuli <chul> |
Component: | binutils | Assignee: | unassigned |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | bug-binutils |
Priority: | P2 | ||
Version: | 2.17 | ||
Target Milestone: | --- | ||
Host: | Target: | ||
Build: | Last reconfirmed: | ||
Attachments: |
After applying this patch, when use "strings -0 file", "invalid number 0" will be reported.
Improve handlign of -<number> command line option Used for "-n num" when num is hexadecimal or octal Revised patch which removes integer_arg() |
Description
chuli
2008-02-02 02:42:05 UTC
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 > 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. |