*: hopefully all setup_common_bufsiz() are in place
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 21 Apr 2016 16:38:51 +0000 (18:38 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 21 Apr 2016 16:38:51 +0000 (18:38 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
29 files changed:
archival/tar.c
console-tools/dumpkmap.c
coreutils/catv.c
coreutils/cksum.c
coreutils/date.c
coreutils/split.c
coreutils/stat.c
coreutils/sum.c
coreutils/tee.c
editors/diff.c
editors/ed.c
miscutils/chat.c
miscutils/conspy.c
miscutils/fbsplash.c
miscutils/inotifyd.c
miscutils/less.c
miscutils/microcom.c
networking/httpd.c
networking/isrv_identd.c
networking/libiproute/ipaddress.c
networking/libiproute/ipneigh.c
networking/libiproute/iproute.c
networking/nc.c
procps/nmeter.c
runit/svlogd.c
sysklogd/klogd.c
sysklogd/logger.c
util-linux/script.c
util-linux/umount.c

index caf4363dea69f63cae561d5623c5890f65160061..346a9404eef9f8a3e3780892797aeea7da53b3da 100644 (file)
 
 
 #define block_buf bb_common_bufsiz1
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
 
 
 #if ENABLE_FEATURE_TAR_CREATE
@@ -964,6 +965,7 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
 #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
        llist_t *excludes = NULL;
 #endif
+       INIT_G();
 
        /* Initialise default values */
        tar_handle = init_handle();
index 6412dffc888bedd87c402c276f30ed59232dea01..b6fd466dc8a83f63b8e0e5a8101b71e24d2f0bbc 100644 (file)
@@ -38,6 +38,7 @@ int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
        struct kbentry ke;
        int i, j, fd;
 #define flags bb_common_bufsiz1
+       setup_common_bufsiz();
 
        /* When user accidentally runs "dumpkmap FILE"
         * instead of "dumpkmap >FILE", we'd dump binary stuff to tty.
index 801d2451d4ff410df2a1484803a04e6651352c96..0e71368a5f95cf780abb200612f0d8388b04b5c6 100644 (file)
@@ -49,6 +49,9 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
        /* Read from stdin if there's nothing else to do. */
        if (!argv[0])
                *--argv = (char*)"-";
+
+#define read_buf bb_common_bufsiz1
+       setup_common_bufsiz();
        do {
                fd = open_or_warn_stdin(*argv);
                if (fd < 0) {
@@ -58,7 +61,6 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
                for (;;) {
                        int i, res;
 
-#define read_buf bb_common_bufsiz1
                        res = read(fd, read_buf, COMMON_BUFSIZE);
                        if (res < 0)
                                retval = EXIT_FAILURE;
index d8351e7c6022bf9a87dfc7523985c87c0f6c5d3d..8a8a39f68aeefe758a714e3662d6ba4e3303ef9e 100644 (file)
@@ -33,6 +33,7 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
        argv++;
 #endif
 
+       setup_common_bufsiz();
        do {
                int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input);
 
@@ -43,9 +44,8 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
                crc = 0;
                length = 0;
 
-#define        read_buf bb_common_bufsiz1
-#define sizeof_read_buf COMMON_BUFSIZE
-               while ((bytes_read = safe_read(fd, read_buf, sizeof_read_buf)) > 0) {
+#define read_buf bb_common_bufsiz1
+               while ((bytes_read = safe_read(fd, read_buf, COMMON_BUFSIZE)) > 0) {
                        length += bytes_read;
                        crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table);
                }
index 59b4b8f2a1172bb450da08a36e85f390a8b96200..ff3214d8513d7a453102fbc3648b75d65f06e9bf 100644 (file)
@@ -368,8 +368,8 @@ int date_main(int argc UNUSED_PARAM, char **argv)
        }
 #endif
 
-#define        date_buf bb_common_bufsiz1
-#define sizeof_date_buf COMMON_BUFSIZE
+#define date_buf bb_common_bufsiz1
+       setup_common_bufsiz();
        if (*fmt_dt2str == '\0') {
                /* With no format string, just print a blank line */
                date_buf[0] = '\0';
@@ -379,7 +379,7 @@ int date_main(int argc UNUSED_PARAM, char **argv)
                        fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
                }
                /* Generate output string */
-               strftime(date_buf, sizeof_date_buf, fmt_dt2str, &tm_time);
+               strftime(date_buf, COMMON_BUFSIZE, fmt_dt2str, &tm_time);
        }
        puts(date_buf);
 
index b2da74e2789dd3cff5629fd85b93450715642bc6..e67c3de6648f97044125045356ce84a44e84d80b 100644 (file)
@@ -79,6 +79,8 @@ int split_main(int argc UNUSED_PARAM, char **argv)
        ssize_t bytes_read, to_write;
        char *src;
 
+       setup_common_bufsiz();
+
        opt_complementary = "?2:a+"; /* max 2 args; -a N */
        opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len);
 
index 78df9c94840fe4ab2e0004205a8eb68972775e58..ddcfcf2d78bd319e7984fdb0c4077ee6a97e2fc1 100644 (file)
@@ -158,10 +158,9 @@ static const char *human_time(time_t t)
        /* coreutils 6.3 compat: */
 
        /*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/
-#define        buf bb_common_bufsiz1
-#define sizeof_buf COMMON_BUFSIZE
-
-       strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof_buf, &t), ".000000000");
+#define buf bb_common_bufsiz1
+       setup_common_bufsiz();
+       strcpy(strftime_YYYYMMDDHHMMSS(buf, COMMON_BUFSIZE, &t), ".000000000");
        return buf;
 #undef buf
 }
index cc6677221a2068f20416b2144a90e4d291d2a8da..ec9ed2a1110eaad2ea9f4e9cfaf5765223d5ae80 100644 (file)
@@ -31,12 +31,14 @@ enum { SUM_BSD, PRINT_NAME, SUM_SYSV };
 /* Return 1 if successful.  */
 static unsigned sum_file(const char *file, unsigned type)
 {
-#define buf bb_common_bufsiz1
        unsigned long long total_bytes = 0;
        int fd, r;
        /* The sum of all the input bytes, modulo (UINT_MAX + 1).  */
        unsigned s = 0;
 
+#define buf bb_common_bufsiz1
+       setup_common_bufsiz();
+
        fd = open_or_warn_stdin(file);
        if (fd == -1)
                return 0;
index a0e177cbcff9f413016e2e1a4806b3cf4ea86d90..a68e9446ff48fa008fb635fefa8403876ae54af4 100644 (file)
@@ -37,8 +37,8 @@ int tee_main(int argc, char **argv)
 //TODO: make unconditional
 #if ENABLE_FEATURE_TEE_USE_BLOCK_IO
        ssize_t c;
-# define        buf bb_common_bufsiz1
-# define sizeof_buf COMMON_BUFSIZE
+# define buf bb_common_bufsiz1
+       setup_common_bufsiz();
 #else
        int c;
 #endif
@@ -81,7 +81,7 @@ int tee_main(int argc, char **argv)
        /* names[0] will be filled later */
 
 #if ENABLE_FEATURE_TEE_USE_BLOCK_IO
-       while ((c = safe_read(STDIN_FILENO, buf, sizeof_buf)) > 0) {
+       while ((c = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE)) > 0) {
                fp = files;
                do
                        fwrite(buf, 1, c, *fp);
index 3c8e9074a649d3e7993a10f6460064c2214d50d0..ff269360f6d9a94f78fdd94f4eefffa3e4dcb91b 100644 (file)
@@ -749,6 +749,7 @@ static int diffreg(char *file[2])
                fp[i] = fdopen(fd, "r");
        }
 
+       setup_common_bufsiz();
        while (1) {
                const size_t sz = COMMON_BUFSIZE / 2;
                char *const buf0 = bb_common_bufsiz1;
index 8da7b1dd5b05cc762803794ed7468265bca766f8..c028b78cb8157599f3788e3a55e995b20401c395 100644 (file)
@@ -33,12 +33,11 @@ typedef struct LINE {
 } LINE;
 
 
-#define        searchString bb_common_bufsiz1
-#define sizeof_searchString COMMON_BUFSIZE
+#define searchString bb_common_bufsiz1
 
 enum {
-       USERSIZE = sizeof_searchString > 1024 ? 1024
-                : sizeof_searchString - 1, /* max line length typed in by user */
+       USERSIZE = COMMON_BUFSIZE > 1024 ? 1024
+                : COMMON_BUFSIZE - 1, /* max line length typed in by user */
        INITBUF_SIZE = 1024, /* initial buffer size */
 };
 
@@ -68,6 +67,7 @@ struct globals {
 #define lines              (G.lines             )
 #define marks              (G.marks             )
 #define INIT_G() do { \
+       setup_common_bufsiz(); \
        SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
 } while (0)
 
index 25850dd20dcf6b752f641f8f54993cb8b224b836..6b429f2a648f00b5ccd4b5fbb2a95d311782b571 100644 (file)
@@ -286,9 +286,10 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
                            && poll(&pfd, 1, timeout) > 0
                            && (pfd.revents & POLLIN)
                        ) {
-#define buf bb_common_bufsiz1
                                llist_t *l;
                                ssize_t delta;
+#define buf bb_common_bufsiz1
+                               setup_common_bufsiz();
 
                                // read next char from device
                                if (safe_read(STDIN_FILENO, buf+buf_len, 1) > 0) {
index 0d96a5f9a4037f800f71da0f7f9799859c974dfc..f6468c116b7b682fe4cf27c98f8668864e83bacc 100644 (file)
@@ -364,8 +364,6 @@ int conspy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
 int conspy_main(int argc UNUSED_PARAM, char **argv)
 {
        char tty_name[sizeof(DEV_TTY "NN")];
-#define        keybuf bb_common_bufsiz1
-#define sizeof_keybuf COMMON_BUFSIZE
        struct termios termbuf;
        unsigned opts;
        unsigned ttynum;
@@ -384,6 +382,9 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
 
        applet_long_options = getopt_longopts;
 #endif
+#define keybuf bb_common_bufsiz1
+       setup_common_bufsiz();
+
        INIT_G();
        strcpy(G.vcsa_name, DEV_VCSA);
 
@@ -515,7 +516,7 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
                default:
                        // Read the keys pressed
                        k = keybuf + G.key_count;
-                       bytes_read = read(G.kbd_fd, k, sizeof_keybuf - G.key_count);
+                       bytes_read = read(G.kbd_fd, k, COMMON_BUFSIZE - G.key_count);
                        if (bytes_read < 0)
                                goto abort;
 
index b26ad2c1566a6ae789d10afbaebe22bb7af1319b..3ddf8a242767e6f902ae55c33a8f163953b2f1e5 100644 (file)
@@ -373,12 +373,13 @@ static void fb_drawimage(void)
         * - A raster of Width * Height pixels in triplets of rgb
         *   in pure binary by 1 or 2 bytes. (we support only 1 byte)
         */
-#define        concat_buf bb_common_bufsiz1
-#define sizeof_concat_buf COMMON_BUFSIZE
+#define concat_buf bb_common_bufsiz1
+       setup_common_bufsiz();
+
        read_ptr = concat_buf;
        while (1) {
                int w, h, max_color_val;
-               int rem = concat_buf + sizeof_concat_buf - read_ptr;
+               int rem = concat_buf + COMMON_BUFSIZE - read_ptr;
                if (rem < 2
                 || fgets(read_ptr, rem, theme_file) == NULL
                ) {
index 1d28e8f992d576ed3f8b2f134e17d767c39d2333..52db08adac5f5f192d73cadfbe6d70abd31d6e5f 100644 (file)
@@ -162,10 +162,10 @@ int inotifyd_main(int argc, char **argv)
 
                // read out all pending events
                // (NB: len must be int, not ssize_t or long!)
+#define eventbuf bb_common_bufsiz1
+               setup_common_bufsiz();
                xioctl(pfd.fd, FIONREAD, &len);
-#define        eventbuf bb_common_bufsiz1
-#define sizeof_eventbuf COMMON_BUFSIZE
-               ie = buf = (len <= sizeof_eventbuf) ? eventbuf : xmalloc(len);
+               ie = buf = (len <= COMMON_BUFSIZE) ? eventbuf : xmalloc(len);
                len = full_read(pfd.fd, buf, len);
                // process events. N.B. events may vary in length
                while (len > 0) {
index 94ecf1686c0e70b1a0e7f704f18c8f2552dd3fe3..d7076dbbc78b66d284abc2fdffdc3d1306318d23 100644 (file)
@@ -440,8 +440,6 @@ static int at_end(void)
  */
 static void read_lines(void)
 {
-#define        readbuf bb_common_bufsiz1
-#define sizeof_readbuf COMMON_BUFSIZE
        char *current_line, *p;
        int w = width;
        char last_terminated = terminated;
@@ -451,6 +449,9 @@ static void read_lines(void)
        unsigned old_max_fline = max_fline;
 #endif
 
+#define readbuf bb_common_bufsiz1
+       setup_common_bufsiz();
+
        /* (careful: max_fline can be -1) */
        if (max_fline + 1 > MAXLINES)
                return;
@@ -482,7 +483,7 @@ static void read_lines(void)
                                        time_t t;
 
                                        errno = 0;
-                                       eof_error = safe_read(STDIN_FILENO, readbuf, sizeof_readbuf);
+                                       eof_error = safe_read(STDIN_FILENO, readbuf, COMMON_BUFSIZE);
                                        if (errno != EAGAIN)
                                                break;
                                        t = time(NULL);
index 5eb2e6743e07ffa912181fcb54c8f1046aad4f86..d9e8f918790e1304fb1233311675626dbac720ea 100644 (file)
@@ -156,11 +156,11 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
 skip_write: ;
                }
                if (pfd[0].revents) {
-#define        iobuf bb_common_bufsiz1
-#define sizeof_iobuf COMMON_BUFSIZE
                        ssize_t len;
+#define iobuf bb_common_bufsiz1
+                       setup_common_bufsiz();
                        // read from device -> write to stdout
-                       len = safe_read(sfd, iobuf, sizeof_iobuf);
+                       len = safe_read(sfd, iobuf, COMMON_BUFSIZE);
                        if (len > 0)
                                full_write(STDOUT_FILENO, iobuf, len);
                        else {
index ef90770acfcba4b20cfe3c79e4274c81635c8088..abe83a458d36971570fa3ea64a2a89d81a5ec2e5 100644 (file)
@@ -370,6 +370,7 @@ enum {
 # define content_gzip     0
 #endif
 #define INIT_G() do { \
+       setup_common_bufsiz(); \
        SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
        IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
        IF_FEATURE_HTTPD_RANGES(range_start = -1;) \
index f63ed8ee4012264ce9e8485d4a4c1b4acb016579..8a15926e5832d280f3b97e8cb3e2fc5350761abe 100644 (file)
@@ -29,8 +29,7 @@ typedef struct identd_buf_t {
        char buf[64 - sizeof(int)];
 } identd_buf_t;
 
-#define        bogouser bb_common_bufsiz1
-#define sizeof_bogouser COMMON_BUFSIZE
+#define bogouser bb_common_bufsiz1
 
 static int new_peer(isrv_state_t *state, int fd)
 {
@@ -117,10 +116,12 @@ int fakeidentd_main(int argc UNUSED_PARAM, char **argv)
        unsigned opt;
        int fd;
 
+       setup_common_bufsiz();
+
        opt = getopt32(argv, "fiwb:", &bind_address);
        strcpy(bogouser, "nobody");
        if (argv[optind])
-               strncpy(bogouser, argv[optind], sizeof_bogouser - 1);
+               strncpy(bogouser, argv[optind], COMMON_BUFSIZE - 1);
 
        /* Daemonize if no -f and no -i and no -w */
        if (!(opt & OPT_fiw))
index 2c0f514c7d9bcdd3433059b1eec157a382a96672..d9e09960759e4977e39d9136a202d860821633d2 100644 (file)
@@ -41,7 +41,7 @@ struct filter_t {
 typedef struct filter_t filter_t;
 
 #define G_filter (*(filter_t*)bb_common_bufsiz1)
-
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
 
 static void print_link_flags(unsigned flags, unsigned mdown)
 {
@@ -745,6 +745,9 @@ int FAST_FUNC do_ipaddr(char **argv)
                /* 0    1         2      3          4         5       6       7      8 */
                "add\0""change\0""chg\0""replace\0""delete\0""list\0""show\0""lst\0""flush\0";
        int cmd = 2;
+
+       INIT_G();
+
        if (*argv) {
                cmd = index_in_substrings(commands, *argv);
                if (cmd < 0)
index 151d3d109bcc83378ff128bb1a99ca3586e89a69..d2028b7b682112eb0197db1d0846536ca3b0f1f8 100644 (file)
@@ -42,6 +42,7 @@ struct filter_t {
 typedef struct filter_t filter_t;
 
 #define G_filter (*(filter_t*)bb_common_bufsiz1)
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
 
 static int flush_update(void)
 {
@@ -339,6 +340,8 @@ int FAST_FUNC do_ipneigh(char **argv)
                /*0-1*/ "show\0"  "flush\0";
        int command_num;
 
+       INIT_G();
+
        if (!*argv)
                return ipneigh_list_or_flush(argv, 0);
 
index 34d4f4758a40b3b4c2e51b6c06a021cae0f677b9..e674e9a0d914b0c8df01a6c5942135a9324dc26d 100644 (file)
@@ -45,6 +45,7 @@ struct filter_t {
 typedef struct filter_t filter_t;
 
 #define G_filter (*(filter_t*)bb_common_bufsiz1)
+#define INIT_G() do { setup_common_bufsiz(); } while (0)
 
 static int flush_update(void)
 {
@@ -903,6 +904,8 @@ int FAST_FUNC do_iproute(char **argv)
        unsigned flags = 0;
        int cmd = RTM_NEWROUTE;
 
+       INIT_G();
+
        if (!*argv)
                return iproute_list_or_flush(argv, 0);
 
index 50edee450d977aea24dd8418eed3f656b1de960d..13a9b48a89b588b5a479a1d76739b0f732d4679d 100644 (file)
@@ -239,6 +239,8 @@ int nc_main(int argc, char **argv)
        FD_SET(cfd, &readfds);
        FD_SET(STDIN_FILENO, &readfds);
 
+#define iobuf bb_common_bufsiz1
+       setup_common_bufsiz();
        for (;;) {
                int fd;
                int ofd;
@@ -249,7 +251,6 @@ int nc_main(int argc, char **argv)
                if (select(cfd + 1, &testfds, NULL, NULL, NULL) < 0)
                        bb_perror_msg_and_die("select");
 
-#define iobuf bb_common_bufsiz1
                fd = STDIN_FILENO;
                while (1) {
                        if (FD_ISSET(fd, &testfds)) {
index efa3d553d71134988daccf5af023a9d1029a25ab..3eac2d3b2cb8a48e17cd6f56e90e49d19314091d 100644 (file)
@@ -109,16 +109,15 @@ struct globals {
 #define proc_meminfo       (G.proc_meminfo      )
 #define proc_diskstats     (G.proc_diskstats    )
 #define proc_sys_fs_filenr (G.proc_sys_fs_filenr)
+#define outbuf bb_common_bufsiz1
 #define INIT_G() do { \
+       setup_common_bufsiz(); \
        SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
        cur_outbuf = outbuf; \
        G.final_char = '\n'; \
        G.deltanz = G.delta = 1000000; \
 } while (0)
 
-#define        outbuf bb_common_bufsiz1
-#define sizeof_outbuf COMMON_BUFSIZE
-
 static inline void reset_outbuf(void)
 {
        cur_outbuf = outbuf;
@@ -141,7 +140,7 @@ static void print_outbuf(void)
 static void put(const char *s)
 {
        char *p = cur_outbuf;
-       int sz = outbuf + sizeof_outbuf - p;
+       int sz = outbuf + COMMON_BUFSIZE - p;
        while (*s && --sz >= 0)
                *p++ = *s++;
        cur_outbuf = p;
@@ -149,7 +148,7 @@ static void put(const char *s)
 
 static void put_c(char c)
 {
-       if (cur_outbuf < outbuf + sizeof_outbuf)
+       if (cur_outbuf < outbuf + COMMON_BUFSIZE)
                *cur_outbuf++ = c;
 }
 
index 09efdb69563bc113d224f1ed9b1d93db73ebcc25..7cae81cb2cd725f2198f35c43dc899bca210bd32 100644 (file)
@@ -234,7 +234,9 @@ struct globals {
 #define blocked_sigset (G.blocked_sigset)
 #define fl_flag_0      (G.fl_flag_0     )
 #define dirn           (G.dirn          )
+#define line bb_common_bufsiz1
 #define INIT_G() do { \
+       setup_common_bufsiz(); \
        SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
        linemax = 1000; \
        /*buflen = 1024;*/ \
@@ -242,8 +244,6 @@ struct globals {
        replace = ""; \
 } while (0)
 
-#define line bb_common_bufsiz1
-
 
 #define FATAL "fatal: "
 #define WARNING "warning: "
index 845c49a5ea6844db01608011b60e8780a57ef57f..4db72110d9d5e51c3a3f38c5b7cfb6ab38463240 100644 (file)
@@ -146,10 +146,9 @@ static void klogd_close(void)
 
 #endif
 
-#define        log_buffer bb_common_bufsiz1
-#define sizeof_log_buffer COMMON_BUFSIZE
+#define log_buffer bb_common_bufsiz1
 enum {
-       KLOGD_LOGBUF_SIZE = sizeof_log_buffer,
+       KLOGD_LOGBUF_SIZE = COMMON_BUFSIZE,
        OPT_LEVEL      = (1 << 0),
        OPT_FOREGROUND = (1 << 1),
 };
@@ -175,6 +174,8 @@ int klogd_main(int argc UNUSED_PARAM, char **argv)
        int opt;
        int used;
 
+       setup_common_bufsiz();
+
        opt = getopt32(argv, "c:n", &opt_c);
        if (opt & OPT_LEVEL) {
                /* Valid levels are between 1 and 8 */
index b3ca8570323d70da579e7d57fa05ccafebee6dd8..f9eafeb259d85400063ead816324f9278b42ed29 100644 (file)
@@ -99,6 +99,8 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
        int opt;
        int i = 0;
 
+       setup_common_bufsiz();
+
        /* Fill out the name string early (may be overwritten later) */
        str_t = uid2uname_utoa(geteuid());
 
index 6195161bcc8b6ca60909a52b753868b307bbe766..86475c1f145da4e3ae36f937e3a8a7782048dbb4 100644 (file)
@@ -109,12 +109,12 @@ int script_main(int argc UNUSED_PARAM, char **argv)
 
        if (child_pid) {
                /* parent */
-#define        buf bb_common_bufsiz1
-#define sizeof_buf COMMON_BUFSIZE
                struct pollfd pfd[2];
                int outfd, count, loop;
                double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0;
                smallint fd_count = 2;
+#define buf bb_common_bufsiz1
+               setup_common_bufsiz();
 
                outfd = xopen(fname, mode);
                pfd[0].fd = pty;
@@ -136,7 +136,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                        }
                        if (pfd[0].revents) {
                                errno = 0;
-                               count = safe_read(pty, buf, sizeof_buf);
+                               count = safe_read(pty, buf, COMMON_BUFSIZE);
                                if (count <= 0 && errno != EAGAIN) {
                                        /* err/eof from pty: exit */
                                        goto restore;
@@ -159,7 +159,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                                }
                        }
                        if (pfd[1].revents) {
-                               count = safe_read(STDIN_FILENO, buf, sizeof_buf);
+                               count = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE);
                                if (count <= 0) {
                                        /* err/eof from stdin: don't read stdin anymore */
                                        pfd[1].revents = 0;
@@ -178,7 +178,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
                 * (util-linux's script doesn't do this. buggy :) */
                loop = 999;
                /* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */
-               while (--loop && (count = safe_read(pty, buf, sizeof_buf)) > 0) {
+               while (--loop && (count = safe_read(pty, buf, COMMON_BUFSIZE)) > 0) {
                        full_write(STDOUT_FILENO, buf, count);
                        full_write(outfd, buf, count);
                }
index be0300394dd8b7fb667e8865fa6e83738aacc9ab..91da69674de1d1320c8d9f7f25dabe2275b81be6 100644 (file)
@@ -103,6 +103,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
                if (opt & OPT_ALL)
                        bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file);
        } else {
+               setup_common_bufsiz();
                while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) {
                        /* Match fstype if passed */
                        if (!match_fstype(&me, fstype))