On Tue, Mar 6, 2012 at 7:50 PM, Alexander Kriegisch <[email protected]> wrote:
> Sorry for pushing this, but there has been traffic on the list, but no
> reaction to my inquiry. If I was unclear of information is missing,
> please let me know.
You should not be sorry. It's standard practice to ping
when no reply is received.
>>> # Not okay
>>> $ printf "%b" '\0057usr\0057bin\n'
>>> 7usr7bin
Please try attached patch.
--
vda
diff -d -urpN busybox.8/coreutils/printf.c busybox.9/coreutils/printf.c
--- busybox.8/coreutils/printf.c 2011-10-28 18:09:32.000000000 +0200
+++ busybox.9/coreutils/printf.c 2012-03-07 11:55:26.982016907 +0100
@@ -132,13 +132,28 @@ static double my_xstrtod(const char *arg
return result;
}
+/* Handles %b */
static void print_esc_string(const char *str)
{
char c;
while ((c = *str) != '\0') {
str++;
- if (c == '\\')
- c = bb_process_escape_sequence(&str);
+ if (c == '\\') {
+ /* %b also accepts 4-digit octals of the form \0### */
+ if (*str == '0') {
+ if ((unsigned char)(str[1] - '0') < 8) {
+ /* 2nd char is 0..7: skip leading '0' */
+ str++;
+ }
+ }
+ {
+ /* optimization: don't force arg to be on-stack,
+ * use another variable for that. */
+ const char *z = str;
+ c = bb_process_escape_sequence(&z);
+ str = z;
+ }
+ }
putchar(c);
}
}
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox