Apply post-1.19.2 patches, bump version to 1.19.3 1_19_3
authorDenys Vlasenko <vda.linux@googlemail.com>
Fri, 28 Oct 2011 15:48:15 +0000 (17:48 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Fri, 28 Oct 2011 15:48:15 +0000 (17:48 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Makefile
applets/applet_tables.c
coreutils/tail.c
include/platform.h
loginutils/chpasswd.c
miscutils/crond.c
networking/inetd.c
networking/tftp.c
sysklogd/syslogd.c
testsuite/tail.tests

index 2cac36c0001fa96701f95c78db576d42905ecda1..9648c9c208324783912ef68465c648e09419a788 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 1
 PATCHLEVEL = 19
-SUBLEVEL = 2
+SUBLEVEL = 3
 EXTRAVERSION =
 NAME = Unnamed
 
index 3859d73262b59a484557f573c61055d5f7600fe0..a47574737f7ef84f84aab48b70efd6b8dd626a31 100644 (file)
@@ -80,8 +80,15 @@ int main(int argc, char **argv)
 
        printf("#define NUM_APPLETS %u\n", NUM_APPLETS);
        if (NUM_APPLETS == 1) {
+               char *dash_to_underscore, *p;
                printf("#define SINGLE_APPLET_STR \"%s\"\n", applets[0].name);
-               printf("#define SINGLE_APPLET_MAIN %s_main\n", applets[0].name);
+               /* Example: "ether-wake" -> "ether_wake" */
+               p = dash_to_underscore = strdup(applets[0].name);
+               p--;
+               while (*++p)
+                       if (*p == '-')
+                               *p = '_';
+               printf("#define SINGLE_APPLET_MAIN %s_main\n", dash_to_underscore);
        }
        printf("\n");
 
index 454c2593625d640bbff061d1b51f8fe34a598481..43cecbd97ffd7c08dc7dd54fd137025e6b59350b 100644 (file)
@@ -203,7 +203,7 @@ int tail_main(int argc, char **argv)
                int fd = fds[i];
 
                if (ENABLE_FEATURE_FANCY_TAIL && fd < 0)
-                       continue; /* may happen with -E */
+                       continue; /* may happen with -F */
 
                if (nfiles > header_threshhold) {
                        tail_xprint_header(fmt, argv[i]);
@@ -252,14 +252,14 @@ int tail_main(int argc, char **argv)
                 * Used only by +N code ("start from Nth", 1-based): */
                seen = 1;
                newlines_seen = 0;
-               while ((nread = tail_read(fd, buf, tailbufsize-taillen)) > 0) {
+               while ((nread = tail_read(fd, buf, tailbufsize - taillen)) > 0) {
                        if (G.from_top) {
                                int nwrite = nread;
                                if (seen < count) {
                                        /* We need to skip a few more bytes/lines */
                                        if (COUNT_BYTES) {
                                                nwrite -= (count - seen);
-                                               seen = count;
+                                               seen += nread;
                                        } else {
                                                char *s = buf;
                                                do {
index 826a4c497ba271000b7fd7d9c1dd7c9658bbb3c7..aa1bc331b8f4c0fc710046433c6b3b37e7473132 100644 (file)
@@ -433,7 +433,7 @@ typedef unsigned smalluint;
 # undef HAVE_STPCPY
 #endif
 
-#if defined(ANDROID)
+#if defined(ANDROID) || defined(__ANDROID__)
 # undef HAVE_DPRINTF
 # undef HAVE_GETLINE
 # undef HAVE_STPCPY
index 2262b792a34b12ee1e6cf7d74b9da8044a4334d9..b7df57e5d461313e52f510750167b31f6dbffec2 100644 (file)
@@ -33,9 +33,8 @@ static const char chpasswd_longopts[] ALIGN1 =
 int chpasswd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int chpasswd_main(int argc UNUSED_PARAM, char **argv)
 {
-       char *name, *pass;
-       char salt[sizeof("$N$XXXXXXXX")];
-       int opt, rc;
+       char *name;
+       int opt;
 
        if (getuid() != 0)
                bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
@@ -45,6 +44,10 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
        opt = getopt32(argv, "em");
 
        while ((name = xmalloc_fgetline(stdin)) != NULL) {
+               char *free_me;
+               char *pass;
+               int rc;
+
                pass = strchr(name, ':');
                if (!pass)
                        bb_error_msg_and_die("missing new password");
@@ -52,7 +55,10 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
 
                xuname2uid(name); /* dies if there is no such user */
 
+               free_me = NULL;
                if (!(opt & OPT_ENC)) {
+                       char salt[sizeof("$N$XXXXXXXX")];
+
                        crypt_make_salt(salt, 1);
                        if (opt & OPT_MD5) {
                                salt[0] = '$';
@@ -60,7 +66,7 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
                                salt[2] = '$';
                                crypt_make_salt(salt + 3, 4);
                        }
-                       pass = pw_encrypt(pass, salt, 0);
+                       free_me = pass = pw_encrypt(pass, salt, 0);
                }
 
                /* This is rather complex: if user is not found in /etc/shadow,
@@ -81,8 +87,7 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
                        bb_info_msg("Password for '%s' changed", name);
                logmode = LOGMODE_STDIO;
                free(name);
-               if (!(opt & OPT_ENC))
-                       free(pass);
+               free(free_me);
        }
        return EXIT_SUCCESS;
 }
index 014016fb63c16f3ab00fa6e03c0dae69977b8f2d..a0b73c77497018d1abed6c469bac6da8623150ab 100644 (file)
@@ -861,7 +861,8 @@ int crond_main(int argc UNUSED_PARAM, char **argv)
 
        /* "-b after -f is ignored", and so on for every pair a-b */
        opt_complementary = "f-b:b-f:S-L:L-S" IF_FEATURE_CROND_D(":d-l")
-                       ":l+:d+"; /* -l and -d have numeric param */
+                       /* -l and -d have numeric param */
+                       ":l+" IF_FEATURE_CROND_D(":d+");
        opts = getopt32(argv, "l:L:fbSc:" IF_FEATURE_CROND_D("d:"),
                        &G.log_level, &G.log_filename, &G.crontab_dir_name
                        IF_FEATURE_CROND_D(,&G.log_level));
index 873fd95281fdd668514588c9c955a4edf99877da..05ad8c7929fc6d20549985d76a7b4cb68dc683ef 100644 (file)
@@ -1278,6 +1278,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
                                                        sep->se_count = 0;
                                                        rearm_alarm(); /* will revive it in RETRYTIME sec */
                                                        restore_sigmask(&omask);
+                                                       maybe_close(new_udp_fd);
                                                        maybe_close(accepted_fd);
                                                        continue; /* -> check next fd in fd set */
                                                }
@@ -1298,17 +1299,18 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
                                        bb_perror_msg("vfork"+1);
                                        sleep(1);
                                        restore_sigmask(&omask);
+                                       maybe_close(new_udp_fd);
                                        maybe_close(accepted_fd);
                                        continue; /* -> check next fd in fd set */
                                }
                                if (pid == 0)
                                        pid--; /* -1: "we did fork and we are child" */
                        }
-                       /* if pid == 0 here, we never forked */
+                       /* if pid == 0 here, we didn't fork */
 
                        if (pid > 0) { /* parent */
                                if (sep->se_wait) {
-                                       /* tcp wait: we passed listening socket to child,
+                                       /* wait: we passed socket to child,
                                         * will wait for child to terminate */
                                        sep->se_wait = pid;
                                        remove_fd_from_set(sep->se_fd);
@@ -1345,9 +1347,13 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
                        setsid();
                        /* "nowait" udp */
                        if (new_udp_fd >= 0) {
-                               len_and_sockaddr *lsa = xzalloc_lsa(sep->se_family);
+                               len_and_sockaddr *lsa;
+                               int r;
+
+                               close(new_udp_fd);
+                               lsa = xzalloc_lsa(sep->se_family);
                                /* peek at the packet and remember peer addr */
-                               int r = recvfrom(ctrl, NULL, 0, MSG_PEEK|MSG_DONTWAIT,
+                               r = recvfrom(ctrl, NULL, 0, MSG_PEEK|MSG_DONTWAIT,
                                        &lsa->u.sa, &lsa->len);
                                if (r < 0)
                                        goto do_exit1;
index 17485a527ac299f3263faaebb707e06dda9fe274..043b879af45cb1925235777699255db3ec8bb9af 100644 (file)
@@ -813,7 +813,8 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
                goto err;
        }
        mode = local_file + strlen(local_file) + 1;
-       if (mode >= block_buf + result || strcmp(mode, "octet") != 0) {
+       /* RFC 1350 says mode string is case independent */
+       if (mode >= block_buf + result || strcasecmp(mode, "octet") != 0) {
                goto err;
        }
 # if ENABLE_FEATURE_TFTP_BLOCKSIZE
index 2f0ca6ac57c4863131623f444c145035e90dcda1..fc380d9f91bcfabc697489c9f6144b931cd02a5c 100644 (file)
@@ -278,7 +278,7 @@ static void parse_syslogdcfg(const char *file)
        parser_t *parser;
 
        parser = config_open2(file ? file : "/etc/syslog.conf",
-                               file ? xfopen_for_read : fopen_or_warn_stdin);
+                               file ? xfopen_for_read : fopen_for_read);
        if (!parser)
                /* didn't find default /etc/syslog.conf */
                /* proceed as if we built busybox without config support */
@@ -594,6 +594,14 @@ static void log_locally(time_t now, char *msg, logFile_t *log_file)
                        }
                        /* newFile == "f.0" now */
                        rename(log_file->path, newFile);
+                       /* Incredibly, if F and F.0 are hardlinks, POSIX
+                        * _demands_ that rename returns 0 but does not
+                        * remove F!!!
+                        * (hardlinked F/F.0 pair was observed after
+                        * power failure during rename()).
+                        * Ensure old file is gone:
+                        */
+                       unlink(log_file->path);
 #ifdef SYSLOGD_WRLOCK
                        fl.l_type = F_UNLCK;
                        fcntl(log_file->fd, F_SETLKW, &fl);
@@ -678,7 +686,7 @@ static void timestamp_and_log(int pri, char *msg, int len)
        if (LOG_PRI(pri) < G.logLevel) {
 #if ENABLE_FEATURE_IPC_SYSLOG
                if ((option_mask32 & OPT_circularlog) && G.shbuf) {
-                       log_to_shmem(msg);
+                       log_to_shmem(G.printbuf);
                        return;
                }
 #endif
index 7140da262b6e2590f56bb61fe57effb2ae3f68b6..305a83b15ec243e73321f0d3e224edfb97b40f07 100755 (executable)
@@ -14,4 +14,12 @@ testing "tail: +N with N > file length" \
        "0\n" \
        "" "qw"
 
+testing "tail: -c +N with largish N" \
+       "
+       dd if=/dev/zero bs=16k count=1 2>/dev/null | tail -c +8200 | wc -c;
+       dd if=/dev/zero bs=16k count=1 2>/dev/null | tail -c +8208 | wc -c;
+       " \
+       "8185\n8177\n" \
+       "" ""
+
 exit $FAILCOUNT