*: hopefully all setup_common_bufsiz() are in place

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2016-04-21 18:38:51 +02:00
parent 47cfbf32fd
commit 9de2e5a222
29 changed files with 83 additions and 55 deletions

View File

@ -162,6 +162,7 @@
#define block_buf bb_common_bufsiz1 #define block_buf bb_common_bufsiz1
#define INIT_G() do { setup_common_bufsiz(); } while (0)
#if ENABLE_FEATURE_TAR_CREATE #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 #if ENABLE_FEATURE_TAR_LONG_OPTIONS && ENABLE_FEATURE_TAR_FROM
llist_t *excludes = NULL; llist_t *excludes = NULL;
#endif #endif
INIT_G();
/* Initialise default values */ /* Initialise default values */
tar_handle = init_handle(); tar_handle = init_handle();

View File

@ -38,6 +38,7 @@ int dumpkmap_main(int argc UNUSED_PARAM, char **argv)
struct kbentry ke; struct kbentry ke;
int i, j, fd; int i, j, fd;
#define flags bb_common_bufsiz1 #define flags bb_common_bufsiz1
setup_common_bufsiz();
/* When user accidentally runs "dumpkmap FILE" /* When user accidentally runs "dumpkmap FILE"
* instead of "dumpkmap >FILE", we'd dump binary stuff to tty. * instead of "dumpkmap >FILE", we'd dump binary stuff to tty.

View File

@ -49,6 +49,9 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
/* Read from stdin if there's nothing else to do. */ /* Read from stdin if there's nothing else to do. */
if (!argv[0]) if (!argv[0])
*--argv = (char*)"-"; *--argv = (char*)"-";
#define read_buf bb_common_bufsiz1
setup_common_bufsiz();
do { do {
fd = open_or_warn_stdin(*argv); fd = open_or_warn_stdin(*argv);
if (fd < 0) { if (fd < 0) {
@ -58,7 +61,6 @@ int catv_main(int argc UNUSED_PARAM, char **argv)
for (;;) { for (;;) {
int i, res; int i, res;
#define read_buf bb_common_bufsiz1
res = read(fd, read_buf, COMMON_BUFSIZE); res = read(fd, read_buf, COMMON_BUFSIZE);
if (res < 0) if (res < 0)
retval = EXIT_FAILURE; retval = EXIT_FAILURE;

View File

@ -33,6 +33,7 @@ int cksum_main(int argc UNUSED_PARAM, char **argv)
argv++; argv++;
#endif #endif
setup_common_bufsiz();
do { do {
int fd = open_or_warn_stdin(*argv ? *argv : bb_msg_standard_input); 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; crc = 0;
length = 0; length = 0;
#define read_buf bb_common_bufsiz1 #define read_buf bb_common_bufsiz1
#define sizeof_read_buf COMMON_BUFSIZE while ((bytes_read = safe_read(fd, read_buf, COMMON_BUFSIZE)) > 0) {
while ((bytes_read = safe_read(fd, read_buf, sizeof_read_buf)) > 0) {
length += bytes_read; length += bytes_read;
crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table); crc = crc32_block_endian1(crc, read_buf, bytes_read, crc32_table);
} }

View File

@ -368,8 +368,8 @@ int date_main(int argc UNUSED_PARAM, char **argv)
} }
#endif #endif
#define date_buf bb_common_bufsiz1 #define date_buf bb_common_bufsiz1
#define sizeof_date_buf COMMON_BUFSIZE setup_common_bufsiz();
if (*fmt_dt2str == '\0') { if (*fmt_dt2str == '\0') {
/* With no format string, just print a blank line */ /* With no format string, just print a blank line */
date_buf[0] = '\0'; 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"; fmt_dt2str = (char*)"%Y.%m.%d-%H:%M:%S";
} }
/* Generate output string */ /* 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); puts(date_buf);

View File

@ -79,6 +79,8 @@ int split_main(int argc UNUSED_PARAM, char **argv)
ssize_t bytes_read, to_write; ssize_t bytes_read, to_write;
char *src; char *src;
setup_common_bufsiz();
opt_complementary = "?2:a+"; /* max 2 args; -a N */ opt_complementary = "?2:a+"; /* max 2 args; -a N */
opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len); opt = getopt32(argv, "l:b:a:", &count_p, &count_p, &suffix_len);

View File

@ -158,10 +158,9 @@ static const char *human_time(time_t t)
/* coreutils 6.3 compat: */ /* coreutils 6.3 compat: */
/*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/ /*static char buf[sizeof("YYYY-MM-DD HH:MM:SS.000000000")] ALIGN1;*/
#define buf bb_common_bufsiz1 #define buf bb_common_bufsiz1
#define sizeof_buf COMMON_BUFSIZE setup_common_bufsiz();
strcpy(strftime_YYYYMMDDHHMMSS(buf, COMMON_BUFSIZE, &t), ".000000000");
strcpy(strftime_YYYYMMDDHHMMSS(buf, sizeof_buf, &t), ".000000000");
return buf; return buf;
#undef buf #undef buf
} }

View File

@ -31,12 +31,14 @@ enum { SUM_BSD, PRINT_NAME, SUM_SYSV };
/* Return 1 if successful. */ /* Return 1 if successful. */
static unsigned sum_file(const char *file, unsigned type) static unsigned sum_file(const char *file, unsigned type)
{ {
#define buf bb_common_bufsiz1
unsigned long long total_bytes = 0; unsigned long long total_bytes = 0;
int fd, r; int fd, r;
/* The sum of all the input bytes, modulo (UINT_MAX + 1). */ /* The sum of all the input bytes, modulo (UINT_MAX + 1). */
unsigned s = 0; unsigned s = 0;
#define buf bb_common_bufsiz1
setup_common_bufsiz();
fd = open_or_warn_stdin(file); fd = open_or_warn_stdin(file);
if (fd == -1) if (fd == -1)
return 0; return 0;

View File

@ -37,8 +37,8 @@ int tee_main(int argc, char **argv)
//TODO: make unconditional //TODO: make unconditional
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO #if ENABLE_FEATURE_TEE_USE_BLOCK_IO
ssize_t c; ssize_t c;
# define buf bb_common_bufsiz1 # define buf bb_common_bufsiz1
# define sizeof_buf COMMON_BUFSIZE setup_common_bufsiz();
#else #else
int c; int c;
#endif #endif
@ -81,7 +81,7 @@ int tee_main(int argc, char **argv)
/* names[0] will be filled later */ /* names[0] will be filled later */
#if ENABLE_FEATURE_TEE_USE_BLOCK_IO #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; fp = files;
do do
fwrite(buf, 1, c, *fp); fwrite(buf, 1, c, *fp);

View File

@ -749,6 +749,7 @@ static int diffreg(char *file[2])
fp[i] = fdopen(fd, "r"); fp[i] = fdopen(fd, "r");
} }
setup_common_bufsiz();
while (1) { while (1) {
const size_t sz = COMMON_BUFSIZE / 2; const size_t sz = COMMON_BUFSIZE / 2;
char *const buf0 = bb_common_bufsiz1; char *const buf0 = bb_common_bufsiz1;

View File

@ -33,12 +33,11 @@ typedef struct LINE {
} LINE; } LINE;
#define searchString bb_common_bufsiz1 #define searchString bb_common_bufsiz1
#define sizeof_searchString COMMON_BUFSIZE
enum { enum {
USERSIZE = sizeof_searchString > 1024 ? 1024 USERSIZE = COMMON_BUFSIZE > 1024 ? 1024
: sizeof_searchString - 1, /* max line length typed in by user */ : COMMON_BUFSIZE - 1, /* max line length typed in by user */
INITBUF_SIZE = 1024, /* initial buffer size */ INITBUF_SIZE = 1024, /* initial buffer size */
}; };
@ -68,6 +67,7 @@ struct globals {
#define lines (G.lines ) #define lines (G.lines )
#define marks (G.marks ) #define marks (G.marks )
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
} while (0) } while (0)

View File

@ -286,9 +286,10 @@ int chat_main(int argc UNUSED_PARAM, char **argv)
&& poll(&pfd, 1, timeout) > 0 && poll(&pfd, 1, timeout) > 0
&& (pfd.revents & POLLIN) && (pfd.revents & POLLIN)
) { ) {
#define buf bb_common_bufsiz1
llist_t *l; llist_t *l;
ssize_t delta; ssize_t delta;
#define buf bb_common_bufsiz1
setup_common_bufsiz();
// read next char from device // read next char from device
if (safe_read(STDIN_FILENO, buf+buf_len, 1) > 0) { if (safe_read(STDIN_FILENO, buf+buf_len, 1) > 0) {

View File

@ -364,8 +364,6 @@ int conspy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int conspy_main(int argc UNUSED_PARAM, char **argv) int conspy_main(int argc UNUSED_PARAM, char **argv)
{ {
char tty_name[sizeof(DEV_TTY "NN")]; char tty_name[sizeof(DEV_TTY "NN")];
#define keybuf bb_common_bufsiz1
#define sizeof_keybuf COMMON_BUFSIZE
struct termios termbuf; struct termios termbuf;
unsigned opts; unsigned opts;
unsigned ttynum; unsigned ttynum;
@ -384,6 +382,9 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
applet_long_options = getopt_longopts; applet_long_options = getopt_longopts;
#endif #endif
#define keybuf bb_common_bufsiz1
setup_common_bufsiz();
INIT_G(); INIT_G();
strcpy(G.vcsa_name, DEV_VCSA); strcpy(G.vcsa_name, DEV_VCSA);
@ -515,7 +516,7 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
default: default:
// Read the keys pressed // Read the keys pressed
k = keybuf + G.key_count; 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) if (bytes_read < 0)
goto abort; goto abort;

View File

@ -373,12 +373,13 @@ static void fb_drawimage(void)
* - A raster of Width * Height pixels in triplets of rgb * - A raster of Width * Height pixels in triplets of rgb
* in pure binary by 1 or 2 bytes. (we support only 1 byte) * in pure binary by 1 or 2 bytes. (we support only 1 byte)
*/ */
#define concat_buf bb_common_bufsiz1 #define concat_buf bb_common_bufsiz1
#define sizeof_concat_buf COMMON_BUFSIZE setup_common_bufsiz();
read_ptr = concat_buf; read_ptr = concat_buf;
while (1) { while (1) {
int w, h, max_color_val; 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 if (rem < 2
|| fgets(read_ptr, rem, theme_file) == NULL || fgets(read_ptr, rem, theme_file) == NULL
) { ) {

View File

@ -162,10 +162,10 @@ int inotifyd_main(int argc, char **argv)
// read out all pending events // read out all pending events
// (NB: len must be int, not ssize_t or long!) // (NB: len must be int, not ssize_t or long!)
#define eventbuf bb_common_bufsiz1
setup_common_bufsiz();
xioctl(pfd.fd, FIONREAD, &len); xioctl(pfd.fd, FIONREAD, &len);
#define eventbuf bb_common_bufsiz1 ie = buf = (len <= COMMON_BUFSIZE) ? eventbuf : xmalloc(len);
#define sizeof_eventbuf COMMON_BUFSIZE
ie = buf = (len <= sizeof_eventbuf) ? eventbuf : xmalloc(len);
len = full_read(pfd.fd, buf, len); len = full_read(pfd.fd, buf, len);
// process events. N.B. events may vary in length // process events. N.B. events may vary in length
while (len > 0) { while (len > 0) {

View File

@ -440,8 +440,6 @@ static int at_end(void)
*/ */
static void read_lines(void) static void read_lines(void)
{ {
#define readbuf bb_common_bufsiz1
#define sizeof_readbuf COMMON_BUFSIZE
char *current_line, *p; char *current_line, *p;
int w = width; int w = width;
char last_terminated = terminated; char last_terminated = terminated;
@ -451,6 +449,9 @@ static void read_lines(void)
unsigned old_max_fline = max_fline; unsigned old_max_fline = max_fline;
#endif #endif
#define readbuf bb_common_bufsiz1
setup_common_bufsiz();
/* (careful: max_fline can be -1) */ /* (careful: max_fline can be -1) */
if (max_fline + 1 > MAXLINES) if (max_fline + 1 > MAXLINES)
return; return;
@ -482,7 +483,7 @@ static void read_lines(void)
time_t t; time_t t;
errno = 0; errno = 0;
eof_error = safe_read(STDIN_FILENO, readbuf, sizeof_readbuf); eof_error = safe_read(STDIN_FILENO, readbuf, COMMON_BUFSIZE);
if (errno != EAGAIN) if (errno != EAGAIN)
break; break;
t = time(NULL); t = time(NULL);

View File

@ -156,11 +156,11 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
skip_write: ; skip_write: ;
} }
if (pfd[0].revents) { if (pfd[0].revents) {
#define iobuf bb_common_bufsiz1
#define sizeof_iobuf COMMON_BUFSIZE
ssize_t len; ssize_t len;
#define iobuf bb_common_bufsiz1
setup_common_bufsiz();
// read from device -> write to stdout // read from device -> write to stdout
len = safe_read(sfd, iobuf, sizeof_iobuf); len = safe_read(sfd, iobuf, COMMON_BUFSIZE);
if (len > 0) if (len > 0)
full_write(STDOUT_FILENO, iobuf, len); full_write(STDOUT_FILENO, iobuf, len);
else { else {

View File

@ -370,6 +370,7 @@ enum {
# define content_gzip 0 # define content_gzip 0
#endif #endif
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \
IF_FEATURE_HTTPD_RANGES(range_start = -1;) \ IF_FEATURE_HTTPD_RANGES(range_start = -1;) \

View File

@ -29,8 +29,7 @@ typedef struct identd_buf_t {
char buf[64 - sizeof(int)]; char buf[64 - sizeof(int)];
} identd_buf_t; } identd_buf_t;
#define bogouser bb_common_bufsiz1 #define bogouser bb_common_bufsiz1
#define sizeof_bogouser COMMON_BUFSIZE
static int new_peer(isrv_state_t *state, int fd) 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; unsigned opt;
int fd; int fd;
setup_common_bufsiz();
opt = getopt32(argv, "fiwb:", &bind_address); opt = getopt32(argv, "fiwb:", &bind_address);
strcpy(bogouser, "nobody"); strcpy(bogouser, "nobody");
if (argv[optind]) 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 */ /* Daemonize if no -f and no -i and no -w */
if (!(opt & OPT_fiw)) if (!(opt & OPT_fiw))

View File

@ -41,7 +41,7 @@ struct filter_t {
typedef struct filter_t filter_t; typedef struct filter_t filter_t;
#define G_filter (*(filter_t*)bb_common_bufsiz1) #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) 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 */ /* 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"; "add\0""change\0""chg\0""replace\0""delete\0""list\0""show\0""lst\0""flush\0";
int cmd = 2; int cmd = 2;
INIT_G();
if (*argv) { if (*argv) {
cmd = index_in_substrings(commands, *argv); cmd = index_in_substrings(commands, *argv);
if (cmd < 0) if (cmd < 0)

View File

@ -42,6 +42,7 @@ struct filter_t {
typedef struct filter_t filter_t; typedef struct filter_t filter_t;
#define G_filter (*(filter_t*)bb_common_bufsiz1) #define G_filter (*(filter_t*)bb_common_bufsiz1)
#define INIT_G() do { setup_common_bufsiz(); } while (0)
static int flush_update(void) static int flush_update(void)
{ {
@ -339,6 +340,8 @@ int FAST_FUNC do_ipneigh(char **argv)
/*0-1*/ "show\0" "flush\0"; /*0-1*/ "show\0" "flush\0";
int command_num; int command_num;
INIT_G();
if (!*argv) if (!*argv)
return ipneigh_list_or_flush(argv, 0); return ipneigh_list_or_flush(argv, 0);

View File

@ -45,6 +45,7 @@ struct filter_t {
typedef struct filter_t filter_t; typedef struct filter_t filter_t;
#define G_filter (*(filter_t*)bb_common_bufsiz1) #define G_filter (*(filter_t*)bb_common_bufsiz1)
#define INIT_G() do { setup_common_bufsiz(); } while (0)
static int flush_update(void) static int flush_update(void)
{ {
@ -903,6 +904,8 @@ int FAST_FUNC do_iproute(char **argv)
unsigned flags = 0; unsigned flags = 0;
int cmd = RTM_NEWROUTE; int cmd = RTM_NEWROUTE;
INIT_G();
if (!*argv) if (!*argv)
return iproute_list_or_flush(argv, 0); return iproute_list_or_flush(argv, 0);

View File

@ -239,6 +239,8 @@ int nc_main(int argc, char **argv)
FD_SET(cfd, &readfds); FD_SET(cfd, &readfds);
FD_SET(STDIN_FILENO, &readfds); FD_SET(STDIN_FILENO, &readfds);
#define iobuf bb_common_bufsiz1
setup_common_bufsiz();
for (;;) { for (;;) {
int fd; int fd;
int ofd; int ofd;
@ -249,7 +251,6 @@ int nc_main(int argc, char **argv)
if (select(cfd + 1, &testfds, NULL, NULL, NULL) < 0) if (select(cfd + 1, &testfds, NULL, NULL, NULL) < 0)
bb_perror_msg_and_die("select"); bb_perror_msg_and_die("select");
#define iobuf bb_common_bufsiz1
fd = STDIN_FILENO; fd = STDIN_FILENO;
while (1) { while (1) {
if (FD_ISSET(fd, &testfds)) { if (FD_ISSET(fd, &testfds)) {

View File

@ -109,16 +109,15 @@ struct globals {
#define proc_meminfo (G.proc_meminfo ) #define proc_meminfo (G.proc_meminfo )
#define proc_diskstats (G.proc_diskstats ) #define proc_diskstats (G.proc_diskstats )
#define proc_sys_fs_filenr (G.proc_sys_fs_filenr) #define proc_sys_fs_filenr (G.proc_sys_fs_filenr)
#define outbuf bb_common_bufsiz1
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
cur_outbuf = outbuf; \ cur_outbuf = outbuf; \
G.final_char = '\n'; \ G.final_char = '\n'; \
G.deltanz = G.delta = 1000000; \ G.deltanz = G.delta = 1000000; \
} while (0) } while (0)
#define outbuf bb_common_bufsiz1
#define sizeof_outbuf COMMON_BUFSIZE
static inline void reset_outbuf(void) static inline void reset_outbuf(void)
{ {
cur_outbuf = outbuf; cur_outbuf = outbuf;
@ -141,7 +140,7 @@ static void print_outbuf(void)
static void put(const char *s) static void put(const char *s)
{ {
char *p = cur_outbuf; char *p = cur_outbuf;
int sz = outbuf + sizeof_outbuf - p; int sz = outbuf + COMMON_BUFSIZE - p;
while (*s && --sz >= 0) while (*s && --sz >= 0)
*p++ = *s++; *p++ = *s++;
cur_outbuf = p; cur_outbuf = p;
@ -149,7 +148,7 @@ static void put(const char *s)
static void put_c(char c) static void put_c(char c)
{ {
if (cur_outbuf < outbuf + sizeof_outbuf) if (cur_outbuf < outbuf + COMMON_BUFSIZE)
*cur_outbuf++ = c; *cur_outbuf++ = c;
} }

View File

@ -234,7 +234,9 @@ struct globals {
#define blocked_sigset (G.blocked_sigset) #define blocked_sigset (G.blocked_sigset)
#define fl_flag_0 (G.fl_flag_0 ) #define fl_flag_0 (G.fl_flag_0 )
#define dirn (G.dirn ) #define dirn (G.dirn )
#define line bb_common_bufsiz1
#define INIT_G() do { \ #define INIT_G() do { \
setup_common_bufsiz(); \
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
linemax = 1000; \ linemax = 1000; \
/*buflen = 1024;*/ \ /*buflen = 1024;*/ \
@ -242,8 +244,6 @@ struct globals {
replace = ""; \ replace = ""; \
} while (0) } while (0)
#define line bb_common_bufsiz1
#define FATAL "fatal: " #define FATAL "fatal: "
#define WARNING "warning: " #define WARNING "warning: "

View File

@ -146,10 +146,9 @@ static void klogd_close(void)
#endif #endif
#define log_buffer bb_common_bufsiz1 #define log_buffer bb_common_bufsiz1
#define sizeof_log_buffer COMMON_BUFSIZE
enum { enum {
KLOGD_LOGBUF_SIZE = sizeof_log_buffer, KLOGD_LOGBUF_SIZE = COMMON_BUFSIZE,
OPT_LEVEL = (1 << 0), OPT_LEVEL = (1 << 0),
OPT_FOREGROUND = (1 << 1), OPT_FOREGROUND = (1 << 1),
}; };
@ -175,6 +174,8 @@ int klogd_main(int argc UNUSED_PARAM, char **argv)
int opt; int opt;
int used; int used;
setup_common_bufsiz();
opt = getopt32(argv, "c:n", &opt_c); opt = getopt32(argv, "c:n", &opt_c);
if (opt & OPT_LEVEL) { if (opt & OPT_LEVEL) {
/* Valid levels are between 1 and 8 */ /* Valid levels are between 1 and 8 */

View File

@ -99,6 +99,8 @@ int logger_main(int argc UNUSED_PARAM, char **argv)
int opt; int opt;
int i = 0; int i = 0;
setup_common_bufsiz();
/* Fill out the name string early (may be overwritten later) */ /* Fill out the name string early (may be overwritten later) */
str_t = uid2uname_utoa(geteuid()); str_t = uid2uname_utoa(geteuid());

View File

@ -109,12 +109,12 @@ int script_main(int argc UNUSED_PARAM, char **argv)
if (child_pid) { if (child_pid) {
/* parent */ /* parent */
#define buf bb_common_bufsiz1
#define sizeof_buf COMMON_BUFSIZE
struct pollfd pfd[2]; struct pollfd pfd[2];
int outfd, count, loop; int outfd, count, loop;
double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0; double oldtime = ENABLE_SCRIPTREPLAY ? time(NULL) : 0;
smallint fd_count = 2; smallint fd_count = 2;
#define buf bb_common_bufsiz1
setup_common_bufsiz();
outfd = xopen(fname, mode); outfd = xopen(fname, mode);
pfd[0].fd = pty; pfd[0].fd = pty;
@ -136,7 +136,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
} }
if (pfd[0].revents) { if (pfd[0].revents) {
errno = 0; errno = 0;
count = safe_read(pty, buf, sizeof_buf); count = safe_read(pty, buf, COMMON_BUFSIZE);
if (count <= 0 && errno != EAGAIN) { if (count <= 0 && errno != EAGAIN) {
/* err/eof from pty: exit */ /* err/eof from pty: exit */
goto restore; goto restore;
@ -159,7 +159,7 @@ int script_main(int argc UNUSED_PARAM, char **argv)
} }
} }
if (pfd[1].revents) { if (pfd[1].revents) {
count = safe_read(STDIN_FILENO, buf, sizeof_buf); count = safe_read(STDIN_FILENO, buf, COMMON_BUFSIZE);
if (count <= 0) { if (count <= 0) {
/* err/eof from stdin: don't read stdin anymore */ /* err/eof from stdin: don't read stdin anymore */
pfd[1].revents = 0; 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 :) */ * (util-linux's script doesn't do this. buggy :) */
loop = 999; loop = 999;
/* pty is in O_NONBLOCK mode, we exit as soon as buffer is empty */ /* 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(STDOUT_FILENO, buf, count);
full_write(outfd, buf, count); full_write(outfd, buf, count);
} }

View File

@ -103,6 +103,7 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
if (opt & OPT_ALL) if (opt & OPT_ALL)
bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file); bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file);
} else { } else {
setup_common_bufsiz();
while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) { while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) {
/* Match fstype if passed */ /* Match fstype if passed */
if (!match_fstype(&me, fstype)) if (!match_fstype(&me, fstype))