From bugs at busybox.net Thu May 1 00:27:48 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Thu, 1 May 2008 00:27:48 -0700 Subject: [BusyBox 0003224]: error in fdisk.c Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=3224 ====================================================================== Reported By: wenjinshan Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 3224 Category: Kernel Module Support Reproducibility: always Severity: major Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 04-30-2008 12:06 PDT Last Modified: 05-01-2008 00:27 PDT ====================================================================== Summary: error in fdisk.c Description: fdisk -> t (change a partition's system id) -> Hex code(type L to list codes) can't return main menu. ====================================================================== ---------------------------------------------------------------------- vda - 05-01-08 00:27 ---------------------------------------------------------------------- Bug exists in 1.9.x, fixed in 1.10.x Issue History Date Modified Username Field Change ====================================================================== 04-30-08 12:06 wenjinshan New Issue 04-30-08 12:06 wenjinshan Status new => assigned 04-30-08 12:06 wenjinshan Assigned To => BusyBox 04-30-08 12:06 wenjinshan File Added: fdisk.c 05-01-08 00:27 vda Status assigned => closed 05-01-08 00:27 vda Note Added: 0007324 ====================================================================== From bugs at busybox.net Thu May 1 09:15:18 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Thu, 1 May 2008 09:15:18 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: <368ca59d5ee89481eca6bdc633283771@bugs.busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-01-2008 09:15 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 ====================================================================== From bugs at busybox.net Thu May 1 23:58:06 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Thu, 1 May 2008 23:58:06 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: <0b58f1c8f67ac60d3beebceffffc06bd@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-01-2008 23:58 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 ====================================================================== From bugs at busybox.net Fri May 2 00:19:39 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 2 May 2008 00:19:39 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: <5da5b6b0d1b56f17e2712c0d13a21f7f@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-02-2008 00:19 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:19 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 05-02-08 00:19 vda Note Added: 0007354 ====================================================================== From vda at busybox.net Fri May 2 02:19:29 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 May 2008 02:19:29 -0700 (PDT) Subject: svn commit: trunk/busybox/testsuite Message-ID: <20080502091929.6BC043C708@busybox.net> Author: vda Date: 2008-05-02 02:19:29 -0700 (Fri, 02 May 2008) New Revision: 21917 Log: runtest: the saga continues :( Modified: trunk/busybox/testsuite/runtest Changeset: Modified: trunk/busybox/testsuite/runtest =================================================================== --- trunk/busybox/testsuite/runtest 2008-05-02 07:18:29 UTC (rev 21916) +++ trunk/busybox/testsuite/runtest 2008-05-02 09:19:29 UTC (rev 21917) @@ -62,18 +62,12 @@ for testcase in "$tsdir/$applet"/*; do # switch on basename of $testcase case "${testcase##*/}" in - \#*) - continue - ;; - *\~) - continue - ;; - "CVS") - continue - ;; - .*) - continue - ;; + .*) continue ;; # .svn, .git etc + *~) continue ;; # backup files + "CVS") continue ;; + \#*) continue ;; # CVS merge residues + *.mine) continue ;; # svn-produced junk + *.r[0-9]*) continue ;; # svn-produced junk esac run_applet_testcase "$applet" "$testcase" test $? -eq 0 || status=1 @@ -122,22 +116,13 @@ done # Set up option flags so tests can be selective. -export OPTIONFLAGS=:$(sed -nr 's/^CONFIG_//p' "$bindir/.config" | sed 's/=.*//' | xargs | sed 's/ /:/g') +export OPTIONFLAGS=:$( + sed -nr 's/^CONFIG_//p' "$bindir/.config" | + sed 's/=.*//' | xargs | sed 's/ /:/g' + ) status=0 for applet in $applets; do - case "$applet" in - "links") - continue - ;; - "CVS") - continue - ;; - .*) - continue - ;; - esac - # Any old-style tests for this applet? if [ -d "$tsdir/$applet" ]; then run_oldstyle_applet_tests "$applet" @@ -162,7 +147,7 @@ # Leaving the dir makes it somewhat easier to run failed test by hand #rm -rf "$LINKSDIR" -if [ $status -ne 0 -a x"$VERBOSE" = x ]; then +if [ $status -ne 0 ] && [ x"$VERBOSE" = x ]; then echo "Failures detected, running with -v (verbose) will give more info" fi exit $status From vda at busybox.net Fri May 2 02:39:09 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 May 2008 02:39:09 -0700 (PDT) Subject: svn commit: trunk/busybox/testsuite Message-ID: <20080502093909.BEC4E3C678@busybox.net> Author: vda Date: 2008-05-02 02:39:09 -0700 (Fri, 02 May 2008) New Revision: 21918 Log: testing.sh: bashisms are eradicated. By Cristian Ionescu-Idbohrn Modified: trunk/busybox/testsuite/testing.sh Changeset: Modified: trunk/busybox/testsuite/testing.sh =================================================================== --- trunk/busybox/testsuite/testing.sh 2008-05-02 09:19:29 UTC (rev 21917) +++ trunk/busybox/testsuite/testing.sh 2008-05-02 09:39:09 UTC (rev 21918) @@ -79,7 +79,7 @@ cmp expected actual >/dev/null 2>/dev/null if [ $? -ne 0 ] then - FAILCOUNT=$[$FAILCOUNT+1] + FAILCOUNT=$(($FAILCOUNT + 1)) echo "FAIL: $NAME" [ -n "$VERBOSE" ] && diff -u expected actual else @@ -107,7 +107,8 @@ shift for i in "$@" do - [ "${i:0:1}" == "/" ] || i=$(which $i) + #bashism: [ "${i:0:1}" == "/" ] || i=$(which $i) + i=$(which $i) # no-op for /bin/prog [ -f "$dest/$i" ] && continue if [ -e "$i" ] then From bugs at busybox.net Fri May 2 05:25:01 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 2 May 2008 05:25:01 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: <2815bb7792846dc6d45c01aaca4d3078@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-02-2008 05:25 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:46 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Recompile, let it crash, and show the output. ---------------------------------------------------------------------- fingar - 05-02-08 05:25 ---------------------------------------------------------------------- result of debug # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 Segmentation fault # Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 05-02-08 00:19 vda Note Added: 0007354 05-02-08 00:46 vda Note Edited: 0007354 05-02-08 05:25 fingar Note Added: 0007364 ====================================================================== From vda at busybox.net Fri May 2 05:35:00 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 May 2008 05:35:00 -0700 (PDT) Subject: svn commit: trunk/busybox/testsuite Message-ID: <20080502123500.135D43C773@busybox.net> Author: vda Date: 2008-05-02 05:34:59 -0700 (Fri, 02 May 2008) New Revision: 21920 Log: fix grep test false positive Modified: trunk/busybox/testsuite/grep.tests Changeset: Modified: trunk/busybox/testsuite/grep.tests =================================================================== --- trunk/busybox/testsuite/grep.tests 2008-05-02 11:20:00 UTC (rev 21919) +++ trunk/busybox/testsuite/grep.tests 2008-05-02 12:34:59 UTC (rev 21920) @@ -26,7 +26,9 @@ testing "grep input (specify file)" "grep two input" "two\n" \ "one\ntwo\nthree\nthree\nthree\n" "" -testing "grep (no newline at EOL)" "grep bug" "bug" "bug" "" +# GNU grep (version?) outputs a new line character after the located string +# even if there is no new line character in the input +testing "grep (no newline at EOL)" "grep bug input" "bug\n" "bug" "" >empty testing "grep two files" "grep two input empty 2>/dev/null" \ From vda at busybox.net Fri May 2 06:21:25 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 May 2008 06:21:25 -0700 (PDT) Subject: svn commit: trunk/busybox: testsuite util-linux Message-ID: <20080502132125.3BA483C7BE@busybox.net> Author: vda Date: 2008-05-02 06:21:24 -0700 (Fri, 02 May 2008) New Revision: 21921 Log: mdev: fix a bug where we were eating argv[0] of helper Modified: trunk/busybox/testsuite/mdev.tests trunk/busybox/util-linux/mdev.c Changeset: Modified: trunk/busybox/testsuite/mdev.tests =================================================================== --- trunk/busybox/testsuite/mdev.tests 2008-05-02 12:34:59 UTC (rev 21920) +++ trunk/busybox/testsuite/mdev.tests 2008-05-02 13:21:24 UTC (rev 21921) @@ -18,6 +18,8 @@ # We need mdev executable to be in chroot jail! # (will still fail with dynamically linked one, though...) cp ../busybox mdev.testdir/mdev +mkdir mdev.testdir/bin +cp ../busybox mdev.testdir/bin/sh 2>/dev/null # for testing cmd feature mkdir mdev.testdir/etc mkdir mdev.testdir/dev mkdir -p mdev.testdir/sys/block/sda @@ -93,6 +95,20 @@ " \ "" "" +# continuing to use directory structure from prev test +rm -rf mdev.testdir/dev/* +# here we complicate things by having non-matching group 1 and using %0 +echo "sda 0:0 644 @echo @echo TEST" >mdev.testdir/etc/mdev.conf +testing "mdev command" \ + "env - ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; + ls -lnR mdev.testdir/dev | $FILTER_LS" \ +"\ + at echo TEST +mdev.testdir/dev: +brw-r--r-- 1 0 0 8,0 sda +" \ + "" "" + # clean up rm -rf mdev.testdir Modified: trunk/busybox/util-linux/mdev.c =================================================================== --- trunk/busybox/util-linux/mdev.c 2008-05-02 12:34:59 UTC (rev 21920) +++ trunk/busybox/util-linux/mdev.c 2008-05-02 13:21:24 UTC (rev 21921) @@ -156,43 +156,45 @@ mode = strtoul(val, NULL, 8); /* 4th field (opt): >alias */ - if (ENABLE_FEATURE_MDEV_RENAME) { - if (!next) - break; +#if ENABLE_FEATURE_MDEV_RENAME + if (!next) + break; + if (*next == '>') { +#if ENABLE_FEATURE_MDEV_RENAME_REGEXP + char *s, *p; + unsigned i, n; + val = next; next = next_field(val); - if (*val == '>') { -#if ENABLE_FEATURE_MDEV_RENAME_REGEXP - /* substitute %1..9 with off[1..9], if any */ - char *s, *p; - unsigned i, n; + /* substitute %1..9 with off[1..9], if any */ + n = 0; + s = val; + while (*s && *s++ == '%') + n++; - n = 0; - s = val; - while (*s && *s++ == '%') - n++; - - p = alias = xzalloc(strlen(val) + n * strlen(device_name)); - s = val + 1; - while (*s) { - *p = *s; - if ('%' == *s) { - i = (s[1] - '0'); - if (i <= 9 && off[i].rm_so >= 0) { - n = off[i].rm_eo - off[i].rm_so; - strncpy(p, device_name + off[i].rm_so, n); - p += n - 1; - s++; - } + p = alias = xzalloc(strlen(val) + n * strlen(device_name)); + s = val + 1; + while (*s) { + *p = *s; + if ('%' == *s) { + i = (s[1] - '0'); + if (i <= 9 && off[i].rm_so >= 0) { + n = off[i].rm_eo - off[i].rm_so; + strncpy(p, device_name + off[i].rm_so, n); + p += n - 1; + s++; } - p++; - s++; } + p++; + s++; + } #else - alias = xstrdup(val + 1); + val = next; + next = next_field(val); + alias = xstrdup(val + 1); #endif - } } +#endif /* ENABLE_FEATURE_MDEV_RENAME */ /* The rest (opt): command to run */ if (!next) From vda at busybox.net Fri May 2 06:26:19 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 May 2008 06:26:19 -0700 (PDT) Subject: svn commit: trunk/busybox/testsuite Message-ID: <20080502132619.372FC3C790@busybox.net> Author: vda Date: 2008-05-02 06:26:18 -0700 (Fri, 02 May 2008) New Revision: 21922 Log: clarify grep version Modified: trunk/busybox/testsuite/grep.tests Changeset: Modified: trunk/busybox/testsuite/grep.tests =================================================================== --- trunk/busybox/testsuite/grep.tests 2008-05-02 13:21:24 UTC (rev 21921) +++ trunk/busybox/testsuite/grep.tests 2008-05-02 13:26:18 UTC (rev 21922) @@ -26,7 +26,7 @@ testing "grep input (specify file)" "grep two input" "two\n" \ "one\ntwo\nthree\nthree\nthree\n" "" -# GNU grep (version?) outputs a new line character after the located string +# GNU grep 2.5.3 outputs a new line character after the located string # even if there is no new line character in the input testing "grep (no newline at EOL)" "grep bug input" "bug\n" "bug" "" From bugs at busybox.net Fri May 2 06:30:47 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 2 May 2008 06:30:47 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-02-2008 06:30 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:46 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Recompile, let it crash, and show the output. ---------------------------------------------------------------------- fingar - 05-02-08 05:25 ---------------------------------------------------------------------- result of debug # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 Segmentation fault # ---------------------------------------------------------------------- vda - 05-02-08 06:30 ---------------------------------------------------------------------- Wow... can you replace lines bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); with bb_error_msg("HERE2 buffer:%p idname%p bufsize %d", buffer, idname, bufsize); bb_error_msg("HERE21 buffer:'%s'", buffer); bb_error_msg("HERE22 idname:'%s'", idname); safe_strncpy(buffer, idname, bufsize); bb_error_msg("HERE23 returning '%s'", buffer); return buffer; Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 05-02-08 00:19 vda Note Added: 0007354 05-02-08 00:46 vda Note Edited: 0007354 05-02-08 05:25 fingar Note Added: 0007364 05-02-08 06:30 vda Note Added: 0007374 ====================================================================== From bugs at busybox.net Fri May 2 07:49:10 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 2 May 2008 07:49:10 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-02-2008 07:49 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:46 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Recompile, let it crash, and show the output. ---------------------------------------------------------------------- fingar - 05-02-08 05:25 ---------------------------------------------------------------------- result of debug # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 Segmentation fault # ---------------------------------------------------------------------- vda - 05-02-08 06:32 ---------------------------------------------------------------------- Wow... can you replace lines bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); with bb_error_msg("HERE2 buffer:%p idname:%p bufsize:%d", buffer, idname, bufsize); bb_error_msg("HERE21 buffer:'%s'", buffer); bb_error_msg("HERE22 idname:'%s'", idname); safe_strncpy(buffer, idname, bufsize); bb_error_msg("HERE23 returning '%s'", buffer); return buffer; ---------------------------------------------------------------------- kienvtran - 05-02-08 07:49 ---------------------------------------------------------------------- When I inserted debug statements like vda suggested, without modifying the code, the bug DISAPPEARED. In that case the outputs of "ls -l" and "ps" were useless, as they were interspersed with debug statements. Are there regression tests that I could run to ensure that I don't break anything else? Sorry about "id" breaking, I am kind of new at this. Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 05-02-08 00:19 vda Note Added: 0007354 05-02-08 00:46 vda Note Edited: 0007354 05-02-08 05:25 fingar Note Added: 0007364 05-02-08 06:30 vda Note Added: 0007374 05-02-08 06:32 vda Note Edited: 0007374 05-02-08 07:49 kienvtran Note Added: 0007384 ====================================================================== From bugs at busybox.net Fri May 2 08:49:45 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 2 May 2008 08:49:45 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-02-2008 08:49 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:46 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Recompile, let it crash, and show the output. ---------------------------------------------------------------------- fingar - 05-02-08 05:25 ---------------------------------------------------------------------- result of debug # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 Segmentation fault # ---------------------------------------------------------------------- vda - 05-02-08 06:32 ---------------------------------------------------------------------- Wow... can you replace lines bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); with bb_error_msg("HERE2 buffer:%p idname:%p bufsize:%d", buffer, idname, bufsize); bb_error_msg("HERE21 buffer:'%s'", buffer); bb_error_msg("HERE22 idname:'%s'", idname); safe_strncpy(buffer, idname, bufsize); bb_error_msg("HERE23 returning '%s'", buffer); return buffer; ---------------------------------------------------------------------- kienvtran - 05-02-08 07:49 ---------------------------------------------------------------------- When I inserted debug statements like vda suggested, without modifying the code, the bug DISAPPEARED. In that case the outputs of "ls -l" and "ps" were useless, as they were interspersed with debug statements. Are there regression tests that I could run to ensure that I don't break anything else? Sorry about "id" breaking, I am kind of new at this. ---------------------------------------------------------------------- fingar - 05-02-08 08:49 ---------------------------------------------------------------------- replaced the code with the extra debug messages as vda suggested. output is now # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 buffer:0x944a4 idname 0x94510 bufsize 12 ps: HERE21 buffer:'' ps: HERE22 idname:'root' ps: HERE23 returning 'root' 1 root 3000 S init 2 root SWN [ksoftirqd/0] 3 root SW< [events/0] 4 root SW< [khelper] 5 root SW< [kthread] 40 root SW< [kblockd/0] 44 root SW< [khubd] 46 root SW< [kseriod] 59 root SW [pdflush] 60 root SW [pdflush] 61 root SW< [kswapd0] 62 root SW< [aio/0] 64 root SW< [jfsIO] 65 root SW< [jfsCommit] 66 root SW< [jfsSync] 675 root SW [mtdblockd] 712 root SWN [jffs2_gcd_mtd1] 720 root 3004 S /sbin/syslogd -O /var/log/messages 722 root 3004 S /sbin/klogd 728 root 3008 S /bin/sh 733 root 3008 R ps # It works now. Is this a toolchain problem. If I remove the debug messages is it likely other things will be broken? Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 05-02-08 00:19 vda Note Added: 0007354 05-02-08 00:46 vda Note Edited: 0007354 05-02-08 05:25 fingar Note Added: 0007364 05-02-08 06:30 vda Note Added: 0007374 05-02-08 06:32 vda Note Edited: 0007374 05-02-08 07:49 kienvtran Note Added: 0007384 05-02-08 08:49 fingar Note Added: 0007394 ====================================================================== From bugs at busybox.net Fri May 2 09:39:27 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Fri, 2 May 2008 09:39:27 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: <8e5fdcc30fcb0d58ece822971f67ab91@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-02-2008 09:39 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:46 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Recompile, let it crash, and show the output. ---------------------------------------------------------------------- fingar - 05-02-08 05:25 ---------------------------------------------------------------------- result of debug # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 Segmentation fault # ---------------------------------------------------------------------- vda - 05-02-08 06:32 ---------------------------------------------------------------------- Wow... can you replace lines bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); with bb_error_msg("HERE2 buffer:%p idname:%p bufsize:%d", buffer, idname, bufsize); bb_error_msg("HERE21 buffer:'%s'", buffer); bb_error_msg("HERE22 idname:'%s'", idname); safe_strncpy(buffer, idname, bufsize); bb_error_msg("HERE23 returning '%s'", buffer); return buffer; ---------------------------------------------------------------------- kienvtran - 05-02-08 07:49 ---------------------------------------------------------------------- When I inserted debug statements like vda suggested, without modifying the code, the bug DISAPPEARED. In that case the outputs of "ls -l" and "ps" were useless, as they were interspersed with debug statements. Are there regression tests that I could run to ensure that I don't break anything else? Sorry about "id" breaking, I am kind of new at this. ---------------------------------------------------------------------- fingar - 05-02-08 08:49 ---------------------------------------------------------------------- replaced the code with the extra debug messages as vda suggested. output is now # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 buffer:0x944a4 idname 0x94510 bufsize 12 ps: HERE21 buffer:'' ps: HERE22 idname:'root' ps: HERE23 returning 'root' 1 root 3000 S init 2 root SWN [ksoftirqd/0] 3 root SW< [events/0] 4 root SW< [khelper] 5 root SW< [kthread] 40 root SW< [kblockd/0] 44 root SW< [khubd] 46 root SW< [kseriod] 59 root SW [pdflush] 60 root SW [pdflush] 61 root SW< [kswapd0] 62 root SW< [aio/0] 64 root SW< [jfsIO] 65 root SW< [jfsCommit] 66 root SW< [jfsSync] 675 root SW [mtdblockd] 712 root SWN [jffs2_gcd_mtd1] 720 root 3004 S /sbin/syslogd -O /var/log/messages 722 root 3004 S /sbin/klogd 728 root 3008 S /bin/sh 733 root 3008 R ps # It works now. Is this a toolchain problem. If I remove the debug messages is it likely other things will be broken? ---------------------------------------------------------------------- fingar - 05-02-08 09:39 ---------------------------------------------------------------------- Ihave done some further tests. I returned bb_pwd.c to the original version & modified safe_strncpy.c to return the buffer instead of the return of strncpy. This also produced a segmentation error. So the only way I seem to get it to work is to use the original safe_strncpy.c and the modified bb_pwd.c which returns buffer instead of the return of safe_strncpy(). I guess this is looking like a toolchain problem as I can't see why the original bb_pwd.c shouldn't work. Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 05-02-08 00:19 vda Note Added: 0007354 05-02-08 00:46 vda Note Edited: 0007354 05-02-08 05:25 fingar Note Added: 0007364 05-02-08 06:30 vda Note Added: 0007374 05-02-08 06:32 vda Note Edited: 0007374 05-02-08 07:49 kienvtran Note Added: 0007384 05-02-08 08:49 fingar Note Added: 0007394 05-02-08 09:39 fingar Note Added: 0007404 ====================================================================== From vda at busybox.net Fri May 2 14:46:30 2008 From: vda at busybox.net (vda at busybox.net) Date: Fri, 2 May 2008 14:46:30 -0700 (PDT) Subject: svn commit: trunk/busybox: scripts testsuite Message-ID: <20080502214630.A68AC3C65A@busybox.net> Author: vda Date: 2008-05-02 14:46:30 -0700 (Fri, 02 May 2008) New Revision: 21925 Log: more fixes to testsuite by Cristian and vda Added: trunk/busybox/scripts/echo.c Modified: trunk/busybox/testsuite/cpio.tests trunk/busybox/testsuite/testing.sh Changeset: Added: trunk/busybox/scripts/echo.c =================================================================== --- trunk/busybox/scripts/echo.c (rev 0) +++ trunk/busybox/scripts/echo.c 2008-05-02 21:46:30 UTC (rev 21925) @@ -0,0 +1,230 @@ +/* vi: set sw=4 ts=4: */ +/* + * echo implementation for busybox - used as a helper for testsuite/* + * on systems lacking "echo -en" + * + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * + * Original copyright notice is retained at the end of this file. + */ + +/* BB_AUDIT SUSv3 compliant -- unless configured as fancy echo. */ +/* http://www.opengroup.org/onlinepubs/007904975/utilities/echo.html */ + +/* Mar 16, 2003 Manuel Novoa III (mjn3 at codepoet.org) + * + * Because of behavioral differences, implemented configurable SUSv3 + * or 'fancy' gnu-ish behaviors. Also, reduced size and fixed bugs. + * 1) In handling '\c' escape, the previous version only suppressed the + * trailing newline. SUSv3 specifies _no_ output after '\c'. + * 2) SUSv3 specifies that octal escapes are of the form \0{#{#{#}}}. + * The previous version did not allow 4-digit octals. + */ + +#include +#include +#include + +#define WANT_HEX_ESCAPES 1 + +/* Usual "this only works for ascii compatible encodings" disclaimer. */ +#undef _tolower +#define _tolower(X) ((X)|((char) 0x20)) + +static char bb_process_escape_sequence(const char **ptr) +{ + static const char charmap[] = { + 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', 0, + '\a', '\b', '\f', '\n', '\r', '\t', '\v', '\\', '\\' }; + + const char *p; + const char *q; + unsigned int num_digits; + unsigned int r; + unsigned int n; + unsigned int d; + unsigned int base; + + num_digits = n = 0; + base = 8; + q = *ptr; + +#ifdef WANT_HEX_ESCAPES + if (*q == 'x') { + ++q; + base = 16; + ++num_digits; + } +#endif + + do { + d = (unsigned char)(*q) - '0'; +#ifdef WANT_HEX_ESCAPES + if (d >= 10) { + d = (unsigned char)(_tolower(*q)) - 'a' + 10; + } +#endif + + if (d >= base) { +#ifdef WANT_HEX_ESCAPES + if ((base == 16) && (!--num_digits)) { +/* return '\\'; */ + --q; + } +#endif + break; + } + + r = n * base + d; + if (r > UCHAR_MAX) { + break; + } + + n = r; + ++q; + } while (++num_digits < 3); + + if (num_digits == 0) { /* mnemonic escape sequence? */ + p = charmap; + do { + if (*p == *q) { + q++; + break; + } + } while (*++p); + n = *(p + (sizeof(charmap)/2)); + } + + *ptr = q; + + return (char) n; +} + + +int main(int argc, char **argv) +{ + const char *arg; + const char *p; + char nflag = 1; + char eflag = 0; + + /* We must check that stdout is not closed. */ + if (dup2(1, 1) != 1) + return -1; + + while (1) { + arg = *++argv; + if (!arg) + goto newline_ret; + if (*arg != '-') + break; + + /* If it appears that we are handling options, then make sure + * that all of the options specified are actually valid. + * Otherwise, the string should just be echoed. + */ + p = arg + 1; + if (!*p) /* A single '-', so echo it. */ + goto just_echo; + + do { + if (!strrchr("neE", *p)) + goto just_echo; + } while (*++p); + + /* All of the options in this arg are valid, so handle them. */ + p = arg + 1; + do { + if (*p == 'n') + nflag = 0; + if (*p == 'e') + eflag = '\\'; + } while (*++p); + } + just_echo: + while (1) { + /* arg is already == *argv and isn't NULL */ + int c; + + if (!eflag) { + /* optimization for very common case */ + fputs(arg, stdout); + } else while ((c = *arg++)) { + if (c == eflag) { /* Check for escape seq. */ + if (*arg == 'c') { + /* '\c' means cancel newline and + * ignore all subsequent chars. */ + goto ret; + } + { + /* Since SUSv3 mandates a first digit of 0, 4-digit octals + * of the form \0### are accepted. */ + if (*arg == '0') { + /* NB: don't turn "...\0" into "...\" */ + if (arg[1] && ((unsigned char)(arg[1]) - '0') < 8) { + arg++; + } + } + /* bb_process_escape_sequence handles NUL correctly + * ("...\" case. */ + c = bb_process_escape_sequence(&arg); + } + } + putchar(c); + } + + arg = *++argv; + if (!arg) + break; + putchar(' '); + } + + newline_ret: + if (nflag) { + putchar('\n'); + } + ret: + return fflush(stdout); +} + +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Kenneth Almquist. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. + * + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)echo.c 8.1 (Berkeley) 5/31/93 + */ Modified: trunk/busybox/testsuite/cpio.tests =================================================================== --- trunk/busybox/testsuite/cpio.tests 2008-05-02 20:31:57 UTC (rev 21924) +++ trunk/busybox/testsuite/cpio.tests 2008-05-02 21:46:30 UTC (rev 21925) @@ -4,6 +4,13 @@ . testing.sh +# check if hexdump supports the '-R' option +hexdump -R /dev/null 2>&1 || { + echo "'hexdump -R' is not available" >&2 + SKIP=1 + exit 1 +} + # ls -ln is showing date. Need to remove that, it's variable # sed: coalesce spaces # cut: remove date @@ -24,6 +31,9 @@ 00000090 14 24 19 07 a4 63 00 " +user=$(id -u) +group=$(id -g) + rm -rf cpio.testdir # testing "test name" "options" "expected result" "file input" "stdin" @@ -34,8 +44,8 @@ "\ 1 blocks 0 --rw-r--r-- 2 0 0 0 x --rw-r--r-- 2 0 0 0 y +-rw-r--r-- 2 $user $group 0 x +-rw-r--r-- 2 $user $group 0 y " \ "" "" Modified: trunk/busybox/testsuite/testing.sh =================================================================== --- trunk/busybox/testsuite/testing.sh 2008-05-02 20:31:57 UTC (rev 21924) +++ trunk/busybox/testsuite/testing.sh 2008-05-02 21:46:30 UTC (rev 21925) @@ -4,28 +4,29 @@ # # License is GPLv2, see LICENSE in the busybox tarball for full license text. -# This file defines two functions, "testing" and "optionflag" +# This file defines two functions, "testing" and "optional" +# and a couple more... # The following environment variables may be set to enable optional behavior # in "testing": # VERBOSE - Print the diff -u of each failed test case. # DEBUG - Enable command tracing. -# SKIP - do not perform this test (this is set by "optionflag") +# SKIP - do not perform this test (this is set by "optional") # # The "testing" function takes five arguments: -# $1) Description to display when running command -# $2) Command line arguments to command -# $3) Expected result (on stdout) -# $4) Data written to file "input" -# $5) Data written to stdin +# $1) Test description +# $2) Command(s) to run. May have pipes, redirects, etc +# $3) Expected result on stdout +# $4) Data to be written to file "input" +# $5) Data to be written to stdin # -# The exit value of testing is the exit value of the command it ran. +# The exit value of testing is the exit value of $2 it ran. # # The environment variable "FAILCOUNT" contains a cumulative total of the # number of failed tests. # The "optional" function is used to skip certain tests, ala: -# optionflag CONFIG_FEATURE_THINGY +# optional CONFIG_FEATURE_THINGY # # The "optional" function checks the environment variable "OPTIONFLAGS", # which is either empty (in which case it always clears SKIP) or @@ -35,15 +36,28 @@ export FAILCOUNT=0 export SKIP= +# Helper for helpers. Oh my... +test x"$ECHO" = x"" && { + ECHO="echo" + test x"`echo -ne`" = x"" || { + # Compile and use a replacement 'echo' which understands -e -n + ECHO="$PWD/echo-ne" + test -x "$ECHO" || { + gcc -Os -o "$ECHO" ../scripts/echo.c || exit 1 + } + } + export ECHO +} + # Helper functions optional() { - option=`echo "$OPTIONFLAGS" | egrep "(^|:)$1(:|\$)"` + option=`echo ":$OPTIONFLAGS:" | grep ":$1:"` # Not set? if [ -z "$1" ] || [ -z "$OPTIONFLAGS" ] || [ ${#option} -ne 0 ] then - SKIP="" + SKIP= return fi SKIP=1 @@ -54,7 +68,7 @@ testing() { NAME="$1" - [ -z "$1" ] && NAME=$2 + [ -z "$1" ] && NAME="$2" if [ $# -ne 5 ] then @@ -70,10 +84,10 @@ return 0 fi - echo -ne "$3" > expected - echo -ne "$4" > input + $ECHO -ne "$3" > expected + $ECHO -ne "$4" > input [ -z "$VERBOSE" ] || echo "echo '$5' | $2" - echo -ne "$5" | eval "$2" > actual + $ECHO -ne "$5" | eval "$2" > actual RETVAL=$? cmp expected actual >/dev/null 2>/dev/null @@ -101,7 +115,7 @@ { [ $# -lt 2 ] && return - echo -n . + $ECHO -n . dest=$1 shift @@ -136,7 +150,7 @@ # Copy utilities from command line arguments - echo -n "Setup chroot" + $ECHO -n "Setup chroot" mkchroot tmpdir4chroot $* echo @@ -152,4 +166,3 @@ umount -l tmpdir4chroot rmdir tmpdir4chroot } - From vda at busybox.net Sat May 3 00:21:28 2008 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 May 2008 00:21:28 -0700 (PDT) Subject: svn commit: trunk/busybox: coreutils include testsuite Message-ID: <20080503072128.6AE4B3C678@busybox.net> Author: vda Date: 2008-05-03 00:21:27 -0700 (Sat, 03 May 2008) New Revision: 21927 Log: uniq: support -w. closes bug 3094. function old new delta packed_usage 24136 24132 -4 uniq_main 399 384 -15 Modified: trunk/busybox/coreutils/uniq.c trunk/busybox/include/usage.h trunk/busybox/testsuite/uniq.tests Changeset: Modified: trunk/busybox/coreutils/uniq.c =================================================================== --- trunk/busybox/coreutils/uniq.c 2008-05-03 05:44:30 UTC (rev 21926) +++ trunk/busybox/coreutils/uniq.c 2008-05-03 07:21:27 UTC (rev 21927) @@ -12,8 +12,6 @@ #include "libbb.h" -static const char uniq_opts[] ALIGN1 = "cdu" "f:s:" "cdu\0\1\2\4"; - static FILE *xgetoptfile_uniq_s(char **argv, int read0write2) { const char *n; @@ -31,9 +29,11 @@ int uniq_main(int argc ATTRIBUTE_UNUSED, char **argv) { FILE *in, *out; - unsigned long dups, skip_fields, skip_chars, i; const char *s0, *e0, *s1, *e1, *input_filename; + unsigned long dups; + unsigned skip_fields, skip_chars, max_chars; unsigned opt; + unsigned i; enum { OPT_c = 0x1, @@ -41,15 +41,14 @@ OPT_u = 0x4, OPT_f = 0x8, OPT_s = 0x10, + OPT_w = 0x20, }; skip_fields = skip_chars = 0; + max_chars = -1; - opt = getopt32(argv, "cduf:s:", &s0, &s1); - if (opt & OPT_f) - skip_fields = xatoul(s0); - if (opt & OPT_s) - skip_chars = xatoul(s1); + opt_complementary = "f+:s+:w+"; + opt = getopt32(argv, "cduf:s:w:", &skip_fields, &skip_chars, &max_chars); argv += optind; input_filename = *argv; @@ -63,7 +62,7 @@ bb_show_usage(); } - s1 = e1 = NULL; /* prime the pump */ + s1 = e1 = NULL; /* prime the pump */ do { s0 = s1; @@ -81,16 +80,16 @@ ++e1; } - if (!s0 || strcmp(e0, e1)) { + if (!s0 || strncmp(e0, e1, max_chars)) { break; } - ++dups; /* Note: Testing for overflow seems excessive. */ + ++dups; /* note: testing for overflow seems excessive. */ } if (s0) { if (!(opt & (OPT_d << !!dups))) { /* (if dups, opt & OPT_e) */ - fprintf(out, "\0%d " + (opt & 1), dups + 1); + fprintf(out, "\0%ld " + (opt & 1), dups + 1); /* 1 == OPT_c */ fprintf(out, "%s\n", s0); } free((void *)s0); Modified: trunk/busybox/include/usage.h =================================================================== --- trunk/busybox/include/usage.h 2008-05-03 05:44:30 UTC (rev 21926) +++ trunk/busybox/include/usage.h 2008-05-03 07:21:27 UTC (rev 21927) @@ -4303,16 +4303,16 @@ ) #define uniq_trivial_usage \ - "[-fscdu]... [INPUT [OUTPUT]]" + "[-fscduw]... [INPUT [OUTPUT]]" #define uniq_full_usage "\n\n" \ - "Discard all but one of successive identical lines from INPUT\n" \ - "(or standard input), writing to OUTPUT (or standard output)\n" \ + "Discard duplicate lines\n" \ "\nOptions:" \ "\n -c Prefix lines by the number of occurrences" \ "\n -d Only print duplicate lines" \ "\n -u Only print unique lines" \ - "\n -f N Skip the first N fields" \ - "\n -s N Skip the first N chars (after any skipped fields)" \ + "\n -f N Skip first N fields" \ + "\n -s N Skip first N chars (after any skipped fields)" \ + "\n -w N Compare N characters in line" \ #define uniq_example_usage \ "$ echo -e \"a\\na\\nb\\nc\\nc\\na\" | sort | uniq\n" \ Modified: trunk/busybox/testsuite/uniq.tests =================================================================== --- trunk/busybox/testsuite/uniq.tests 2008-05-03 05:44:30 UTC (rev 21926) +++ trunk/busybox/testsuite/uniq.tests 2008-05-03 07:21:27 UTC (rev 21927) @@ -41,6 +41,7 @@ #-c occurrences #-d dups only #-u +#-w max chars # Test various command line options @@ -60,7 +61,23 @@ bb cc dd8 aa bb cc9 " +testing "uniq -w (compare max characters)" "uniq -w 2" \ +"cc1 +" "" \ +"cc1 +cc2 +cc3 +" +testing "uniq -s -w (skip fields and compare max chars)" \ +"uniq -s 2 -w 2" \ +"aaccaa +" "" \ +"aaccaa +aaccbb +bbccaa +" + # -d is "Suppress the writing fo lines that are not repeated in the input." # -u is "Suppress the writing of lines that are repeated in the input." # Therefore, together this means they should produce no output. From bugs at busybox.net Sat May 3 00:21:47 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 00:21:47 -0700 Subject: [BusyBox 0003094]: Implement -w option to uniq Message-ID: <4da5c90fee78f9faf07c369c6449fff7@busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=3094 ====================================================================== Reported By: McNetic Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 3094 Category: New Features Reproducibility: N/A Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 04-23-2008 00:42 PDT Last Modified: 05-03-2008 00:21 PDT ====================================================================== Summary: Implement -w option to uniq Description: With some trivial changes, it is possible to add the -w option (compare max N chars in line) to busybox uniq. The main addition is the longer usage message :). I attached a patch against current trunk including the feature + usage message + two unit test cases. ====================================================================== ---------------------------------------------------------------------- vda - 05-03-08 00:21 ---------------------------------------------------------------------- Applied as rev 21927. Thanks! Issue History Date Modified Username Field Change ====================================================================== 04-23-08 00:42 McNetic New Issue 04-23-08 00:42 McNetic Status new => assigned 04-23-08 00:42 McNetic Assigned To => BusyBox 04-23-08 00:42 McNetic File Added: busybox-uniq.patch 05-03-08 00:21 vda Status assigned => closed 05-03-08 00:21 vda Note Added: 0007414 ====================================================================== From bugs at busybox.net Sat May 3 00:23:20 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 00:23:20 -0700 Subject: [BusyBox 0002734]: "make menuconfig" unusable with colormake Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=2734 ====================================================================== Reported By: KiBi Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2734 Category: Other Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 04-02-2008 07:48 PDT Last Modified: 05-03-2008 00:23 PDT ====================================================================== Summary: "make menuconfig" unusable with colormake Description: With MAKE=colormake, calling "make menuconfig" (or calling "colormake menuconfig" with MAKE unset) results in the screen being cleared, and then one gets: --8<--8<--8<-- # # using defaults found in .config # interrupted(11) make[1]: *** [menuconfig] Error 1 make: *** [menuconfig] Error 2 -->8-->8-->8-- It might be a problem in colormake as well, but I guess it could be handled at least more gracefully by the busybox build system. Happens with 1.9.2 and 1.10.0 at least (both of which not being available in the "product version" drop-down list anyway). ====================================================================== ---------------------------------------------------------------------- vda - 04-02-08 11:16 ---------------------------------------------------------------------- Hmmm... Colormake --------- This is a simple wrapper for making the output from make easier to read (more colorful), and errors easier to find in messy compilations. It was inspired by Micheal T. Babcock's excellent logcolorize program. It most probably got utterly confused by "make menuconfig"'s output which contains ESC sequences etc. I am not volunteering to fix it... Issue History Date Modified Username Field Change ====================================================================== 04-02-08 07:48 KiBi New Issue 04-02-08 07:48 KiBi Status new => assigned 04-02-08 07:48 KiBi Assigned To => BusyBox 04-02-08 11:15 vda Note Added: 0006324 04-02-08 11:16 vda Note Edited: 0006324 05-03-08 00:23 vda Status assigned => closed ====================================================================== From bugs at busybox.net Sat May 3 01:38:11 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 01:38:11 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-03-2008 01:38 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:46 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Recompile, let it crash, and show the output. ---------------------------------------------------------------------- fingar - 05-02-08 05:25 ---------------------------------------------------------------------- result of debug # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 Segmentation fault # ---------------------------------------------------------------------- vda - 05-02-08 06:32 ---------------------------------------------------------------------- Wow... can you replace lines bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); with bb_error_msg("HERE2 buffer:%p idname:%p bufsize:%d", buffer, idname, bufsize); bb_error_msg("HERE21 buffer:'%s'", buffer); bb_error_msg("HERE22 idname:'%s'", idname); safe_strncpy(buffer, idname, bufsize); bb_error_msg("HERE23 returning '%s'", buffer); return buffer; ---------------------------------------------------------------------- kienvtran - 05-02-08 07:49 ---------------------------------------------------------------------- When I inserted debug statements like vda suggested, without modifying the code, the bug DISAPPEARED. In that case the outputs of "ls -l" and "ps" were useless, as they were interspersed with debug statements. Are there regression tests that I could run to ensure that I don't break anything else? Sorry about "id" breaking, I am kind of new at this. ---------------------------------------------------------------------- fingar - 05-02-08 08:49 ---------------------------------------------------------------------- replaced the code with the extra debug messages as vda suggested. output is now # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 buffer:0x944a4 idname 0x94510 bufsize 12 ps: HERE21 buffer:'' ps: HERE22 idname:'root' ps: HERE23 returning 'root' 1 root 3000 S init 2 root SWN [ksoftirqd/0] 3 root SW< [events/0] 4 root SW< [khelper] 5 root SW< [kthread] 40 root SW< [kblockd/0] 44 root SW< [khubd] 46 root SW< [kseriod] 59 root SW [pdflush] 60 root SW [pdflush] 61 root SW< [kswapd0] 62 root SW< [aio/0] 64 root SW< [jfsIO] 65 root SW< [jfsCommit] 66 root SW< [jfsSync] 675 root SW [mtdblockd] 712 root SWN [jffs2_gcd_mtd1] 720 root 3004 S /sbin/syslogd -O /var/log/messages 722 root 3004 S /sbin/klogd 728 root 3008 S /bin/sh 733 root 3008 R ps # It works now. Is this a toolchain problem. If I remove the debug messages is it likely other things will be broken? ---------------------------------------------------------------------- fingar - 05-02-08 09:39 ---------------------------------------------------------------------- Ihave done some further tests. I returned bb_pwd.c to the original version & modified safe_strncpy.c to return the buffer instead of the return of strncpy. This also produced a segmentation error. So the only way I seem to get it to work is to use the original safe_strncpy.c and the modified bb_pwd.c which returns buffer instead of the return of safe_strncpy(). I guess this is looking like a toolchain problem as I can't see why the original bb_pwd.c shouldn't work. ---------------------------------------------------------------------- vda - 05-03-08 01:38 ---------------------------------------------------------------------- What are the versions of ld and gcc? Post full output of gcc -v and ld -v. Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 05-02-08 00:19 vda Note Added: 0007354 05-02-08 00:46 vda Note Edited: 0007354 05-02-08 05:25 fingar Note Added: 0007364 05-02-08 06:30 vda Note Added: 0007374 05-02-08 06:32 vda Note Edited: 0007374 05-02-08 07:49 kienvtran Note Added: 0007384 05-02-08 08:49 fingar Note Added: 0007394 05-02-08 09:39 fingar Note Added: 0007404 05-03-08 01:38 vda Note Added: 0007424 ====================================================================== From vda at busybox.net Sat May 3 04:36:00 2008 From: vda at busybox.net (vda at busybox.net) Date: Sat, 3 May 2008 04:36:00 -0700 (PDT) Subject: svn commit: trunk/busybox/editors Message-ID: <20080503113600.8EBF13C679@busybox.net> Author: vda Date: 2008-05-03 04:35:59 -0700 (Sat, 03 May 2008) New Revision: 21928 Log: vi: do not truncate file to zero length. closes bug 2944. function old new delta file_write 98 104 +6 Modified: trunk/busybox/editors/vi.c Changeset: Modified: trunk/busybox/editors/vi.c =================================================================== --- trunk/busybox/editors/vi.c 2008-05-03 07:21:27 UTC (rev 21927) +++ trunk/busybox/editors/vi.c 2008-05-03 11:35:59 UTC (rev 21928) @@ -2437,11 +2437,16 @@ return -2; } charcnt = 0; - fd = open(fn, (O_WRONLY | O_CREAT | O_TRUNC), 0666); + /* By popular request we do not open file with O_TRUNC, + * but instead ftruncate() it _after_ successful write. + * Might reduce amount of data lost on power fail etc. + */ + fd = open(fn, (O_WRONLY | O_CREAT), 0666); if (fd < 0) return -1; cnt = last - first + 1; charcnt = full_write(fd, first, cnt); + ftruncate(fd, charcnt); if (charcnt == cnt) { // good write //file_modified = FALSE; // the file has not been modified From bugs at busybox.net Sat May 3 04:36:23 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 04:36:23 -0700 Subject: [BusyBox 0002944]: vi truncates the file synchronously in file_write() but does write() asynchronously. Message-ID: <195e19b0e22374728eaf37adf50f31f5@busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=2944 ====================================================================== Reported By: kulve Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2944 Category: Other Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 04-18-2008 11:13 PDT Last Modified: 05-03-2008 04:36 PDT ====================================================================== Summary: vi truncates the file synchronously in file_write() but does write() asynchronously. Description: Because the file is truncated to zero synchronously for in-place rewriting and written asynchronously it's vulnarable to losing all data on power loss. This is easily reproducable with e.g. UBIFS by editing the file, exiting and then immediately powering the device off (yeah, I should have run sync before just powering off). The file_write() should probably be done in a way that would lose only the changes, not the original file. With smaller files this could be achieved with e.g. using mv. ====================================================================== ---------------------------------------------------------------------- vda - 04-18-08 14:42 ---------------------------------------------------------------------- What do you mean "written asynchronously"? It is written this way: fd = open(fn, (O_WRONLY | O_CREAT | O_TRUNC), 0666); if (fd < 0) return -1; cnt = last - first + 1; charcnt = full_write(fd, first, cnt); if (charcnt == cnt) { // good write //file_modified = FALSE; // the file has not been modified } else { charcnt = 0; } close(fd); How do you propose doing it instead? ---------------------------------------------------------------------- kulve - 04-19-08 00:40 ---------------------------------------------------------------------- The write doesn't force (O_SYNC) data to be written to disk but it is left to cache waiting for the OS to write it to disk at some point. This is the normal case when writing. But because the O_TRUNC is synchronous operation on some filesystems, the file is truncated immediately. I suggest that the open() and write() uses the same method, either synchronous or not. With smaller files the content could be first written to a temporary file, then synced and then the temporary file could be renamed over the real one. The rename on same filesystem is atomic. This way the file would always be either the old one or the new one, corruption would not be possible. With this method the temporary file could be left on the filesystem if the power loss happens before the rename. And the method won't work with big files and low free space: if you have 5M free and you try to edit 6M file, you don't have space for the temporary file. Maybe the file could be opened with O_SYNC when saving? This would slow down the write phase compared to current situation but maybe in most use cases in normal busybox environments this wouldn't be a problem. And the user might even expect a slow write as he asked to write the file to the disk. There would still be a small chance for data corruption if the power loss happens during the write but at least the user wouldn't accidentally power off too early like I did. ---------------------------------------------------------------------- vda - 04-19-08 12:01 ---------------------------------------------------------------------- > With smaller files the content could be first written to a temporary file, then synced and then the temporary file could be renamed over the real one. The rename on same filesystem is atomic. This way the file would always be either the old one or the new one, corruption would not be possible. If what you edit is a symlink, this will trash the symlink (replace it with ordinary file). You probably don't want that to happen. The same will happen with hardlink, but in even less obvious way. This can be done with some effort (and in fact passwd applet has some code for that). Care to try to produce a patch? ---------------------------------------------------------------------- vda - 05-03-08 04:36 ---------------------------------------------------------------------- Changed to not open with O_TRUNC in rev 21928. Issue History Date Modified Username Field Change ====================================================================== 04-18-08 11:13 kulve New Issue 04-18-08 11:13 kulve Status new => assigned 04-18-08 11:13 kulve Assigned To => BusyBox 04-18-08 14:42 vda Note Added: 0006664 04-19-08 00:40 kulve Note Added: 0006674 04-19-08 12:01 vda Note Added: 0006684 05-03-08 04:36 vda Status assigned => closed 05-03-08 04:36 vda Note Added: 0007434 ====================================================================== From bugs at busybox.net Sat May 3 04:37:40 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 04:37:40 -0700 Subject: [BusyBox 0001586]: vi generates a Segmentation Fault when pasting Message-ID: <12122406ecbb2dd9cda3937f750f9a51@busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1586 ====================================================================== Reported By: opalenzuela Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1586 Category: Other Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 11-12-2007 07:31 PST Last Modified: 05-03-2008 04:37 PDT ====================================================================== Summary: vi generates a Segmentation Fault when pasting Description: Accessing my busybox platform through Putty, and editing a text file with busybox's "vi" (Insertion mode activated) just pasting a quite big amount of plain text bytes (maybe 10KB) it drops with a Segmentation Fault. CPU consumption before the crash was really high too (maybe the auto-justification has some relation with it)... ====================================================================== ---------------------------------------------------------------------- opalenzuela - 11-25-07 23:20 ---------------------------------------------------------------------- It looks like some problems on "auto-justifying" function, and opening-closure control on "{". In my opinion, this functions are not necessary for an embedded platform, and some file editing functions (jump to line, search string, replace?) should be enough. ---------------------------------------------------------------------- vda - 11-25-07 23:26 ---------------------------------------------------------------------- Can you give some *reproducible* way to trigger this? Also state busybox version and maybe attach your .config ---------------------------------------------------------------------- opalenzuela - 01-14-08 07:55 ---------------------------------------------------------------------- I haven't tried with latest versions. This problem was detected on a 1.6.x . I'll confirm it as soon as possible. Thanks. Issue History Date Modified Username Field Change ====================================================================== 11-12-07 07:31 opalenzuela New Issue 11-12-07 07:31 opalenzuela Status new => assigned 11-12-07 07:31 opalenzuela Assigned To => BusyBox 11-25-07 23:20 opalenzuela Note Added: 0002962 11-25-07 23:26 vda Note Added: 0002963 11-25-07 23:27 vda Status assigned => feedback 01-14-08 07:55 opalenzuela Note Added: 0003449 05-03-08 04:37 vda Status feedback => closed ====================================================================== From bugs at busybox.net Sat May 3 04:37:56 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 04:37:56 -0700 Subject: [BusyBox 0001600]: Cursor and other special keys don't work properly in vi Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1600 ====================================================================== Reported By: iggarpe Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1600 Category: Documentation Reproducibility: always Severity: major Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 11-21-2007 08:04 PST Last Modified: 05-03-2008 04:37 PDT ====================================================================== Summary: Cursor and other special keys don't work properly in vi Description: Looks like escape sequences are not being interpreted correctly. Once in several keypresses cursor keys generate weird cursor movenets and input. Detected in busybox 1.8.1 (with all current patches applied). Previous version no showing this problem: 1.7.3. Problem detected v ====================================================================== ---------------------------------------------------------------------- vda - 02-13-08 07:43 ---------------------------------------------------------------------- This report is vague. To reporter, can you be more specific? Whatever I type in my busybox's vi, everything seems to work. Issue History Date Modified Username Field Change ====================================================================== 11-21-07 08:04 iggarpe New Issue 11-21-07 08:04 iggarpe Status new => assigned 11-21-07 08:04 iggarpe Assigned To => BusyBox 02-13-08 07:43 vda Note Added: 0004394 02-13-08 07:43 vda Status assigned => feedback 05-03-08 04:37 vda Status feedback => closed ====================================================================== From bugs at busybox.net Sat May 3 04:38:57 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 04:38:57 -0700 Subject: [BusyBox 0001964]: ipv6 ifconfig displays garbage for ipv6 addresses on blackfin on busybox 1.9.0 Message-ID: <00ef42edc23251defc9b04b7cc8a23ef@busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1964 ====================================================================== Reported By: mtaht Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1964 Category: Networking Support Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 01-22-2008 01:05 PST Last Modified: 05-03-2008 04:38 PDT ====================================================================== Summary: ipv6 ifconfig displays garbage for ipv6 addresses on blackfin on busybox 1.9.0 Description: It appears that something is going wrong with the output of 'ifconfig' for ipv6. Haven't got so far as seeing if 'ip' is doing the right thing on setup... eth0 Link encap:Ethernet HWaddr 00:09:45:54:20:A5 inet addr:192.168.1.254 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: $#,/64 Scope:Link UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1 RX packets:800 errors:0 dropped:0 overruns:0 frame:0 TX packets:502 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:59718 (58.3 KiB) TX bytes:48195 (47.0 KiB) Interrupt:48 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: &http://busybox.net/bugs/view.php?id=65533;&http://busybox.net/bugs/view.php?id=65533;_^C^L&http://busybox.net/bugs/view.php?id=65533;_^C^Z&http://busybox.net/bugs/view.php?id=286;1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) sit1 Link encap:IPv6-in-IPv4 inet6 addr: &http://busybox.net/bugs/view.php?id=65533;&http://busybox.net/bugs/view.php?id=65533;_^C^L&http://busybox.net/bugs/view.php?id=65533;_^C^Z&http://busybox.net/bugs/view.php?id=286;1/64 Scope:Link UP POINTOPOINT RUNNING NOARP MTU:1280 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 ====================================================================== ---------------------------------------------------------------------- vda - 01-24-08 13:55 ---------------------------------------------------------------------- IIRC inet6 addresses in text form are generated here. Please add "bb_error_msg()" as indicated with '+' and let us know where it fails: char *INET6_rresolve(struct sockaddr_in6 *sin6, int numeric) { char name[128]; int s; if (sin6->sin6_family != AF_INET6) { #ifdef DEBUG bb_error_msg("rresolve: unsupport address family %d!", sin6->sin6_family); #endif errno = EAFNOSUPPORT; return NULL; } if (numeric & 0x7FFF) { inet_ntop(AF_INET6, &sin6->sin6_addr, name, sizeof(name)); +bb_error_msg("inet_ntop: %s", name) return xstrdup(name); } if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { if (numeric & 0x8000) return xstrdup(bb_str_default); return xstrdup("*"); } s = getnameinfo((struct sockaddr *) sin6, sizeof(struct sockaddr_in6), name, sizeof(name), NULL, 0, 0); if (s) { bb_error_msg("getnameinfo failed"); return NULL; } +bb_error_msg("getnameinfo: %s", name) return xstrdup(name); } Issue History Date Modified Username Field Change ====================================================================== 01-22-08 01:05 mtaht New Issue 01-22-08 01:05 mtaht Status new => assigned 01-22-08 01:05 mtaht Assigned To => BusyBox 01-24-08 13:55 vda Note Added: 0003514 05-03-08 04:38 vda Status assigned => closed ====================================================================== From bugs at busybox.net Sat May 3 04:40:12 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 04:40:12 -0700 Subject: [BusyBox 0001000]: this awk script don't work with busybox Message-ID: The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=1000 ====================================================================== Reported By: VEvgeniy Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 1000 Category: Standards Compliance Reproducibility: always Severity: minor Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 08-17-2006 08:28 PDT Last Modified: 05-03-2008 04:40 PDT ====================================================================== Summary: this awk script don't work with busybox Description: multipart.awk ------ start ------ BEGIN{ RS="\015\012" getline FS="\015\012" RS=$0 dirfile="/tmp" } { head=1 getfile="" getname="" typedata="f" if($1=="--"){exit} if($1==""){$0=substr($0,3)} for(i=1;i<=NF;i++){ head=head+length($i)+length(FS) if($i==""){ value=$0 value=substr(value,head,length(value)-head-1) if(getfile!=""){ printf("%s",value) > dirfile"/"getfile value=getfile } for(nl=1;nl<=length(value);nl=nl+2){ value=substr(value,1,nl-1)"\\"substr(value,nl) } while((nl=index(getname,"_"))>0){getname=substr(getname,1,nl-1)" "substr(getname,nl+1)} if(value==""){value="''"} print getname" "value next } if(i==1){ s=$1";" while(length(s)>0){ n=index(s,";") sl=substr(s,1,n-1) while(substr(sl,1,1)==" "){sl=substr(sl,2)} if(typedata=="f"){ if(sl=="Content-Disposition: form-data"){typedata="t"} } else{ if(substr(sl,1,5)=="name="){ getname=substr(sl,7,length(sl)-7) } if(substr(sl,1,9)=="filename="){ getfile=substr(sl,11,length(sl)-11) while((nl=index(getfile,"/"))>0){getfile=substr(getfile,nl+1)} while((nl=index(getfile,"\\"))>0){getfile=substr(getfile,nl+1)} } } s=substr(s,n+1) } } } } ------ end ------ This awk script work with "multipart/form-data" enctype in cgi-script for httpd Only "multipart/form-data" enctype form download files to server. If I use standart awk program, I have fine result with any files. If I use busybox awk, I have bad result. My files cut. problem strings: ... value=$0 value=substr(value,head,length(value)-head-1) if(getfile!=""){ printf("%s",value) > dirfile"/"getfile value=getfile } ... more file - more probability problem I have not fine result with 10MB file or more. ====================================================================== ---------------------------------------------------------------------- bernhardf - 08-25-06 08:40 ---------------------------------------------------------------------- I fear that i do not quite understand the problem you are describing. Can you please attach a tarball with 1) the awk script 2) example input file 3) expected output file 4) a script that converts the input file to the outputfile? regards, ---------------------------------------------------------------------- VEvgeniy - 08-26-06 07:10 ---------------------------------------------------------------------- my files size ~ 4.7 MB bernhardf, please send your e-mail address my e-mail vevgeniy82 at mail.ru ---------------------------------------------------------------------- vda - 02-14-08 07:03 ---------------------------------------------------------------------- Bernhard Fischer rep.dot.nop AT gmail.com Denys Vlasenko vda.linux AT googlemail.com Issue History Date Modified Username Field Change ====================================================================== 08-17-06 08:28 VEvgeniy New Issue 08-17-06 08:28 VEvgeniy Status new => assigned 08-17-06 08:28 VEvgeniy Assigned To => BusyBox 08-25-06 08:40 bernhardf Note Added: 0001588 08-26-06 07:10 VEvgeniy Note Added: 0001593 02-14-08 07:03 vda Note Added: 0004684 05-03-08 04:40 vda Status assigned => closed ====================================================================== From bugs at busybox.net Sat May 3 04:41:01 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Sat, 3 May 2008 04:41:01 -0700 Subject: [BusyBox 0002814]: Logging on httpd Message-ID: <20921ff7b1fc0dfaef6b803d01c83bfc@busybox.net> The following issue has been CLOSED ====================================================================== http://busybox.net/bugs/view.php?id=2814 ====================================================================== Reported By: opalenzuela Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2814 Category: New Features Reproducibility: N/A Severity: feature Priority: normal Status: closed Resolution: open Fixed in Version: ====================================================================== Date Submitted: 04-04-2008 02:24 PDT Last Modified: 05-03-2008 04:41 PDT ====================================================================== Summary: Logging on httpd Description: It may be interesting to enable logging options for httpd. For instance, an option in the configuration file like: L:/var/log/httpd.log It doesn't look too complicated, and it could be an interesting feature (specially as a debug tool for developers like me). ====================================================================== ---------------------------------------------------------------------- vda - 04-04-08 09:59 ---------------------------------------------------------------------- Have you tried "httpd -vvv ..." ? Issue History Date Modified Username Field Change ====================================================================== 04-04-08 02:24 opalenzuela New Issue 04-04-08 02:24 opalenzuela Status new => assigned 04-04-08 02:24 opalenzuela Assigned To => BusyBox 04-04-08 05:24 opalenzuela Issue Monitored: opalenzuela 04-04-08 09:59 vda Note Added: 0006404 05-03-08 04:41 vda Status assigned => closed ====================================================================== From aldot at busybox.net Mon May 5 07:45:33 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Mon, 5 May 2008 07:45:33 -0700 (PDT) Subject: svn commit: trunk/busybox/miscutils Message-ID: <20080505144533.8E3CB3C61F@busybox.net> Author: aldot Date: 2008-05-05 07:45:32 -0700 (Mon, 05 May 2008) New Revision: 21932 Log: - fix strncmp'ing "runlevel". (Cristian Ionescu-Idbohrn) Modified: trunk/busybox/miscutils/last.c Changeset: Modified: trunk/busybox/miscutils/last.c =================================================================== --- trunk/busybox/miscutils/last.c 2008-05-03 15:27:10 UTC (rev 21931) +++ trunk/busybox/miscutils/last.c 2008-05-05 14:45:32 UTC (rev 21932) @@ -49,7 +49,7 @@ ut.ut_type = SHUTDOWN_TIME; else if (strncmp(ut.ut_user, "reboot", 6) == 0) ut.ut_type = BOOT_TIME; - else if (strncmp(ut.ut_user, "runlevel", 7) == 0) + else if (strncmp(ut.ut_user, "runlevel", 8) == 0) ut.ut_type = RUN_LVL; } else { if (ut.ut_name[0] == '\0' || strcmp(ut.ut_name, "LOGIN") == 0) { From aldot at busybox.net Mon May 5 07:48:13 2008 From: aldot at busybox.net (aldot at busybox.net) Date: Mon, 5 May 2008 07:48:13 -0700 (PDT) Subject: svn commit: branches/busybox_1_10_stable/miscutils Message-ID: <20080505144813.D5A243C63E@busybox.net> Author: aldot Date: 2008-05-05 07:48:13 -0700 (Mon, 05 May 2008) New Revision: 21933 Log: - fix strncmp'ing "runlevel" r21931 from trunk Modified: branches/busybox_1_10_stable/miscutils/last.c Changeset: Modified: branches/busybox_1_10_stable/miscutils/last.c =================================================================== --- branches/busybox_1_10_stable/miscutils/last.c 2008-05-05 14:45:32 UTC (rev 21932) +++ branches/busybox_1_10_stable/miscutils/last.c 2008-05-05 14:48:13 UTC (rev 21933) @@ -49,7 +49,7 @@ ut.ut_type = SHUTDOWN_TIME; else if (strncmp(ut.ut_user, "reboot", 6) == 0) ut.ut_type = BOOT_TIME; - else if (strncmp(ut.ut_user, "runlevel", 7) == 0) + else if (strncmp(ut.ut_user, "runlevel", 8) == 0) ut.ut_type = RUN_LVL; } else { if (ut.ut_name[0] == '\0' || strcmp(ut.ut_name, "LOGIN") == 0) { From bugs at busybox.net Mon May 5 16:38:40 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Mon, 5 May 2008 16:38:40 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: <5310efe745a14a0ac8735f946b88c722@bugs.busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-05-2008 16:38 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:46 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Recompile, let it crash, and show the output. ---------------------------------------------------------------------- fingar - 05-02-08 05:25 ---------------------------------------------------------------------- result of debug # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 Segmentation fault # ---------------------------------------------------------------------- vda - 05-02-08 06:32 ---------------------------------------------------------------------- Wow... can you replace lines bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); with bb_error_msg("HERE2 buffer:%p idname:%p bufsize:%d", buffer, idname, bufsize); bb_error_msg("HERE21 buffer:'%s'", buffer); bb_error_msg("HERE22 idname:'%s'", idname); safe_strncpy(buffer, idname, bufsize); bb_error_msg("HERE23 returning '%s'", buffer); return buffer; ---------------------------------------------------------------------- kienvtran - 05-02-08 07:49 ---------------------------------------------------------------------- When I inserted debug statements like vda suggested, without modifying the code, the bug DISAPPEARED. In that case the outputs of "ls -l" and "ps" were useless, as they were interspersed with debug statements. Are there regression tests that I could run to ensure that I don't break anything else? Sorry about "id" breaking, I am kind of new at this. ---------------------------------------------------------------------- fingar - 05-02-08 08:49 ---------------------------------------------------------------------- replaced the code with the extra debug messages as vda suggested. output is now # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 buffer:0x944a4 idname 0x94510 bufsize 12 ps: HERE21 buffer:'' ps: HERE22 idname:'root' ps: HERE23 returning 'root' 1 root 3000 S init 2 root SWN [ksoftirqd/0] 3 root SW< [events/0] 4 root SW< [khelper] 5 root SW< [kthread] 40 root SW< [kblockd/0] 44 root SW< [khubd] 46 root SW< [kseriod] 59 root SW [pdflush] 60 root SW [pdflush] 61 root SW< [kswapd0] 62 root SW< [aio/0] 64 root SW< [jfsIO] 65 root SW< [jfsCommit] 66 root SW< [jfsSync] 675 root SW [mtdblockd] 712 root SWN [jffs2_gcd_mtd1] 720 root 3004 S /sbin/syslogd -O /var/log/messages 722 root 3004 S /sbin/klogd 728 root 3008 S /bin/sh 733 root 3008 R ps # It works now. Is this a toolchain problem. If I remove the debug messages is it likely other things will be broken? ---------------------------------------------------------------------- fingar - 05-02-08 09:39 ---------------------------------------------------------------------- Ihave done some further tests. I returned bb_pwd.c to the original version & modified safe_strncpy.c to return the buffer instead of the return of strncpy. This also produced a segmentation error. So the only way I seem to get it to work is to use the original safe_strncpy.c and the modified bb_pwd.c which returns buffer instead of the return of safe_strncpy(). I guess this is looking like a toolchain problem as I can't see why the original bb_pwd.c shouldn't work. ---------------------------------------------------------------------- vda - 05-03-08 01:38 ---------------------------------------------------------------------- What are the versions of ld and gcc? Post full output of gcc -v and ld -v. ---------------------------------------------------------------------- kienvtran - 05-05-08 16:38 ---------------------------------------------------------------------- $ $CROSS_COMPILE"gcc" -v Using built-in specs. Target: arm-none-linux-gnueabi Configured with: /scratch/paul/lite/linux/src/gcc-4.2/configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --enable-shared --enable-symvers=gnu --enable-__cxa_atexit --with-pkgversion=CodeSourcery Sourcery G++ Lite 2007q3-51 --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc --with-build-sysroot=/scratch/paul/lite/linux/install/arm-none-linux-gnueabi/libc --enable-poison-system-directories --with-build-time-tools=/scratch/paul/lite/linux/install/arm-none-linux-gnueabi/bin --with-build-time-tools=/scratch/paul/lite/linux/install/arm-none-linux-gnueabi/bin Thread model: posix gcc version 4.2.1 (CodeSourcery Sourcery G++ Lite 2007q3-51) $ $CROSS_COMPILE"ld" -v GNU ld (CodeSourcery Sourcery G++ Lite 2007q3-51) 2.18.50.20070820 Issue History Date Modified Username Field Change ====================================================================== 03-06-08 02:19 fingar New Issue 03-06-08 02:19 fingar Status new => assigned 03-06-08 02:19 fingar Assigned To => BusyBox 05-01-08 09:15 kienvtran Note Added: 0007334 05-01-08 09:15 kienvtran File Added: bb_pwd.c 05-01-08 23:58 vda Note Added: 0007344 05-02-08 00:19 vda Note Added: 0007354 05-02-08 00:46 vda Note Edited: 0007354 05-02-08 05:25 fingar Note Added: 0007364 05-02-08 06:30 vda Note Added: 0007374 05-02-08 06:32 vda Note Edited: 0007374 05-02-08 07:49 kienvtran Note Added: 0007384 05-02-08 08:49 fingar Note Added: 0007394 05-02-08 09:39 fingar Note Added: 0007404 05-03-08 01:38 vda Note Added: 0007424 05-05-08 16:38 kienvtran Note Added: 0007444 ====================================================================== From bugs at busybox.net Tue May 6 03:21:14 2008 From: bugs at busybox.net (bugs at busybox.net) Date: Tue, 6 May 2008 03:21:14 -0700 Subject: [BusyBox 0002434]: Segmentation fault ls -l, ps Message-ID: <8d2314cb3fd1da59b5e40780696151c5@busybox.net> A NOTE has been added to this issue. ====================================================================== http://busybox.net/bugs/view.php?id=2434 ====================================================================== Reported By: fingar Assigned To: BusyBox ====================================================================== Project: BusyBox Issue ID: 2434 Category: Other Reproducibility: always Severity: minor Priority: normal Status: assigned ====================================================================== Date Submitted: 03-06-2008 02:19 PST Last Modified: 05-06-2008 03:21 PDT ====================================================================== Summary: Segmentation fault ls -l, ps Description: I am running Busybox 1.9.1 on Linux 2.6.21.3. I am using codesourcery compiler arm-none-linux-gnueabi and running on AT91SAM9260. When I run ls -l or ps I get segmentation fault. I have tracked the problem down to get_cached_username in libbb/procps.c but I can't get any further. I don't know if it is a problem with my /etc/passwd file or something in Busybox. Any help would be appreciated ====================================================================== ---------------------------------------------------------------------- kienvtran - 05-01-08 09:15 ---------------------------------------------------------------------- Ran into the exact same problem on the same HW/SW platform. Attached is a fix in the form of an updated libbb/bb_pwd.c source file. ---------------------------------------------------------------------- vda - 05-01-08 23:58 ---------------------------------------------------------------------- /* bb_getpwuid, bb_getgrgid: * bb_getXXXid(buf, bufsz, id) - copy user/group name or id - * as a string to buf, return user/group name or NULL - * bb_getXXXid(NULL, 0, id) - return user/group name or NULL - * bb_getXXXid(NULL, -1, id) - return user/group name or exit + * as a string to buf, return user/group name + * bb_getXXXid(NULL, 0, id) - illegal + * bb_getXXXid(NULL, -1, id) - illegal */ id is broken now - coreutils/id.c: puts((flags & JUST_USER) ? bb_getpwuid(NULL, -1, uid) : bb_getgrgid(NULL, -1, gid)); It would be better if instead of half-baked dirty fix you'd actually debugged the crash. ---------------------------------------------------------------------- vda - 05-02-08 00:46 ---------------------------------------------------------------------- To debug it: bb_pwd.c: static char* bb_getug(char *buffer, int bufsize, char *idname, long id, char prefix) { if (bufsize > 0) { bb_error_msg("HERE1"); assert(buffer != NULL); if (idname) { bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); } bb_error_msg("HERE3"); snprintf(buffer, bufsize, "%ld", id); } else if (bufsize < 0 && !idname) { bb_error_msg("HERE4"); bb_error_msg_and_die("unknown %cid %ld", prefix, id); } bb_error_msg("HERE5: return '%s'", idname); return idname; } Recompile, let it crash, and show the output. ---------------------------------------------------------------------- fingar - 05-02-08 05:25 ---------------------------------------------------------------------- result of debug # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 Segmentation fault # ---------------------------------------------------------------------- vda - 05-02-08 06:32 ---------------------------------------------------------------------- Wow... can you replace lines bb_error_msg("HERE2"); return safe_strncpy(buffer, idname, bufsize); with bb_error_msg("HERE2 buffer:%p idname:%p bufsize:%d", buffer, idname, bufsize); bb_error_msg("HERE21 buffer:'%s'", buffer); bb_error_msg("HERE22 idname:'%s'", idname); safe_strncpy(buffer, idname, bufsize); bb_error_msg("HERE23 returning '%s'", buffer); return buffer; ---------------------------------------------------------------------- kienvtran - 05-02-08 07:49 ---------------------------------------------------------------------- When I inserted debug statements like vda suggested, without modifying the code, the bug DISAPPEARED. In that case the outputs of "ls -l" and "ps" were useless, as they were interspersed with debug statements. Are there regression tests that I could run to ensure that I don't break anything else? Sorry about "id" breaking, I am kind of new at this. ---------------------------------------------------------------------- fingar - 05-02-08 08:49 ---------------------------------------------------------------------- replaced the code with the extra debug messages as vda suggested. output is now # ps PID Uid VSZ Stat Command ps: HERE1 ps: HERE2 buffer:0x944a4 idname 0x94510 bufsize 12 ps: HERE21 buffer:'' ps: HERE22 idname:'root' ps: HERE23 returning 'root' 1 root 3000 S init 2 root SWN [ksoftirqd/0] 3 root SW< [events/0] 4 root SW< [khelper] 5 root SW< [kthread] 40 root SW< [kblockd/0] 44 root SW< [khubd] 46 root SW< [kseriod] 59 root SW [pdflush] 60 root SW [pdflush] 61 root SW< [kswapd0] 62 root SW< [aio/0] 64 root SW< [jfsIO] 65 root SW< [jfsCommit] 66 root SW< [jfsSync] 675 root SW [mtdblockd] 712 root SWN [jffs2_gcd_mtd1] 720 root 3004 S /sbin/syslogd -O /var/log/messages 722 root 3004 S /sbin/klogd 728 root 3008 S /bin/sh 733 root 3008 R ps # It works now. Is this a toolchain problem. If I remove the debug messages is it likely other things will be broken? ---------------------------------------------------------------------- fingar - 05-02-08 09:39 ---------------------------------------------------------------------- Ihave done some further tests. I returned bb_pwd.c to the original version & modified safe_strncpy.c to return the buffer instead of the return of strncpy. This also produced a segmentation error. So the only way I seem to get it to work is to use the original safe_strncpy.c and the modified bb_pwd.c which returns buffer instead of the return of safe_strncpy(). I guess this is looking like a toolchain problem as I can't see why the original bb_pwd.c shouldn't work. ---------------------------------------------------------------------- vda - 05-03-08 01:38 ---------------------------------------------------------------------- What are the versions of ld and gcc? Post full output of gcc -v and ld -v. ---------------------------------------------------------------------- kienvtran - 05-05-08 16:38 ---------------------------------------------------------------------- $ $CROSS_COMPILE"gcc" -v Using built-in specs. Target: arm-none-linux-gnueabi Configured with: /scra