From vda at busybox.net Fri Nov 2 16:31:11 2007
From: vda at busybox.net (vda at busybox.net)
Date: Fri, 2 Nov 2007 16:31:11 -0700 (PDT)
Subject: svn commit: trunk/busybox: libbb modutils
Message-ID: <20071102233111.55E85A6AB6@busybox.net>
Author: vda
Date: 2007-11-02 16:31:10 -0700 (Fri, 02 Nov 2007)
New Revision: 20354
Log:
insmod: code shrink, stop exporting insmod_ng_main.
function old new delta
add_ksymoops_symbols - 421 +421
static.section_names 20 40 +20
lsmod_main 425 424 -1
set_tainted 153 150 -3
main_opts 4 - -4
obj_symbol_patch 47 42 -5
obj_string_patch 144 139 -5
already_loaded 144 138 -6
check_dep 348 341 -7
append_option 75 68 -7
obj_allocate_commons 515 501 -14
new_process_module_arguments 1039 1018 -21
arch_new_symbol 31 9 -22
check_module_name_match 85 61 -24
obj_create_alloced_section 164 136 -28
include_conf 930 902 -28
modprobe_main 1643 1535 -108
obj_load 924 777 -147
insmod_ng_main 245 - -245
insmod_main 4122 3794 -328
------------------------------------------------------------------------------
(add/remove: 1/2 grow/shrink: 1/16 up/down: 441/-1003) Total: -562 bytes
text data bss dec hex filename
776020 974 9420 786414 bffee busybox_old
775384 974 9420 785778 bfd72 busybox_unstripped
Modified:
trunk/busybox/libbb/xreadlink.c
trunk/busybox/modutils/insmod.c
trunk/busybox/modutils/lsmod.c
trunk/busybox/modutils/modprobe.c
Changeset:
Sorry, the patch is too large to include (1586 lines).
Please use ViewCVS to see it!
http://busybox.net/cgi-bin/viewcvs.cgi?view=rev&root=svn&rev=20354
From vda at busybox.net Sat Nov 3 16:17:41 2007
From: vda at busybox.net (vda at busybox.net)
Date: Sat, 3 Nov 2007 16:17:41 -0700 (PDT)
Subject: svn commit: branches/busybox_1_7_stable: coreutils include networking
networking etc...
Message-ID: <20071103231741.93754A65E9@busybox.net>
Author: vda
Date: 2007-11-03 16:17:40 -0700 (Sat, 03 Nov 2007)
New Revision: 20356
Log:
apply accumulated post 1.7.2 patches; bump version to 1.7.3
Modified:
branches/busybox_1_7_stable/Makefile
branches/busybox_1_7_stable/coreutils/tail.c
branches/busybox_1_7_stable/include/libbb.h
branches/busybox_1_7_stable/networking/httpd.c
branches/busybox_1_7_stable/networking/inetd.c
branches/busybox_1_7_stable/networking/libiproute/iptunnel.c
branches/busybox_1_7_stable/shell/ash.c
branches/busybox_1_7_stable/sysklogd/logger.c
Changeset:
Modified: branches/busybox_1_7_stable/Makefile
===================================================================
--- branches/busybox_1_7_stable/Makefile 2007-11-03 07:23:18 UTC (rev 20355)
+++ branches/busybox_1_7_stable/Makefile 2007-11-03 23:17:40 UTC (rev 20356)
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 7
-SUBLEVEL = 2
+SUBLEVEL = 3
EXTRAVERSION =
NAME = Unnamed
Modified: branches/busybox_1_7_stable/coreutils/tail.c
===================================================================
--- branches/busybox_1_7_stable/coreutils/tail.c 2007-11-03 07:23:18 UTC (rev 20355)
+++ branches/busybox_1_7_stable/coreutils/tail.c 2007-11-03 23:17:40 UTC (rev 20356)
@@ -47,13 +47,16 @@
static ssize_t tail_read(int fd, char *buf, size_t count)
{
ssize_t r;
- off_t current, end;
+ off_t current;
struct stat sbuf;
- end = current = lseek(fd, 0, SEEK_CUR);
- if (!fstat(fd, &sbuf))
- end = sbuf.st_size;
- lseek(fd, end < current ? 0 : current, SEEK_SET);
+ /* (A good comment is missing here) */
+ current = lseek(fd, 0, SEEK_CUR);
+ /* /proc files report zero st_size, don't lseek them. */
+ if (fstat(fd, &sbuf) == 0 && sbuf.st_size)
+ if (sbuf.st_size < current)
+ lseek(fd, 0, SEEK_SET);
+
r = safe_read(fd, buf, count);
if (r < 0) {
bb_perror_msg(bb_msg_read_error);
@@ -67,8 +70,12 @@
static unsigned eat_num(const char *p)
{
- if (*p == '-') p++;
- else if (*p == '+') { p++; G.status = EXIT_FAILURE; }
+ if (*p == '-')
+ p++;
+ else if (*p == '+') {
+ p++;
+ G.status = EXIT_FAILURE;
+ }
return xatou_sfx(p, tail_suffixes);
}
Modified: branches/busybox_1_7_stable/include/libbb.h
===================================================================
--- branches/busybox_1_7_stable/include/libbb.h 2007-11-03 07:23:18 UTC (rev 20355)
+++ branches/busybox_1_7_stable/include/libbb.h 2007-11-03 23:17:40 UTC (rev 20356)
@@ -776,7 +776,7 @@
extern void bb_do_delay(int seconds);
extern void change_identity(const struct passwd *pw);
extern const char *change_identity_e2str(const struct passwd *pw);
-extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args);
+extern void run_shell(const char *shell, int loginshell, const char *command, const char **additional_args) ATTRIBUTE_NORETURN;
#if ENABLE_SELINUX
extern void renew_current_security_context(void);
extern void set_current_security_context(security_context_t sid);
Modified: branches/busybox_1_7_stable/networking/httpd.c
===================================================================
--- branches/busybox_1_7_stable/networking/httpd.c 2007-11-03 07:23:18 UTC (rev 20355)
+++ branches/busybox_1_7_stable/networking/httpd.c 2007-11-03 23:17:40 UTC (rev 20356)
@@ -1186,6 +1186,9 @@
* and send it to the peer. So please no SIGPIPEs! */
signal(SIGPIPE, SIG_IGN);
+ /* Accound for POSTDATA already in hdr_buf */
+ bodyLen -= hdr_cnt;
+
/* This loop still looks messy. What is an exit criteria?
* "CGI's output closed"? Or "CGI has exited"?
* What to do if CGI has closed both input and output, but
Modified: branches/busybox_1_7_stable/networking/inetd.c
===================================================================
--- branches/busybox_1_7_stable/networking/inetd.c 2007-11-03 07:23:18 UTC (rev 20355)
+++ branches/busybox_1_7_stable/networking/inetd.c 2007-11-03 23:17:40 UTC (rev 20356)
@@ -734,7 +734,8 @@
/* if ((arg = skip(&cp, 1)) == NULL) */
/* goto more; */
- sep->se_server = xxstrdup(skip(&cp));
+ arg = skip(&cp);
+ sep->se_server = xxstrdup(arg);
if (strcmp(sep->se_server, "internal") == 0) {
#ifdef INETD_FEATURE_ENABLED
const struct builtin *bi;
@@ -759,7 +760,7 @@
sep->se_bi = NULL;
#endif
argc = 0;
- for (arg = skip(&cp); cp; arg = skip(&cp)) {
+ for (; cp; arg = skip(&cp)) {
if (argc < MAXARGV)
sep->se_argv[argc++] = xxstrdup(arg);
}
Modified: branches/busybox_1_7_stable/networking/libiproute/iptunnel.c
===================================================================
--- branches/busybox_1_7_stable/networking/libiproute/iptunnel.c 2007-11-03 07:23:18 UTC (rev 20355)
+++ branches/busybox_1_7_stable/networking/libiproute/iptunnel.c 2007-11-03 23:17:40 UTC (rev 20356)
@@ -241,12 +241,12 @@
} else if (key == ARG_remote) {
NEXT_ARG();
key = index_in_strings(keywords, *argv);
- if (key == ARG_any)
+ if (key != ARG_any)
p->iph.daddr = get_addr32(*argv);
} else if (key == ARG_local) {
NEXT_ARG();
key = index_in_strings(keywords, *argv);
- if (key == ARG_any)
+ if (key != ARG_any)
p->iph.saddr = get_addr32(*argv);
} else if (key == ARG_dev) {
NEXT_ARG();
Modified: branches/busybox_1_7_stable/shell/ash.c
===================================================================
--- branches/busybox_1_7_stable/shell/ash.c 2007-11-03 07:23:18 UTC (rev 20355)
+++ branches/busybox_1_7_stable/shell/ash.c 2007-11-03 23:17:40 UTC (rev 20356)
@@ -4379,6 +4379,7 @@
/* Lives far away from here, needed for forkchild */
static void closescript(void);
+
/* Called after fork(), in child */
static void
forkchild(struct job *jp, union node *n, int mode)
@@ -4423,15 +4424,8 @@
setsignal(SIGQUIT);
setsignal(SIGTERM);
}
-#if JOBS
- /* For "jobs | cat" to work like in bash, we must retain list of jobs
- * in child, but we do need to remove ourself */
- if (jp)
- freejob(jp);
-#else
for (jp = curjob; jp; jp = jp->prev_job)
freejob(jp);
-#endif
jobless = 0;
}
Modified: branches/busybox_1_7_stable/sysklogd/logger.c
===================================================================
--- branches/busybox_1_7_stable/sysklogd/logger.c 2007-11-03 07:23:18 UTC (rev 20355)
+++ branches/busybox_1_7_stable/sysklogd/logger.c 2007-11-03 23:17:40 UTC (rev 20356)
@@ -107,7 +107,7 @@
argv += optind;
if (!argc) {
#define strbuf bb_common_bufsiz1
- while (fgets(strbuf, BUFSIZ, stdin)) {
+ while (fgets(strbuf, COMMON_BUFSIZE, stdin)) {
if (strbuf[0]
&& NOT_LONE_CHAR(strbuf, '\n')
) {
@@ -117,11 +117,11 @@
}
} else {
char *message = NULL;
- int len = 1; /* for NUL */
+ int len = 0;
int pos = 0;
do {
len += strlen(*argv) + 1;
- message = xrealloc(message, len);
+ message = xrealloc(message, len + 1);
sprintf(message + pos, " %s", *argv),
pos = len;
} while (*++argv);
From vda at busybox.net Sat Nov 3 16:18:26 2007
From: vda at busybox.net (vda at busybox.net)
Date: Sat, 3 Nov 2007 16:18:26 -0700 (PDT)
Subject: svn commit: tags
Message-ID: <20071103231826.8D0A4A614E@busybox.net>
Author: vda
Date: 2007-11-03 16:18:26 -0700 (Sat, 03 Nov 2007)
New Revision: 20357
Log:
create tags/busybox_1_7_3
Added:
tags/busybox_1_7_3/
Changeset:
Copied: tags/busybox_1_7_3 (from rev 20356, branches/busybox_1_7_stable)
From vda at busybox.net Sat Nov 3 17:46:03 2007
From: vda at busybox.net (vda at busybox.net)
Date: Sat, 3 Nov 2007 17:46:03 -0700 (PDT)
Subject: svn commit: trunk/busybox/findutils
Message-ID: <20071104004603.E97DBA6885@busybox.net>
Author: vda
Date: 2007-11-03 17:46:03 -0700 (Sat, 03 Nov 2007)
New Revision: 20358
Log:
grep: fix -Fo
Modified:
trunk/busybox/findutils/grep.c
Changeset:
Modified: trunk/busybox/findutils/grep.c
===================================================================
--- trunk/busybox/findutils/grep.c 2007-11-03 23:18:26 UTC (rev 20357)
+++ trunk/busybox/findutils/grep.c 2007-11-04 00:46:03 UTC (rev 20358)
@@ -174,7 +174,7 @@
while ((line = xmalloc_getline(file)) != NULL) {
llist_t *pattern_ptr = pattern_head;
- grep_list_data_t *gl;
+ grep_list_data_t *gl = gl; /* for gcc */
linenum++;
found = 0;
@@ -274,8 +274,15 @@
print_n_lines_after = lines_after;
#endif
if (option_mask32 & OPT_o) {
- line[regmatch.rm_eo] = '\0';
- print_line(line + regmatch.rm_so, linenum, ':');
+ if (FGREP_FLAG) {
+ /* -Fo just prints the pattern
+ * (unless -v: -Fov doesnt print anything at all) */
+ if (found)
+ print_line(gl->pattern, linenum, ':');
+ } else {
+ line[regmatch.rm_eo] = '\0';
+ print_line(line + regmatch.rm_so, linenum, ':');
+ }
} else {
print_line(line, linenum, ':');
}
From vda at busybox.net Sat Nov 3 21:10:18 2007
From: vda at busybox.net (vda at busybox.net)
Date: Sat, 3 Nov 2007 21:10:18 -0700 (PDT)
Subject: svn commit: trunk/busybox: include libbb miscutils networking
Message-ID: <20071104041018.7CCB1A6811@busybox.net>
Author: vda
Date: 2007-11-03 21:10:17 -0700 (Sat, 03 Nov 2007)
New Revision: 20359
Log:
ifconfig: code shrink
adjtimex: code shrink
libbb: move nth_string function into libbb
hdparm: nth_string was here
text data bss dec hex filename
730013 10334 12032 752379 b7afb busybox_old
730093 10134 12032 752259 b7a83 busybox_unstripped
Modified:
trunk/busybox/include/libbb.h
trunk/busybox/libbb/compare_string_array.c
trunk/busybox/miscutils/adjtimex.c
trunk/busybox/miscutils/hdparm.c
trunk/busybox/networking/ifconfig.c
Changeset:
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h 2007-11-04 00:46:03 UTC (rev 20358)
+++ trunk/busybox/include/libbb.h 2007-11-04 04:10:17 UTC (rev 20359)
@@ -846,10 +846,13 @@
/* Returns a ptr to static storage */
extern char *pw_encrypt(const char *clear, const char *salt);
extern int obscure(const char *old, const char *newval, const struct passwd *pwdp);
-extern int index_in_str_array(const char *const string_array[], const char *key);
-extern int index_in_strings(const char *strings, const char *key);
-extern int index_in_substr_array(const char *const string_array[], const char *key);
-extern int index_in_substrings(const char *strings, const char *key);
+
+int index_in_str_array(const char *const string_array[], const char *key);
+int index_in_strings(const char *strings, const char *key);
+int index_in_substr_array(const char *const string_array[], const char *key);
+int index_in_substrings(const char *strings, const char *key);
+const char *nth_string(const char *strings, int n);
+
extern void print_login_issue(const char *issue_file, const char *tty);
extern void print_login_prompt(void);
Modified: trunk/busybox/libbb/compare_string_array.c
===================================================================
--- trunk/busybox/libbb/compare_string_array.c 2007-11-04 00:46:03 UTC (rev 20358)
+++ trunk/busybox/libbb/compare_string_array.c 2007-11-04 04:10:17 UTC (rev 20359)
@@ -67,3 +67,12 @@
}
return -1;
}
+
+const char *nth_string(const char *strings, int n)
+{
+ while (n) {
+ n--;
+ strings += strlen(strings) + 1;
+ }
+ return strings;
+}
Modified: trunk/busybox/miscutils/adjtimex.c
===================================================================
--- trunk/busybox/miscutils/adjtimex.c 2007-11-04 00:46:03 UTC (rev 20358)
+++ trunk/busybox/miscutils/adjtimex.c 2007-11-04 04:10:17 UTC (rev 20359)
@@ -14,34 +14,46 @@
#include "libbb.h"
#include BusyBox 1.7.3.
+ (svn,
+ patches,
+ how to add a patch) This is a bugfix-only release, with fixes to ash, httpd, inetd, iptun, logger, login, tail. BusyBox 1.7.2.
(svn,
@@ -8,7 +18,6 @@
how to add a patch) This is a bugfix-only release, with fixes to install, find, login, httpd, runsvdir, chcon, setfiles, fdisk and line editing. BusyBox 1.8.0.
+ (svn,
+ patches,
+ how to add a patch) Note: this is probably the very last release with lash. It will be dropped. Please migrate to hush.
+
+ Applets which had many changes since 1.7.x:
+ httpd:
+ top:
+ Build system improvements: libbusybox mode restored (it was lost in transition to new makefiles).
+
+ Code and data size in comparison with 1.7.3: New applets:
+ Other changes since previous release (abridged):
+
+
+
+
+
+
+
+
+
+Equivalent .config, i386 uclibc static builds:
+ text data bss dec hex filename
+ 768123 1055 10768 779946 be6aa busybox-1.7.3/busybox
+ 759693 974 9420 770087 bc027 busybox-1.8.0/busybox
+
+
+
+
+
+
+
How to build static busybox against uclibc
+ +BusyBox 1.7.3. (svn, @@ -8,7 +118,6 @@ how to add a patch)
This is a bugfix-only release, with fixes to ash, httpd, inetd, iptun, logger, login, tail.
-
-$ ./busybox
-BusyBox v1.6.0.svn (2007-04-07 04:27:00 CEST) multi-call binary
+$ busybox
+BusyBox v1.8.0 (2007-11-04 15:42:38 GMT) multi-call binary
+Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.
+Licensed under GPLv2. See source distribution for full notice.
Usage: busybox [function] [arguments]...
or: [function] [arguments]...
@@ -24,39 +26,38 @@
Currently defined functions:
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
- awk, basename, bunzip2, bzcat, cal, cat, catv, chattr,
- chgrp, chmod, chown, chpst, chroot, chvt, cksum, clear,
- cmp, comm, cp, cpio, crond, crontab, cut, date, dc, dd,
- deallocvt, delgroup, deluser, df, dhcprelay, diff, dirname,
- dmesg, dnsd, dos2unix, dpkg, dpkg-deb, du, dumpkmap, dumpleases,
- echo, ed, egrep, eject, env, envdir, envuidgid, expr,
- fakeidentd, false, fbset, fdflush, fdformat, fdisk, fgrep,
- find, fold, free, freeramdisk, fsck, fsck.minix, ftpget,
- ftpput, fuser, getopt, getty, grep, gunzip, gzip, halt,
- hdparm, head, hexdump, hostid, hostname, httpd, hwclock,
- id, ifconfig, ifdown, ifup, inetd, init, insmod, install,
- ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule,
- iptunnel, kill, killall, killall5, klogd, lash, last,
- length, less, linux32, linux64, linuxrc, ln, loadfont,
- loadkmap, logger, login, logname, logread, losetup, ls,
- lsattr, lsmod, lzmacat, makedevs, md5sum, mdev, mesg,
- mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, modprobe,
- more, mount, mountpoint, msh, mt, mv, nameif, nc, netstat,
- nice, nmeter, nohup, nslookup, od, openvt, passwd, patch,
- pidof, ping, ping6, pipe_progress, pivot_root, poweroff,
- printenv, printf, ps, pwd, raidautorun, rdate, readahead,
- readlink, readprofile, realpath, reboot, renice, reset,
- resize, rm, rmdir, rmmod, route, rpm, rpm2cpio, run-parts,
- runlevel, runsv, runsvdir, rx, sed, seq, setarch, setconsole,
- setkeycodes, setlogcons, setsid, setuidgid, sha1sum, sleep,
- softlimit, sort, split, start-stop-daemon, stat, strings,
- stty, su, sulogin, sum, sv, svlogd, swapoff, swapon, switch_root,
- sync, sysctl, syslogd, tail, tar, tcpsvd, tee, telnet,
- telnetd, test, tftp, time, top, touch, traceroute, true,
- tty, udhcpc, udhcpd, udpsvd, umount, uname, uncompress,
- uniq, unix2dos, unlzma, unzip, uptime, usleep, uudecode,
- uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget,
- which, who, whoami, xargs, yes, zcat, zcip
+ awk, basename, bunzip2, bzcat, bzip2, cal, cat, catv, chattr,
+ chgrp, chmod, chown, chpasswd, chpst, chroot, chrt, chvt,
+ cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw,
+ cut, date, dc, dd, deallocvt, delgroup, deluser, df, dhcprelay,
+ diff, dirname, dmesg, dnsd, dos2unix, dpkg, du, dumpkmap,
+ dumpleases, echo, ed, egrep, eject, env, envdir, envuidgid,
+ expand, expr, fakeidentd, false, fbset, fdflush, fdformat,
+ fdisk, fgrep, find, fold, free, freeramdisk, fsck, fsck.minix,
+ ftpget, ftpput, fuser, getopt, getty, grep, gunzip, gzip,
+ hdparm, head, hexdump, hostid, hostname, httpd, hush, hwclock,
+ id, ifconfig, inetd, insmod, install, ip, ipaddr, ipcalc,
+ ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode,
+ kill, killall, killall5, klogd, lash, last, length, less,
+ linux32, linux64, ln, loadfont, loadkmap, logger, login, logname,
+ logread, losetup, ls, lsattr, lsmod, lzmacat, md5sum, mdev,
+ mesg, microcom, mkdir, mkfifo, mkfs.minix, mknod, mkswap,
+ mktemp, modprobe, more, mount, mountpoint, msh, mt, mv, nameif,
+ nc, netstat, nice, nmeter, nohup, nslookup, od, openvt, passwd,
+ patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root,
+ pkill, printenv, printf, ps, pscan, pwd, raidautorun, rdate,
+ readlink, readprofile, realpath, renice, reset, resize, rm,
+ rmdir, rmmod, route, rpm, rpm2cpio, run-parts, runlevel, runsv,
+ runsvdir, rx, sed, seq, setarch, setconsole, setkeycodes,
+ setlogcons, setsid, setuidgid, sha1sum, slattach, sleep, softlimit,
+ sort, split, start-stop-daemon, stat, strings, stty, su, sulogin,
+ sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl,
+ syslogd, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp,
+ time, top, touch, tr, traceroute, true, tty, ttysize, udhcpc,
+ udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq,
+ unix2dos, unlzma, unzip, uptime, usleep, uudecode, uuencode,
+ vconfig, vi, vlock, watch, watchdog, wc, wget, which, who,
+ whoami, xargs, yes, zcat, zcip
$ _
From bugs at busybox.net Sun Nov 4 17:38:07 2007
From: bugs at busybox.net (bugs at busybox.net)
Date: Sun, 4 Nov 2007 17:38:07 -0800
Subject: [BusyBox 0001555]: ash shell functionality lack
Message-ID: <1a0771ce75be760b307a356d9894c18c@bugs.busybox.net>
A NOTE has been added to this issue.
======================================================================
http://busybox.net/bugs/view.php?id=1555
======================================================================
Reported By: alexsv
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1555
Category: Standards Compliance
Reproducibility: always
Severity: major
Priority: normal
Status: assigned
======================================================================
Date Submitted: 10-24-2007 14:55 PDT
Last Modified: 11-04-2007 17:38 PST
======================================================================
Summary: ash shell functionality lack
Description:
ash shell from busybox 1.7.2 does not support the following constructions:
CR=$'\r'
for example the following script
----cut----
#!/bin/sh
CR=$'\r'
echo $CR
----cut----
will produce string "$\r" on display
that's violation of standard (citation from man page
http://www.gnu.org/software/bash/manual/bashref.html):
==========================
3.1.2.4 ANSI-C Quoting
Words of the form $'string' are treated specially. The word expands to
string, with backslash-escaped characters replaced as specified by the
ANSI C standard. Backslash escape sequences, if present, are decoded as
follows:
\a
alert (bell)
\b
backspace
\e
an escape character (not ANSI C)
\f
form feed
\n
newline
\r
carriage return
\t
horizontal tab
\v
vertical tab
\\
backslash
\'
single quote
\nnn
the eight-bit character whose value is the octal value nnn (one to
three digits)
\xHH
the eight-bit character whose value is the hexadecimal value HH (one
or two hex digits)
\cx
a control-x character
The expanded result is single-quoted, as if the dollar sign had not been
present.
==========================
======================================================================
----------------------------------------------------------------------
pipatron - 11-04-07 17:38
----------------------------------------------------------------------
This sounds like a bashism. The relevant documentation for shell standards
should be this:
http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
Issue History
Date Modified Username Field Change
======================================================================
10-24-07 14:55 alexsv New Issue
10-24-07 14:55 alexsv Status new => assigned
10-24-07 14:55 alexsv Assigned To => BusyBox
11-04-07 17:38 pipatron Note Added: 0002889
======================================================================
From bugs at busybox.net Mon Nov 5 07:53:42 2007
From: bugs at busybox.net (bugs at busybox.net)
Date: Mon, 5 Nov 2007 07:53:42 -0800
Subject: [BusyBox 0001575]: Newer unzip.c doesn't compile with
arm-linux-gnu-gcc, bad header structure size.
Message-ID:
The following issue has been SUBMITTED.
======================================================================
http://busybox.net/bugs/view.php?id=1575
======================================================================
Reported By: dserpell
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1575
Category: Other
Reproducibility: always
Severity: major
Priority: normal
Status: assigned
======================================================================
Date Submitted: 11-05-2007 07:53 PST
Last Modified: 11-05-2007 07:53 PST
======================================================================
Summary: Newer unzip.c doesn't compile with
arm-linux-gnu-gcc, bad header structure size.
Description:
Compiling using arm-linux-gnu-gcc, (Debian etch version):
-----------------------------------------------------------
CC archival/unzip.o
archival/unzip.c:61: error: size of array
?BUG_zip_header_must_be_26_bytes? is negative
make[1]: *** [archival/unzip.o] Error 1
-----------------------------------------------------------
In fact, the structure size is 28 bytes.
Gcc is:
-----------------------------------------------------------
arm-linux-gnu-gcc -v
Using built-in specs.
Target: arm-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++
--prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/arm-linux-gnu/include/c++/4.1.2
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-checking=release
--program-prefix=arm-linux-gnu- --includedir=/usr/arm-linux-gnu/include
--build=i486-linux-gnu --host=i486-linux-gnu --target=arm-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
-----------------------------------------------------------
I created a small test sample (attached), running it gives:
-----------------------------------------------------------
Size: 28
Fields:
version: 0 (0)
flags: 2 (2)
method: 4 (4)
modtime: 6 (6)
moddate: 8 (8)
crc32: 10 (10)
cmpsize: 14 (14)
ucmpsize: 18 (18)
filename_len: 22 (22)
extra_len: 24 (24)
-----------------------------------------------------------
This means that only the structure size is incorrect.
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
11-05-07 07:53 dserpell New Issue
11-05-07 07:53 dserpell Status new => assigned
11-05-07 07:53 dserpell Assigned To => BusyBox
11-05-07 07:53 dserpell File Added: testStruct.c
======================================================================
From vda at busybox.net Mon Nov 5 08:26:34 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 08:26:34 -0800 (PST)
Subject: svn commit: trunk/busybox: docs/busybox.net
Message-ID: <20071105162634.CE7E4A65AA@busybox.net>
Author: vda
Date: 2007-11-05 08:26:34 -0800 (Mon, 05 Nov 2007)
New Revision: 20366
Log:
webpage: fix typo, remove inconsistent trailing dots
Makefile: version is 1.9.0.svn now
Modified:
trunk/busybox/Makefile
trunk/busybox/docs/busybox.net/news.html
Changeset:
Modified: trunk/busybox/Makefile
===================================================================
--- trunk/busybox/Makefile 2007-11-04 15:57:35 UTC (rev 20365)
+++ trunk/busybox/Makefile 2007-11-05 16:26:34 UTC (rev 20366)
@@ -1,7 +1,7 @@
VERSION = 1
-PATCHLEVEL = 8
+PATCHLEVEL = 9
SUBLEVEL = 0
-EXTRAVERSION =
+EXTRAVERSION = .svn
NAME = Unnamed
# *DOCUMENTATION*
Modified: trunk/busybox/docs/busybox.net/news.html
===================================================================
--- trunk/busybox/docs/busybox.net/news.html 2007-11-04 15:57:35 UTC (rev 20365)
+++ trunk/busybox/docs/busybox.net/news.html 2007-11-05 16:26:34 UTC (rev 20366)
@@ -53,8 +53,8 @@
hdparm: reduce possibility of numeric overflow in -T
hdparm: simplify timing measurement
wget: -O FILE is allowed to overwrite existing file (compat)
- wget: allow dots in header field names.
- telnetd: add -K option to close sessions as soon as child exits.
+ wget: allow dots in header field names
+ telnetd: add -K option to close sessions as soon as child exits
telnetd: don't SIGKILL child when closing the session, kernel will send SIGHUP for us
ed: large cleanup, add line editing
hush: feeble attempt at making it more NOMMU-friendly
@@ -93,7 +93,7 @@
runsv: do not use clock_gettime if !MONOTONIC_CLOCK
runsvdir: fix "linear wait time" bug
sulogin: remove alarm handling, it is redundant there
- svlogd: compat: svlogd -tt should timestanp stderr too
+ svlogd: compat: svlogd -tt should timestamp stderr too
syslogd: bail out if you see null read from Unix socket
syslogd: do not need to poll(), we can just block in read()
tail: work correctly on /proc files (Kazuo TAKADA <kztakada at sm.sony.co.jp>)
From bugs at busybox.net Mon Nov 5 10:52:00 2007
From: bugs at busybox.net (bugs at busybox.net)
Date: Mon, 5 Nov 2007 10:52:00 -0800
Subject: [BusyBox 0001575]: Newer unzip.c doesn't compile with
arm-linux-gnu-gcc, bad header structure size.
Message-ID:
A NOTE has been added to this issue.
======================================================================
http://busybox.net/bugs/view.php?id=1575
======================================================================
Reported By: dserpell
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1575
Category: Other
Reproducibility: always
Severity: major
Priority: normal
Status: assigned
======================================================================
Date Submitted: 11-05-2007 07:53 PST
Last Modified: 11-05-2007 10:51 PST
======================================================================
Summary: Newer unzip.c doesn't compile with
arm-linux-gnu-gcc, bad header structure size.
Description:
Compiling using arm-linux-gnu-gcc, (Debian etch version):
-----------------------------------------------------------
CC archival/unzip.o
archival/unzip.c:61: error: size of array
?BUG_zip_header_must_be_26_bytes? is negative
make[1]: *** [archival/unzip.o] Error 1
-----------------------------------------------------------
In fact, the structure size is 28 bytes.
Gcc is:
-----------------------------------------------------------
arm-linux-gnu-gcc -v
Using built-in specs.
Target: arm-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++
--prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/arm-linux-gnu/include/c++/4.1.2
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-checking=release
--program-prefix=arm-linux-gnu- --includedir=/usr/arm-linux-gnu/include
--build=i486-linux-gnu --host=i486-linux-gnu --target=arm-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
-----------------------------------------------------------
I created a small test sample (attached), running it gives:
-----------------------------------------------------------
Size: 28
Fields:
version: 0 (0)
flags: 2 (2)
method: 4 (4)
modtime: 6 (6)
moddate: 8 (8)
crc32: 10 (10)
cmpsize: 14 (14)
ucmpsize: 18 (18)
filename_len: 22 (22)
extra_len: 24 (24)
-----------------------------------------------------------
This means that only the structure size is incorrect.
======================================================================
----------------------------------------------------------------------
dserpell - 11-05-07 10:51
----------------------------------------------------------------------
I added a patch fixing compilation of unzip.c. I tested the resulting
binary on the target, unzipping some files, and it works.
Issue History
Date Modified Username Field Change
======================================================================
11-05-07 07:53 dserpell New Issue
11-05-07 07:53 dserpell Status new => assigned
11-05-07 07:53 dserpell Assigned To => BusyBox
11-05-07 07:53 dserpell File Added: testStruct.c
11-05-07 10:50 dserpell File Added: busybox-unzip.patch
11-05-07 10:51 dserpell Note Added: 0002890
======================================================================
From vda at busybox.net Mon Nov 5 11:31:01 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 11:31:01 -0800 (PST)
Subject: svn commit: trunk/busybox/applets
Message-ID: <20071105193101.12191A65AA@busybox.net>
Author: vda
Date: 2007-11-05 11:31:01 -0800 (Mon, 05 Nov 2007)
New Revision: 20367
Log:
fix incorrect text of link-time error message. No code changes
Modified:
trunk/busybox/applets/applets.c
Changeset:
Modified: trunk/busybox/applets/applets.c
===================================================================
--- trunk/busybox/applets/applets.c 2007-11-05 16:26:34 UTC (rev 20366)
+++ trunk/busybox/applets/applets.c 2007-11-05 19:31:01 UTC (rev 20367)
@@ -17,7 +17,7 @@
#warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
#warning Note that glibc is unsuitable for static linking anyway.
#warning If you still want to do it, remove -Wl,--gc-sections
-#warning from top-level Makefile and remove this warning.
+#warning from scripts/trylink and remove this warning.
#error Aborting compilation.
#endif
From vda at busybox.net Mon Nov 5 11:33:38 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 11:33:38 -0800 (PST)
Subject: svn commit: trunk/busybox/util-linux
Message-ID: <20071105193338.74749A6079@busybox.net>
Author: vda
Date: 2007-11-05 11:33:38 -0800 (Mon, 05 Nov 2007)
New Revision: 20368
Log:
swaponoff: prevent arithmetic overflow (spotted by Paul Fox )
Modified:
trunk/busybox/util-linux/swaponoff.c
Changeset:
Modified: trunk/busybox/util-linux/swaponoff.c
===================================================================
--- trunk/busybox/util-linux/swaponoff.c 2007-11-05 19:31:01 UTC (rev 20367)
+++ trunk/busybox/util-linux/swaponoff.c 2007-11-05 19:33:38 UTC (rev 20368)
@@ -21,7 +21,7 @@
#if ENABLE_DESKTOP
/* test for holes */
if (S_ISREG(st.st_mode))
- if (st.st_blocks * 512 < st.st_size)
+ if (st.st_blocks * (off_t)512 < st.st_size)
bb_error_msg("warning: swap file has holes");
#endif
From pgf at busybox.net Mon Nov 5 15:09:04 2007
From: pgf at busybox.net (pgf at busybox.net)
Date: Mon, 5 Nov 2007 15:09:04 -0800 (PST)
Subject: svn commit: trunk/busybox/archival
Message-ID: <20071105230904.B6E97A610A@busybox.net>
Author: pgf
Date: 2007-11-05 15:09:03 -0800 (Mon, 05 Nov 2007)
New Revision: 20369
Log:
change safety check on zip header to allow for extra length, and
revert the header read to use the correct constant rather than
sizeof. at least one version of gcc (armv4-linux-gcc-3.4.1) pads
the struct to 28 bytes in spite of the packing.
Modified:
trunk/busybox/archival/unzip.c
Changeset:
Modified: trunk/busybox/archival/unzip.c
===================================================================
--- trunk/busybox/archival/unzip.c 2007-11-05 19:33:38 UTC (rev 20368)
+++ trunk/busybox/archival/unzip.c 2007-11-05 23:09:03 UTC (rev 20369)
@@ -41,8 +41,10 @@
#endif
};
+#define ZIP_HEADER_LEN 26
+
typedef union {
- uint8_t raw[26];
+ uint8_t raw[ZIP_HEADER_LEN];
struct {
uint16_t version; /* 0-1 */
uint16_t flags; /* 2-3 */
@@ -57,8 +59,14 @@
} formatted ATTRIBUTE_PACKED;
} zip_header_t;
+/* Check the offset of the last element, not the length. This leniency
+ * allows for poor packing, whereby the overall struct may be too long,
+ * even though the elements are all in the right place.
+ */
struct BUG_zip_header_must_be_26_bytes {
- char BUG_zip_header_must_be_26_bytes[sizeof(zip_header_t) == 26 ? 1 : -1];
+ char BUG_zip_header_must_be_26_bytes[
+ offsetof(zip_header_t, formatted.extra_len) + 2 ==
+ ZIP_HEADER_LEN ? 1 : -1];
};
#define FIX_ENDIANNESS(zip_header) do { \
@@ -256,7 +264,7 @@
bb_error_msg_and_die("invalid zip magic %08X", magic);
/* Read the file header */
- xread(src_fd, zip_header.raw, sizeof(zip_header));
+ xread(src_fd, zip_header.raw, ZIP_HEADER_LEN);
FIX_ENDIANNESS(zip_header);
if ((zip_header.formatted.method != 0) && (zip_header.formatted.method != 8)) {
bb_error_msg_and_die("unsupported method %d", zip_header.formatted.method);
From bugs at busybox.net Mon Nov 5 17:03:19 2007
From: bugs at busybox.net (bugs at busybox.net)
Date: Mon, 5 Nov 2007 17:03:19 -0800
Subject: [BusyBox 0001574]: syslogd includes null-byte in message transmitted
to remote server
Message-ID: <3610860551f1ec9db7f2ce86e7d3208e@busybox.net>
A NOTE has been added to this issue.
======================================================================
http://busybox.net/bugs/view.php?id=1574
======================================================================
Reported By: pipatron
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1574
Category: Standards Compliance
Reproducibility: always
Severity: minor
Priority: normal
Status: assigned
======================================================================
Date Submitted: 11-04-2007 07:29 PST
Last Modified: 11-05-2007 17:03 PST
======================================================================
Summary: syslogd includes null-byte in message transmitted to
remote server
Description:
Log messages transmitted to remote hosts includes a \0 at the end, which
might be an inconvenience at the remote side when filtering or storing the
message. It's difficult to say if this conforms to the standards or not,
since there aren't any, but no other syslog clients I've seen behaves like
this.
Included are tcpdump captures to show the behaviour.
======================================================================
----------------------------------------------------------------------
pipatron - 11-04-07 07:38
----------------------------------------------------------------------
The debug output got mangled, I uploaded a normal textfile to show the
issue.
----------------------------------------------------------------------
vda - 11-05-07 17:03
----------------------------------------------------------------------
Try 3.patch
Issue History
Date Modified Username Field Change
======================================================================
11-04-07 07:29 pipatron New Issue
11-04-07 07:29 pipatron Status new => assigned
11-04-07 07:29 pipatron Assigned To => BusyBox
11-04-07 07:37 pipatron File Added: busybox-vs-syslog.txt
11-04-07 07:38 pipatron Note Added: 0002888
11-05-07 17:03 vda File Added: 3.patch
11-05-07 17:03 vda Note Added: 0002891
======================================================================
From bugs at busybox.net Mon Nov 5 17:03:36 2007
From: bugs at busybox.net (bugs at busybox.net)
Date: Mon, 5 Nov 2007 17:03:36 -0800
Subject: [BusyBox 0001574]: syslogd includes null-byte in message transmitted
to remote server
Message-ID: <6d2931d16e684a06c6e8ddbbc7dc1181@busybox.net>
The following issue requires your FEEDBACK.
======================================================================
http://busybox.net/bugs/view.php?id=1574
======================================================================
Reported By: pipatron
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1574
Category: Standards Compliance
Reproducibility: always
Severity: minor
Priority: normal
Status: feedback
======================================================================
Date Submitted: 11-04-2007 07:29 PST
Last Modified: 11-05-2007 17:03 PST
======================================================================
Summary: syslogd includes null-byte in message transmitted to
remote server
Description:
Log messages transmitted to remote hosts includes a \0 at the end, which
might be an inconvenience at the remote side when filtering or storing the
message. It's difficult to say if this conforms to the standards or not,
since there aren't any, but no other syslog clients I've seen behaves like
this.
Included are tcpdump captures to show the behaviour.
======================================================================
----------------------------------------------------------------------
pipatron - 11-04-07 07:38
----------------------------------------------------------------------
The debug output got mangled, I uploaded a normal textfile to show the
issue.
----------------------------------------------------------------------
vda - 11-05-07 17:03
----------------------------------------------------------------------
Try 3.patch
Issue History
Date Modified Username Field Change
======================================================================
11-04-07 07:29 pipatron New Issue
11-04-07 07:29 pipatron Status new => assigned
11-04-07 07:29 pipatron Assigned To => BusyBox
11-04-07 07:37 pipatron File Added: busybox-vs-syslog.txt
11-04-07 07:38 pipatron Note Added: 0002888
11-05-07 17:03 vda File Added: 3.patch
11-05-07 17:03 vda Note Added: 0002891
11-05-07 17:03 vda Status assigned => feedback
======================================================================
From bugs at busybox.net Mon Nov 5 17:10:07 2007
From: bugs at busybox.net (bugs at busybox.net)
Date: Mon, 5 Nov 2007 17:10:07 -0800
Subject: [BusyBox 0001575]: Newer unzip.c doesn't compile with
arm-linux-gnu-gcc, bad header structure size.
Message-ID:
A NOTE has been added to this issue.
======================================================================
http://busybox.net/bugs/view.php?id=1575
======================================================================
Reported By: dserpell
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1575
Category: Other
Reproducibility: always
Severity: major
Priority: normal
Status: assigned
======================================================================
Date Submitted: 11-05-2007 07:53 PST
Last Modified: 11-05-2007 17:10 PST
======================================================================
Summary: Newer unzip.c doesn't compile with
arm-linux-gnu-gcc, bad header structure size.
Description:
Compiling using arm-linux-gnu-gcc, (Debian etch version):
-----------------------------------------------------------
CC archival/unzip.o
archival/unzip.c:61: error: size of array
?BUG_zip_header_must_be_26_bytes? is negative
make[1]: *** [archival/unzip.o] Error 1
-----------------------------------------------------------
In fact, the structure size is 28 bytes.
Gcc is:
-----------------------------------------------------------
arm-linux-gnu-gcc -v
Using built-in specs.
Target: arm-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++
--prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/arm-linux-gnu/include/c++/4.1.2
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-checking=release
--program-prefix=arm-linux-gnu- --includedir=/usr/arm-linux-gnu/include
--build=i486-linux-gnu --host=i486-linux-gnu --target=arm-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
-----------------------------------------------------------
I created a small test sample (attached), running it gives:
-----------------------------------------------------------
Size: 28
Fields:
version: 0 (0)
flags: 2 (2)
method: 4 (4)
modtime: 6 (6)
moddate: 8 (8)
crc32: 10 (10)
cmpsize: 14 (14)
ucmpsize: 18 (18)
filename_len: 22 (22)
extra_len: 24 (24)
-----------------------------------------------------------
This means that only the structure size is incorrect.
======================================================================
----------------------------------------------------------------------
dserpell - 11-05-07 10:51
----------------------------------------------------------------------
I added a patch fixing compilation of unzip.c. I tested the resulting
binary on the target, unzipping some files, and it works.
----------------------------------------------------------------------
vda - 11-05-07 17:10
----------------------------------------------------------------------
So you just saw how useful is to have sanity checks against idiotic
compilers, and you are... removing it? Do you want next victim to have
silently miscompiled binaries?
Issue History
Date Modified Username Field Change
======================================================================
11-05-07 07:53 dserpell New Issue
11-05-07 07:53 dserpell Status new => assigned
11-05-07 07:53 dserpell Assigned To => BusyBox
11-05-07 07:53 dserpell File Added: testStruct.c
11-05-07 10:50 dserpell File Added: busybox-unzip.patch
11-05-07 10:51 dserpell Note Added: 0002890
11-05-07 17:10 vda Note Added: 0002892
======================================================================
From vda at busybox.net Mon Nov 5 17:38:47 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 17:38:47 -0800 (PST)
Subject: svn commit: trunk/busybox: archival networking sysklogd
Message-ID: <20071106013847.55475A6079@busybox.net>
Author: vda
Date: 2007-11-05 17:38:46 -0800 (Mon, 05 Nov 2007)
New Revision: 20370
Log:
telnetd: fix problem with zombies (by Paul Fox )
syslogd: strip trailing NULs
Modified:
trunk/busybox/archival/unzip.c
trunk/busybox/networking/telnetd.c
trunk/busybox/sysklogd/syslogd.c
Changeset:
Modified: trunk/busybox/archival/unzip.c
===================================================================
--- trunk/busybox/archival/unzip.c 2007-11-05 23:09:03 UTC (rev 20369)
+++ trunk/busybox/archival/unzip.c 2007-11-06 01:38:46 UTC (rev 20370)
@@ -57,7 +57,7 @@
uint16_t filename_len; /* 22-23 */
uint16_t extra_len; /* 24-25 */
} formatted ATTRIBUTE_PACKED;
-} zip_header_t;
+} zip_header_t ATTRIBUTE_PACKED;
/* Check the offset of the last element, not the length. This leniency
* allows for poor packing, whereby the overall struct may be too long,
Modified: trunk/busybox/networking/telnetd.c
===================================================================
--- trunk/busybox/networking/telnetd.c 2007-11-05 23:09:03 UTC (rev 20369)
+++ trunk/busybox/networking/telnetd.c 2007-11-06 01:38:46 UTC (rev 20370)
@@ -279,6 +279,10 @@
/* make new session and process group */
setsid();
+ /* Restore default signal handling */
+ signal(SIGCHLD, SIG_DFL);
+ signal(SIGPIPE, SIG_DFL);
+
/* open the child's side of the tty. */
/* NB: setsid() disconnects from any previous ctty's. Therefore
* we must open child's side of the tty AFTER setsid! */
@@ -302,14 +306,18 @@
/* Uses FILE-based I/O to stdout, but does fflush(stdout),
* so should be safe with vfork.
* I fear, though, that some users will have ridiculously big
- * issue files, and they may block writing to fd 1. */
+ * issue files, and they may block writing to fd 1,
+ * (parent is supposed to read it, but parent waits
+ * for vforked child to exec!) */
print_login_issue(issuefile, NULL);
/* Exec shell / login / whatever */
login_argv[0] = loginpath;
login_argv[1] = NULL;
- execvp(loginpath, (char **)login_argv);
- /* Safer with vfork, and we shouldn't send message
+ /* exec busybox applet (if PREFER_APPLETS=y), if that fails,
+ * exec external program */
+ BB_EXECVP(loginpath, (char **)login_argv);
+ /* _exit is safer with vfork, and we shouldn't send message
* to remote clients anyway */
_exit(1); /*bb_perror_msg_and_die("execv %s", loginpath);*/
}
@@ -374,7 +382,7 @@
#else /* !FEATURE_TELNETD_STANDALONE */
-/* Used in main() only, thus exits. */
+/* Used in main() only, thus "return 0" actually is exit(0). */
#define free_session(ts) return 0
#endif
@@ -384,20 +392,22 @@
pid_t pid;
struct tsession *ts;
- pid = waitpid(-1, &sig, WNOHANG);
- if (pid > 0) {
+ /* Looping: more than one child may have exited */
+ while (1) {
+ pid = waitpid(-1, NULL, WNOHANG);
+ if (pid <= 0)
+ break;
ts = sessions;
while (ts) {
if (ts->shell_pid == pid) {
ts->shell_pid = -1;
- return;
+ break;
}
ts = ts->next;
}
}
}
-
int telnetd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int telnetd_main(int argc, char **argv)
{
@@ -430,7 +440,7 @@
if (!(opt & OPT_FOREGROUND)) {
/* DAEMON_CHDIR_ROOT was giving inconsistent
* behavior with/without -F, -i */
- bb_daemonize_or_rexec(0 /*DAEMON_CHDIR_ROOT*/, argv);
+ bb_daemonize_or_rexec(0 /*was DAEMON_CHDIR_ROOT*/, argv);
}
}
/* Redirect log to syslog early, if needed */
@@ -466,6 +476,8 @@
if (opt & OPT_WATCHCHILD)
signal(SIGCHLD, handle_sigchld);
+ else /* prevent dead children from becoming zombies */
+ signal(SIGCHLD, SIG_IGN);
/*
This is how the buffers are used. The arrows indicate the movement
@@ -497,7 +509,7 @@
while (ts) {
struct tsession *next = ts->next; /* in case we free ts. */
if (ts->shell_pid == -1) {
- /* Child died ad we detected that */
+ /* Child died and we detected that */
free_session(ts);
} else {
if (ts->size1 > 0) /* can write to pty */
@@ -514,7 +526,7 @@
if (!IS_INETD) {
FD_SET(master_fd, &rdfdset);
/* This is needed because free_session() does not
- * take into account master_fd when it finds new
+ * take master_fd into account when it finds new
* maxfd among remaining fd's */
if (master_fd > maxfd)
maxfd = master_fd;
Modified: trunk/busybox/sysklogd/syslogd.c
===================================================================
--- trunk/busybox/sysklogd/syslogd.c 2007-11-05 23:09:03 UTC (rev 20369)
+++ trunk/busybox/sysklogd/syslogd.c 2007-11-06 01:38:46 UTC (rev 20370)
@@ -381,8 +381,8 @@
}
/* len parameter is used only for "is there a timestamp?" check.
- * NB: some callers cheat and supply 0 when they know
- * that there is no timestamp, short-cutting the test. */
+ * NB: some callers cheat and supply len==0 when they know
+ * that there is no timestamp, short-circuiting the test. */
static void timestamp_and_log(int pri, char *msg, int len)
{
char *timestamp;
@@ -427,10 +427,10 @@
if (*p == '<') {
/* Parse the magic priority number */
pri = bb_strtou(p + 1, &p, 10);
- if (*p == '>') p++;
- if (pri & ~(LOG_FACMASK | LOG_PRIMASK)) {
+ if (*p == '>')
+ p++;
+ if (pri & ~(LOG_FACMASK | LOG_PRIMASK))
pri = (LOG_USER | LOG_NOTICE);
- }
}
while ((c = *p++)) {
@@ -526,14 +526,22 @@
for (;;) {
size_t sz;
-
+ read_again:
sz = safe_read(sock_fd, G.recvbuf, MAX_READ - 1);
- if (sz <= 0) {
- //if (sz == 0)
- // continue; /* EOF from unix socket??? */
+ if (sz < 0) {
bb_perror_msg_and_die("read from /dev/log");
}
+ /* Drop trailing NULs (typically there is one NUL) */
+ while (1) {
+ if (sz == 0)
+ goto read_again;
+ if (G.recvbuf[sz-1])
+ break;
+ sz--;
+ }
+ G.recvbuf[sz] = '\0'; /* make sure it *is* NUL terminated */
+
/* TODO: maybe suppress duplicates? */
#if ENABLE_FEATURE_REMOTE_LOG
/* We are not modifying log messages in any way before send */
@@ -549,7 +557,6 @@
}
}
#endif
- G.recvbuf[sz] = '\0';
split_escape_and_log(G.recvbuf, sz);
} /* for */
}
From vda at busybox.net Mon Nov 5 18:02:45 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 18:02:45 -0800 (PST)
Subject: svn commit: trunk/busybox/modutils
Message-ID: <20071106020245.7A235A685E@busybox.net>
Author: vda
Date: 2007-11-05 18:02:45 -0800 (Mon, 05 Nov 2007)
New Revision: 20371
Log:
insmod: make error reporting less verbose
Modified:
trunk/busybox/modutils/insmod.c
Changeset:
Modified: trunk/busybox/modutils/insmod.c
===================================================================
--- trunk/busybox/modutils/insmod.c 2007-11-06 01:38:46 UTC (rev 20370)
+++ trunk/busybox/modutils/insmod.c 2007-11-06 02:02:45 UTC (rev 20371)
@@ -4241,8 +4241,8 @@
ret = syscall(__NR_init_module, map, len, options);
if (ret != 0) {
- bb_perror_msg_and_die("cannot insert '%s': %s (%li)",
- filename, moderror(errno), ret);
+ bb_error_msg_and_die("cannot insert '%s': %s",
+ filename, moderror(errno));
}
return 0;
From vda at busybox.net Mon Nov 5 18:16:02 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 18:16:02 -0800 (PST)
Subject: svn commit: trunk/busybox/archival
Message-ID: <20071106021602.4FE23A6105@busybox.net>
Author: vda
Date: 2007-11-05 18:16:01 -0800 (Mon, 05 Nov 2007)
New Revision: 20372
Log:
unzip: hmm... gcc doesn't like ATTRIBUTE_PACKED?? Document that...
Modified:
trunk/busybox/archival/unzip.c
Changeset:
Modified: trunk/busybox/archival/unzip.c
===================================================================
--- trunk/busybox/archival/unzip.c 2007-11-06 02:02:45 UTC (rev 20371)
+++ trunk/busybox/archival/unzip.c 2007-11-06 02:16:01 UTC (rev 20372)
@@ -57,7 +57,7 @@
uint16_t filename_len; /* 22-23 */
uint16_t extra_len; /* 24-25 */
} formatted ATTRIBUTE_PACKED;
-} zip_header_t ATTRIBUTE_PACKED;
+} zip_header_t; /* ATTRIBUTE_PACKED - gcc 4.2.1 doesn't like it (spews warning) */
/* Check the offset of the last element, not the length. This leniency
* allows for poor packing, whereby the overall struct may be too long,
From vda at busybox.net Mon Nov 5 18:23:39 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 18:23:39 -0800 (PST)
Subject: svn commit: trunk/busybox: modutils networking networking/udhcp
Message-ID: <20071106022339.BF6A9A65C8@busybox.net>
Author: vda
Date: 2007-11-05 18:23:39 -0800 (Mon, 05 Nov 2007)
New Revision: 20373
Log:
telnet: use poll, it's shorter
*: style fixes
Modified:
trunk/busybox/modutils/insmod.c
trunk/busybox/networking/inetd.c
trunk/busybox/networking/route.c
trunk/busybox/networking/telnet.c
trunk/busybox/networking/udhcp/files.c
Changeset:
Modified: trunk/busybox/modutils/insmod.c
===================================================================
--- trunk/busybox/modutils/insmod.c 2007-11-06 02:16:01 UTC (rev 20372)
+++ trunk/busybox/modutils/insmod.c 2007-11-06 02:23:39 UTC (rev 20373)
@@ -1951,7 +1951,8 @@
while (n > 0) {
ch = *name++;
h = (h << 4) + ch;
- if ((g = (h & 0xf0000000)) != 0) {
+ g = (h & 0xf0000000);
+ if (g != 0) {
h ^= g >> 24;
h &= ~g;
}
Modified: trunk/busybox/networking/inetd.c
===================================================================
--- trunk/busybox/networking/inetd.c 2007-11-06 02:16:01 UTC (rev 20372)
+++ trunk/busybox/networking/inetd.c 2007-11-06 02:23:39 UTC (rev 20373)
@@ -430,7 +430,8 @@
struct protoent *pp;
socklen_t size;
- if ((pp = getprotobyname(sep->se_proto + 4)) == NULL) {
+ pp = getprotobyname(sep->se_proto + 4);
+ if (pp == NULL) {
bb_perror_msg("%s: getproto", sep->se_proto);
return;
}
Modified: trunk/busybox/networking/route.c
===================================================================
--- trunk/busybox/networking/route.c 2007-11-06 02:16:01 UTC (rev 20372)
+++ trunk/busybox/networking/route.c 2007-11-06 02:23:39 UTC (rev 20373)
@@ -352,9 +352,10 @@
memset(&sa6, 0, sizeof(sa6));
} else {
char *cp;
- if ((cp = strchr(target, '/'))) { /* Yes... const to non is ok. */
- *cp = 0;
- prefix_len = xatoul_range(cp+1, 0, 128);
+ cp = strchr(target, '/'); /* Yes... const to non is ok. */
+ if (cp) {
+ *cp = '\0';
+ prefix_len = xatoul_range(cp + 1, 0, 128);
} else {
prefix_len = 128;
}
Modified: trunk/busybox/networking/telnet.c
===================================================================
--- trunk/busybox/networking/telnet.c 2007-11-06 02:16:01 UTC (rev 20372)
+++ trunk/busybox/networking/telnet.c 2007-11-06 02:23:39 UTC (rev 20373)
@@ -101,6 +101,7 @@
#define write_str(fd, str) write(fd, str, sizeof(str) - 1)
+static void doexit(int ev) ATTRIBUTE_NORETURN;
static void doexit(int ev)
{
cookmode();
@@ -157,31 +158,29 @@
static void handlenetoutput(int len)
{
- /* here we could do smart tricks how to handle 0xFF:s in output
- * stream like writing twice every sequence of FF:s (thus doing
- * many write()s. But I think interactive telnet application does
- * not need to be 100% 8-bit clean, so changing every 0xff:s to
- * 0x7f:s
+ /* here we could do smart tricks how to handle 0xFF:s in output
+ * stream like writing twice every sequence of FF:s (thus doing
+ * many write()s. But I think interactive telnet application does
+ * not need to be 100% 8-bit clean, so changing every 0xff:s to
+ * 0x7f:s
*
- * 2002-mar-21, Przemyslaw Czerpak (druzus at polbox.com)
- * I don't agree.
- * first - I cannot use programs like sz/rz
- * second - the 0x0D is sent as one character and if the next
- * char is 0x0A then it's eaten by a server side.
- * third - whay doy you have to make 'many write()s'?
- * I don't understand.
- * So I implemented it. It's realy useful for me. I hope that
- * others people will find it interesting to.
+ * 2002-mar-21, Przemyslaw Czerpak (druzus at polbox.com)
+ * I don't agree.
+ * first - I cannot use programs like sz/rz
+ * second - the 0x0D is sent as one character and if the next
+ * char is 0x0A then it's eaten by a server side.
+ * third - whay doy you have to make 'many write()s'?
+ * I don't understand.
+ * So I implemented it. It's realy useful for me. I hope that
+ * others people will find it interesting too.
*/
int i, j;
byte * p = (byte*)G.buf;
byte outbuf[4*DATABUFSIZE];
- for (i = len, j = 0; i > 0; i--, p++)
- {
- if (*p == 0x1d)
- {
+ for (i = len, j = 0; i > 0; i--, p++) {
+ if (*p == 0x1d) {
conescape();
return;
}
@@ -200,68 +199,59 @@
int i;
int cstart = 0;
- for (i = 0; i < len; i++)
- {
+ for (i = 0; i < len; i++) {
byte c = G.buf[i];
- if (G.telstate == 0) /* most of the time state == 0 */
- {
- if (c == IAC)
- {
+ if (G.telstate == 0) { /* most of the time state == 0 */
+ if (c == IAC) {
cstart = i;
G.telstate = TS_IAC;
}
- }
- else
- switch (G.telstate)
- {
- case TS_0:
- if (c == IAC)
- G.telstate = TS_IAC;
- else
- G.buf[cstart++] = c;
- break;
+ } else
+ switch (G.telstate) {
+ case TS_0:
+ if (c == IAC)
+ G.telstate = TS_IAC;
+ else
+ G.buf[cstart++] = c;
+ break;
- case TS_IAC:
- if (c == IAC) /* IAC IAC -> 0xFF */
- {
- G.buf[cstart++] = c;
- G.telstate = TS_0;
- break;
- }
- /* else */
- switch (c)
- {
- case SB:
- G.telstate = TS_SUB1;
- break;
- case DO:
- case DONT:
- case WILL:
- case WONT:
- G.telwish = c;
- G.telstate = TS_OPT;
- break;
- default:
- G.telstate = TS_0; /* DATA MARK must be added later */
- }
- break;
- case TS_OPT: /* WILL, WONT, DO, DONT */
- telopt(c);
- G.telstate = TS_0;
- break;
- case TS_SUB1: /* Subnegotiation */
- case TS_SUB2: /* Subnegotiation */
- if (subneg(c))
- G.telstate = TS_0;
- break;
- }
+ case TS_IAC:
+ if (c == IAC) { /* IAC IAC -> 0xFF */
+ G.buf[cstart++] = c;
+ G.telstate = TS_0;
+ break;
+ }
+ /* else */
+ switch (c) {
+ case SB:
+ G.telstate = TS_SUB1;
+ break;
+ case DO:
+ case DONT:
+ case WILL:
+ case WONT:
+ G.telwish = c;
+ G.telstate = TS_OPT;
+ break;
+ default:
+ G.telstate = TS_0; /* DATA MARK must be added later */
+ }
+ break;
+ case TS_OPT: /* WILL, WONT, DO, DONT */
+ telopt(c);
+ G.telstate = TS_0;
+ break;
+ case TS_SUB1: /* Subnegotiation */
+ case TS_SUB2: /* Subnegotiation */
+ if (subneg(c))
+ G.telstate = TS_0;
+ break;
+ }
}
- if (G.telstate)
- {
- if (G.iaclen) iacflush();
+ if (G.telstate) {
+ if (G.iaclen) iacflush();
if (G.telstate == TS_0) G.telstate = 0;
-
len = cstart;
}
@@ -440,7 +430,8 @@
} else if (G.telwish == WONT)
return;
- if ((G.telflags ^= UF_SGA) & UF_SGA) /* toggle */
+ G.telflags ^= UF_SGA; /* toggle */
+ if (G.telflags & UF_SGA)
putiac2(DO, TELOPT_SGA);
else
putiac2(DONT, TELOPT_SGA);
@@ -550,6 +541,9 @@
tcsetattr(0, TCSADRAIN, &G.termios_def);
}
+/* poll gives smaller (-70 bytes) code */
+#define USE_POLL 1
+
int telnet_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int telnet_main(int argc, char **argv)
{
Modified: trunk/busybox/networking/udhcp/files.c
===================================================================
--- trunk/busybox/networking/udhcp/files.c 2007-11-06 02:16:01 UTC (rev 20372)
+++ trunk/busybox/networking/udhcp/files.c 2007-11-06 02:23:39 UTC (rev 20373)
@@ -343,8 +343,10 @@
p = strchr(buffer, '#');
if (p) *p = '\0';
- if (!(token = strtok(buffer, " \t"))) continue;
- if (!(line = strtok(NULL, ""))) continue;
+ token = strtok(buffer, " \t");
+ if (!token) continue;
+ line = strtok(NULL, "");
+ if (!line) continue;
/* eat leading whitespace */
line = skip_whitespace(line);
From vda at busybox.net Mon Nov 5 19:05:55 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 19:05:55 -0800 (PST)
Subject: svn commit: trunk/busybox: coreutils editors init libbb loginutils
etc...
Message-ID: <20071106030555.5512EA48D6@busybox.net>
Author: vda
Date: 2007-11-05 19:05:54 -0800 (Mon, 05 Nov 2007)
New Revision: 20374
Log:
fbset: fix buglet where we were using wrong pointer
readahead: stop using stdio.h
*: style fixes
Modified:
trunk/busybox/coreutils/mknod.c
trunk/busybox/editors/diff.c
trunk/busybox/init/init.c
trunk/busybox/libbb/device_open.c
trunk/busybox/libbb/dump.c
trunk/busybox/libbb/obscure.c
trunk/busybox/loginutils/getty.c
trunk/busybox/miscutils/devfsd.c
trunk/busybox/miscutils/hdparm.c
trunk/busybox/miscutils/readahead.c
trunk/busybox/runit/runit_lib.c
trunk/busybox/util-linux/dmesg.c
trunk/busybox/util-linux/fbset.c
trunk/busybox/util-linux/fdisk.c
Changeset:
Modified: trunk/busybox/coreutils/mknod.c
===================================================================
--- trunk/busybox/coreutils/mknod.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/coreutils/mknod.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -28,23 +28,29 @@
argv += optind;
argc -= optind;
- if ((argc >= 2) && ((name = strchr(modes_chars, argv[1][0])) != NULL)) {
- mode |= modes_cubp[(int)(name[4])];
+ if (argc >= 2) {
+ name = strchr(modes_chars, argv[1][0]);
+ if (name != NULL) {
+ mode |= modes_cubp[(int)(name[4])];
- dev = 0;
- if ((*name != 'p') && ((argc -= 2) == 2)) {
- /* Autodetect what the system supports; these macros should
- * optimize out to two constants. */
- dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)),
- xatoul_range(argv[3], 0, minor(UINT_MAX)));
- }
+ dev = 0;
+ if (*name != 'p') {
+ argc -= 2;
+ if (argc == 2) {
+ /* Autodetect what the system supports; these macros should
+ * optimize out to two constants. */
+ dev = makedev(xatoul_range(argv[2], 0, major(UINT_MAX)),
+ xatoul_range(argv[3], 0, minor(UINT_MAX)));
+ }
+ }
- if (argc == 2) {
- name = *argv;
- if (mknod(name, mode, dev) == 0) {
- return EXIT_SUCCESS;
+ if (argc == 2) {
+ name = *argv;
+ if (mknod(name, mode, dev) == 0) {
+ return EXIT_SUCCESS;
+ }
+ bb_simple_perror_msg_and_die(name);
}
- bb_simple_perror_msg_and_die(name);
}
}
bb_show_usage();
Modified: trunk/busybox/editors/diff.c
===================================================================
--- trunk/busybox/editors/diff.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/editors/diff.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -588,7 +588,9 @@
while (1) {
ctold++;
ctnew++;
- if ((c = getc(f1)) != (d = getc(f2))) {
+ c = getc(f1);
+ d = getc(f2);
+ if (c != d) {
J[i] = 0;
if (c != '\n' && c != EOF)
ctold += skipline(f1);
@@ -668,7 +670,8 @@
}
col = 0;
for (j = 0, lastc = '\0'; j < nc; j++, lastc = c) {
- if ((c = getc(lb)) == EOF) {
+ c = getc(lb);
+ if (c == EOF) {
printf("\n\\ No newline at end of file\n");
return;
}
Modified: trunk/busybox/init/init.c
===================================================================
--- trunk/busybox/init/init.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/init/init.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -369,7 +369,8 @@
if (a->action & (SYSINIT | WAIT | CTRLALTDEL | SHUTDOWN | RESTART)) {
/* Now fork off another process to just hang around */
- if ((pid = fork()) < 0) {
+ pid = fork();
+ if (pid) {
message(L_LOG | L_CONSOLE, "Can't fork");
_exit(1);
}
@@ -388,7 +389,8 @@
_exit(0);
/* Use a temporary process to steal the controlling tty. */
- if ((pid = fork()) < 0) {
+ pid = fork();
+ if (pid < 0) {
message(L_LOG | L_CONSOLE, "Can't fork");
_exit(1);
}
Modified: trunk/busybox/libbb/device_open.c
===================================================================
--- trunk/busybox/libbb/device_open.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/libbb/device_open.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -12,15 +12,17 @@
/* try to open up the specified device */
int device_open(const char *device, int mode)
{
- int m, f, fd = -1;
+ int m, f, fd;
m = mode | O_NONBLOCK;
/* Retry up to 5 times */
/* TODO: explain why it can't be considered insane */
- for (f = 0; f < 5; f++)
- if ((fd = open(device, m, 0600)) >= 0)
+ for (f = 0; f < 5; f++) {
+ fd = open(device, m, 0600);
+ if (fd >= 0)
break;
+ }
if (fd < 0)
return fd;
/* Reset original flags. */
Modified: trunk/busybox/libbb/dump.c
===================================================================
--- trunk/busybox/libbb/dump.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/libbb/dump.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -59,7 +59,8 @@
prec = atoi(fmt);
while (isdigit(*++fmt));
}
- if (!(p = strchr(size_conv_str + 12, *fmt))) {
+ p = strchr(size_conv_str + 12, *fmt);
+ if (!p) {
if (*fmt == 's') {
bcnt += prec;
} else if (*fmt == '_') {
@@ -162,7 +163,8 @@
DO_INT_CONV:
{
const char *e;
- if (!(e = strchr(lcc, *p1))) {
+ e = strchr(lcc, *p1);
+ if (!e) {
goto DO_BAD_CONV_CHAR;
}
pr->flags = F_INT;
Modified: trunk/busybox/libbb/obscure.c
===================================================================
--- trunk/busybox/libbb/obscure.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/libbb/obscure.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -130,7 +130,8 @@
c = 0;
p = new_p;
while (1) {
- if ((p = strchr(p, new_p[i])) == NULL) {
+ p = strchr(p, new_p[i]);
+ if (p == NULL) {
break;
}
c++;
Modified: trunk/busybox/loginutils/getty.c
===================================================================
--- trunk/busybox/loginutils/getty.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/loginutils/getty.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -166,8 +166,10 @@
debug("entered parse_speeds\n");
for (cp = strtok(arg, ","); cp != 0; cp = strtok((char *) 0, ",")) {
- if ((op->speeds[op->numspeed++] = bcode(cp)) <= 0)
+ op->speeds[op->numspeed] = bcode(cp);
+ if (op->speeds[op->numspeed] <= 0)
bb_error_msg_and_die("bad speed: %s", cp);
+ op->numspeed++;
if (op->numspeed > MAX_SPEED)
bb_error_msg_and_die("too many alternate speeds");
}
Modified: trunk/busybox/miscutils/devfsd.c
===================================================================
--- trunk/busybox/miscutils/devfsd.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/miscutils/devfsd.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -465,7 +465,8 @@
free(p);
return;
}
- if ((fp = fopen(path, "r")) != NULL) {
+ fp = fopen(path, "r");
+ if (fp != NULL) {
while (fgets(buf, STRING_LENGTH, fp) != NULL) {
/* Skip whitespace */
line = buf;
@@ -560,7 +561,8 @@
case 4: /* "PERMISSIONS" */
new->action.what = AC_PERMISSIONS;
/* Get user and group */
- if ((ptr = strchr(p[0], '.')) == NULL) {
+ ptr = strchr(p[0], '.');
+ if (ptr == NULL) {
msg = "UID.GID";
goto process_config_line_err; /*"missing '.' in UID.GID"*/
}
@@ -979,8 +981,9 @@
if ((source_stat->st_mode & S_IFMT) ==(dest_stat->st_mode & S_IFMT)) {
/* Same type */
if (S_ISLNK(source_stat->st_mode)) {
- if ((source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1)) < 0
- || (dest_len = readlink(destpath , dest_link , STRING_LENGTH - 1)) < 0
+ source_len = readlink(sourcepath, source_link, STRING_LENGTH - 1);
+ if ((source_len < 0)
+ || (dest_len = readlink(destpath, dest_link, STRING_LENGTH - 1)) < 0
)
return FALSE;
source_link[source_len] = '\0';
@@ -999,7 +1002,8 @@
unlink(destpath);
switch (source_stat->st_mode & S_IFMT) {
case S_IFSOCK:
- if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
+ fd = socket(AF_UNIX, SOCK_STREAM, 0);
+ if (fd < 0)
break;
un_addr.sun_family = AF_UNIX;
snprintf(un_addr.sun_path, sizeof(un_addr.sun_path), "%s", destpath);
@@ -1009,14 +1013,16 @@
break;
goto do_chown;
case S_IFLNK:
- if ((val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1)) < 0)
+ val = readlink(sourcepath, symlink_val, STRING_LENGTH - 1);
+ if (val < 0)
break;
symlink_val[val] = '\0';
if (symlink(symlink_val, destpath) == 0)
return TRUE;
break;
case S_IFREG:
- if ((fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT)) < 0)
+ fd = open(destpath, O_RDONLY | O_CREAT, new_mode & ~S_IFMT);
+ if (fd < 0)
break;
close(fd);
if (chmod(destpath, new_mode & ~S_IFMT) != 0)
@@ -1082,7 +1088,7 @@
if (isdigit(string[0]) ||((string[0] == '-') && isdigit(string[1])))
return atoi(string);
- if (flag == UID && (pw_ent = getpwnam(string)) != NULL)
+ if (flag == UID && (pw_ent = getpwnam(string)) != NULL)
return pw_ent->pw_uid;
if (flag == GID && (grp_ent = getgrnam(string)) != NULL)
@@ -1197,7 +1203,8 @@
struct dirent *de;
char *path;
- if ((dp = warn_opendir(dir_name)) == NULL)
+ dp = warn_opendir(dir_name);
+ if (dp == NULL)
return;
while ((de = readdir(dp)) != NULL) {
@@ -1581,7 +1588,8 @@
ch = input[1];
if (isspace(ch) ||(ch == '/') ||(ch == '\0')) {
/* User's own home directory: leave separator for next time */
- if ((env = getenv("HOME")) == NULL) {
+ env = getenv("HOME");
+ if (env == NULL) {
info_logger(LOG_INFO, bb_msg_variable_not_found, "HOME");
return FALSE;
}
@@ -1600,7 +1608,8 @@
goto st_expr_expand_out;
safe_memcpy(tmp, input, len);
input = ptr - 1;
- if ((pwent = getpwnam(tmp)) == NULL) {
+ pwent = getpwnam(tmp);
+ if (pwent == NULL) {
info_logger(LOG_INFO, "no pwent for: %s", tmp);
return FALSE;
}
@@ -1680,7 +1689,8 @@
safe_memcpy(tmp, input, len);
input = ptr - 1;
- if ((env = get_variable_v2(tmp, func, info)) == NULL) {
+ env = get_variable_v2(tmp, func, info);
+ if (env == NULL) {
info_logger(LOG_INFO, bb_msg_variable_not_found, tmp);
return NULL;
}
@@ -1740,7 +1750,8 @@
}
--ptr;
/* At this point ptr should point to closing brace of "${var:-word}" */
- if ((env = get_variable_v2(tmp, func, info)) != NULL) {
+ env = get_variable_v2(tmp, func, info);
+ if (env != NULL) {
/* Found environment variable, so skip the input to the closing brace
and return the variable */
input = ptr;
Modified: trunk/busybox/miscutils/hdparm.c
===================================================================
--- trunk/busybox/miscutils/hdparm.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/miscutils/hdparm.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -1111,7 +1111,8 @@
/* reset result */
jj = val[HWRST_RSLT];
if ((jj & VALID) == VALID_VAL) {
- if (!(oo = (jj & RST0)))
+ oo = (jj & RST0);
+ if (!oo)
jj >>= 8;
if ((jj & DEV_DET) == JUMPER_VAL)
strng = " determined by the jumper";
Modified: trunk/busybox/miscutils/readahead.c
===================================================================
--- trunk/busybox/miscutils/readahead.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/miscutils/readahead.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -15,17 +15,15 @@
int readahead_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int readahead_main(int argc, char **argv)
{
- FILE *f;
int retval = EXIT_SUCCESS;
if (argc == 1) bb_show_usage();
while (*++argv) {
- if ((f = fopen_or_warn(*argv, "r")) != NULL) {
- int r, fd=fileno(f);
-
- r = readahead(fd, 0, fdlength(fd));
- fclose(f);
+ int fd = open_or_warn(*argv, O_RDONLY);
+ if (fd >= 0) {
+ int r = readahead(fd, 0, fdlength(fd));
+ close(fd);
if (r >= 0) continue;
}
retval = EXIT_FAILURE;
Modified: trunk/busybox/runit/runit_lib.c
===================================================================
--- trunk/busybox/runit/runit_lib.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/runit/runit_lib.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -233,19 +233,23 @@
if (!c) return !len;
switch (c) {
case '*':
- if (!(c = *p)) return 1;
+ c = *p;
+ if (!c) return 1;
for (;;) {
if (!len) return 0;
if (*s == c) break;
- ++s; --len;
+ ++s;
+ --len;
}
continue;
case '+':
- if ((c = *p++) != *s) return 0;
+ c = *p++;
+ if (c != *s) return 0;
for (;;) {
if (!len) return 1;
if (*s != c) break;
- ++s; --len;
+ ++s;
+ --len;
}
continue;
/*
@@ -260,7 +264,8 @@
default:
if (!len) return 0;
if (*s != c) return 0;
- ++s; --len;
+ ++s;
+ --len;
continue;
}
}
Modified: trunk/busybox/util-linux/dmesg.c
===================================================================
--- trunk/busybox/util-linux/dmesg.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/util-linux/dmesg.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -27,7 +27,8 @@
len = (flags & 2) ? xatoul_range(size, 2, INT_MAX) : 16384;
buf = xmalloc(len);
- if (0 > (len = klogctl(3 + (flags & 1), buf, len)))
+ len = klogctl(3 + (flags & 1), buf, len);
+ if (len < 0)
bb_perror_msg_and_die("klogctl");
// Skip <#> at the start of lines, and make sure we end with a newline.
Modified: trunk/busybox/util-linux/fbset.c
===================================================================
--- trunk/busybox/util-linux/fbset.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/util-linux/fbset.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -181,10 +181,11 @@
f = xfopen(fn, "r");
while (!feof(f)) {
fgets(buf, sizeof(buf), f);
- if (!(p = strstr(buf, "mode ")) && !(p = strstr(buf, "mode\t")))
+ p = strstr(buf, "mode ");
+ if (!p && !(p = strstr(buf, "mode\t")))
continue;
- p += 5;
- if (!(p = strstr(buf, mode)))
+ p = strstr(p + 5, mode);
+ if (!p)
continue;
p += strlen(mode);
if (!isspace(*p) && (*p != 0) && (*p != '"')
@@ -193,7 +194,8 @@
while (!feof(f)) {
fgets(buf, sizeof(buf), f);
- if ((p = strstr(buf, "geometry "))) {
+ p = strstr(buf, "geometry ");
+ if (p) {
p += 9;
/* FIXME: catastrophic on arches with 64bit ints */
sscanf(p, "%d %d %d %d %d",
Modified: trunk/busybox/util-linux/fdisk.c
===================================================================
--- trunk/busybox/util-linux/fdisk.c 2007-11-06 02:23:39 UTC (rev 20373)
+++ trunk/busybox/util-linux/fdisk.c 2007-11-06 03:05:54 UTC (rev 20374)
@@ -1837,7 +1837,8 @@
last_p_start_pos = 0;
}
pe = &ptes[i];
- if ((p = pe->part_table)->sys_ind) {
+ p = pe->part_table;
+ if (p->sys_ind) {
p_start_pos = get_partition_start(pe);
if (last_p_start_pos > p_start_pos) {
From vda at busybox.net Mon Nov 5 21:26:54 2007
From: vda at busybox.net (vda at busybox.net)
Date: Mon, 5 Nov 2007 21:26:54 -0800 (PST)
Subject: svn commit: trunk/busybox: include libbb loginutils
Message-ID: <20071106052654.35AFDA4D1C@busybox.net>
Author: vda
Date: 2007-11-05 21:26:51 -0800 (Mon, 05 Nov 2007)
New Revision: 20375
Log:
login: clear dangerous environment variables if started by non-root
Modified:
trunk/busybox/include/libbb.h
trunk/busybox/libbb/login.c
trunk/busybox/loginutils/login.c
trunk/busybox/loginutils/sulogin.c
Changeset:
Modified: trunk/busybox/include/libbb.h
===================================================================
--- trunk/busybox/include/libbb.h 2007-11-06 03:05:54 UTC (rev 20374)
+++ trunk/busybox/include/libbb.h 2007-11-06 05:26:51 UTC (rev 20375)
@@ -623,6 +623,8 @@
#endif
void bb_daemonize_or_rexec(int flags, char **argv);
void bb_sanitize_stdio(void);
+/* Clear dangerous stuff, set PATH */
+void sanitize_env_for_suid(void);
extern const char *opt_complementary;
Modified: trunk/busybox/libbb/login.c
===================================================================
--- trunk/busybox/libbb/login.c 2007-11-06 03:05:54 UTC (rev 20374)
+++ trunk/busybox/libbb/login.c 2007-11-06 05:26:51 UTC (rev 20375)
@@ -99,3 +99,29 @@
fputs(LOGIN, stdout);
fflush(stdout);
}
+
+/* Clear dangerous stuff, set PATH */
+static const char forbid[] ALIGN1 =
+ "ENV" "\0"
+ "BASH_ENV" "\0"
+ "HOME" "\0"
+ "IFS" "\0"
+ "SHELL" "\0"
+ "LD_LIBRARY_PATH" "\0"
+ "LD_PRELOAD" "\0"
+ "LD_TRACE_LOADED_OBJECTS" "\0"
+ "LD_BIND_NOW" "\0"
+ "LD_AOUT_LIBRARY_PATH" "\0"
+ "LD_AOUT_PRELOAD" "\0"
+ "LD_NOWARN" "\0"
+ "LD_KEEPDIR" "\0";
+
+void sanitize_env_for_suid(void)
+{
+ const char *p = forbid;
+ do {
+ unsetenv(p);
+ p += strlen(p) + 1;
+ } while (*p);
+ putenv((char*)bb_PATH_root_path);
+}
Modified: trunk/busybox/loginutils/login.c
===================================================================
--- trunk/busybox/loginutils/login.c 2007-11-06 03:05:54 UTC (rev 20374)
+++ trunk/busybox/loginutils/login.c 2007-11-06 05:26:51 UTC (rev 20375)
@@ -201,7 +201,7 @@
int fd;
fd = open(bb_path_motd_file, O_RDONLY);
- if (fd) {
+ if (fd >= 0) {
fflush(stdout);
bb_copyfd_eof(fd, STDOUT_FILENO);
close(fd);
@@ -216,6 +216,10 @@
ndelay_on(1);
ndelay_on(2);
printf("\r\nLogin timed out after %d seconds\r\n", TIMEOUT);
+ /* unix API is brain damaged regarding O_NONBLOCK,
+ * we should undo it, or else we can affect other processes */
+ ndelay_off(1);
+ ndelay_off(2);
exit(EXIT_SUCCESS);
}
@@ -254,6 +258,11 @@
* and any extra open fd's are closed.
* (The name of the function is misleading. Not daemonizing here.) */
bb_daemonize_or_rexec(DAEMON_ONLY_SANITIZE | DAEMON_CLOSE_EXTRA_FDS, NULL);
+ /* More of suid paranoia if called by non-root */
+ if (!amroot) {
+ /* Clear dangerous stuff, set PATH */
+ sanitize_env_for_suid();
+ }
opt = getopt32(argv, "f:h:p", &opt_user, &opt_host);
if (opt & LOGIN_OPT_f) {
@@ -411,7 +420,8 @@
fchown(0, pw->pw_uid, pw->pw_gid);
fchmod(0, 0600);
- if (ENABLE_LOGIN_SCRIPTS) {
+ /* We trust environment only if we run by root */
+ if (ENABLE_LOGIN_SCRIPTS && amroot) {
char *t_argv[2];
t_argv[0] = getenv("LOGIN_PRE_SUID_SCRIPT");
Modified: trunk/busybox/loginutils/sulogin.c
===================================================================
--- trunk/busybox/loginutils/sulogin.c 2007-11-06 03:05:54 UTC (rev 20374)
+++ trunk/busybox/loginutils/sulogin.c 2007-11-06 05:26:51 UTC (rev 20375)
@@ -9,22 +9,6 @@
#include "libbb.h"
-static const char forbid[] ALIGN1 =
- "ENV" "\0"
- "BASH_ENV" "\0"
- "HOME" "\0"
- "IFS" "\0"
- "PATH" "\0"
- "SHELL" "\0"
- "LD_LIBRARY_PATH" "\0"
- "LD_PRELOAD" "\0"
- "LD_TRACE_LOADED_OBJECTS" "\0"
- "LD_BIND_NOW" "\0"
- "LD_AOUT_LIBRARY_PATH" "\0"
- "LD_AOUT_PRELOAD" "\0"
- "LD_NOWARN" "\0"
- "LD_KEEPDIR" "\0";
-
//static void catchalarm(int ATTRIBUTE_UNUSED junk)
//{
// exit(EXIT_FAILURE);
@@ -37,7 +21,6 @@
char *cp;
int timeout = 0;
char *timeout_arg;
- const char *p;
struct passwd *pwd;
const char *shell;
#if ENABLE_FEATURE_SHADOWPASSWDS
@@ -66,12 +49,8 @@
bb_error_msg_and_die("not a tty");
}
- /* Clear out anything dangerous from the environment */
- p = forbid;
- do {
- unsetenv(p);
- p += strlen(p) + 1;
- } while (*p);
+ /* Clear dangerous stuff, set PATH */
+ sanitize_env_for_suid();
// bb_askpass() already handles this
// signal(SIGALRM, catchalarm);
From bugs at busybox.net Mon Nov 5 21:27:22 2007
From: bugs at busybox.net (bugs at busybox.net)
Date: Mon, 5 Nov 2007 21:27:22 -0800
Subject: [BusyBox 0001575]: Newer unzip.c doesn't compile with
arm-linux-gnu-gcc, bad header structure size.
Message-ID: <3a626c6f3da7fd83275ab44ea5fd0354@busybox.net>
The following issue has been CLOSED
======================================================================
http://busybox.net/bugs/view.php?id=1575
======================================================================
Reported By: dserpell
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1575
Category: Other
Reproducibility: always
Severity: major
Priority: normal
Status: closed
Resolution: open
Fixed in Version:
======================================================================
Date Submitted: 11-05-2007 07:53 PST
Last Modified: 11-05-2007 21:27 PST
======================================================================
Summary: Newer unzip.c doesn't compile with
arm-linux-gnu-gcc, bad header structure size.
Description:
Compiling using arm-linux-gnu-gcc, (Debian etch version):
-----------------------------------------------------------
CC archival/unzip.o
archival/unzip.c:61: error: size of array
?BUG_zip_header_must_be_26_bytes? is negative
make[1]: *** [archival/unzip.o] Error 1
-----------------------------------------------------------
In fact, the structure size is 28 bytes.
Gcc is:
-----------------------------------------------------------
arm-linux-gnu-gcc -v
Using built-in specs.
Target: arm-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++
--prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--with-gxx-include-dir=/usr/arm-linux-gnu/include/c++/4.1.2
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-checking=release
--program-prefix=arm-linux-gnu- --includedir=/usr/arm-linux-gnu/include
--build=i486-linux-gnu --host=i486-linux-gnu --target=arm-linux-gnu
Thread model: posix
gcc version 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)
-----------------------------------------------------------
I created a small test sample (attached),