Fixes busybox perror patch (BB)
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 20 Jan 2015 02:26:47 +0000 (21:26 -0500)
committerBarret Rhoden <brho@cs.berkeley.edu>
Tue, 20 Jan 2015 02:26:47 +0000 (21:26 -0500)
The old patch to BB was buggy.  fputs() now sets errno internally in
some cases, which is legal.  I shouldn't have checked errno blindly
without checking the ret of fputs().

You'll need to repatch and build busybox.  The 'easiest' way is to
download the tarball, extract the old echo.c, and reapply the patch.

From the directory containing busybox-1.17.3:

$ wget http://www.busybox.net/downloads/busybox-1.17.3.tar.bz2
$ tar -xjf busybox-1.17.3.tar.bz2 busybox-1.17.3/coreutils/echo.c
$ patch -p1 < $AKAROS_REPO/tools/patches/busybox/bb-echo-perror.patch
$ cd busybox-1.17.3 ; make
$ cp busybox_unstripped $AKAROS_REPO/kern/kfs/bin/busybox

tools/patches/busybox/bb-echo-perror.patch

index 5320d4f..2820248 100644 (file)
@@ -8,20 +8,18 @@
        const char *arg;
  #if !ENABLE_FEATURE_FANCY_ECHO
        enum {
-@@ -101,7 +102,11 @@
+@@ -101,7 +102,9 @@
  
                if (!eflag) {
                        /* optimization for very common case */
 -                      fputs(arg, stdout);
-+                      errno = 0;
-+                      fputs(arg, stdout);
-+                      if (errno)
++                      ret = fputs(arg, stdout);
++                      if (ret == EOF)
 +                              perror("echo failed");
-+
                } else while ((c = *arg++)) {
                        if (c == eflag) {       /* Check for escape seq. */
                                if (*arg == 'c') {
-@@ -141,7 +146,11 @@
+@@ -141,7 +144,11 @@
                bb_putchar('\n');
        }
   ret: