aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/chat.c1
-rw-r--r--miscutils/conspy.c6
-rw-r--r--miscutils/crond.c3
-rw-r--r--miscutils/dc.c3
-rw-r--r--miscutils/fbsplash.c6
-rw-r--r--miscutils/hdparm.c3
-rw-r--r--miscutils/i2c_tools.c1
-rw-r--r--miscutils/inotifyd.c6
-rw-r--r--miscutils/less.c6
-rw-r--r--miscutils/microcom.c6
10 files changed, 28 insertions, 13 deletions
diff --git a/miscutils/chat.c b/miscutils/chat.c
index bd2abc24a..25850dd20 100644
--- a/miscutils/chat.c
+++ b/miscutils/chat.c
@@ -17,6 +17,7 @@
17//usage: "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'" 17//usage: "chat '' ATZ OK ATD123456 CONNECT '' ogin: pppuser word: ppppass '~'"
18 18
19#include "libbb.h" 19#include "libbb.h"
20#include "common_bufsiz.h"
20 21
21// default timeout: 45 sec 22// default timeout: 45 sec
22#define DEFAULT_CHAT_TIMEOUT 45*1000 23#define DEFAULT_CHAT_TIMEOUT 45*1000
diff --git a/miscutils/conspy.c b/miscutils/conspy.c
index 1a46a4340..0d96a5f9a 100644
--- a/miscutils/conspy.c
+++ b/miscutils/conspy.c
@@ -42,6 +42,7 @@
42//usage: "\n -y LINE Starting line" 42//usage: "\n -y LINE Starting line"
43 43
44#include "libbb.h" 44#include "libbb.h"
45#include "common_bufsiz.h"
45#include <sys/kd.h> 46#include <sys/kd.h>
46 47
47#define ESC "\033" 48#define ESC "\033"
@@ -363,7 +364,8 @@ int conspy_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
363int conspy_main(int argc UNUSED_PARAM, char **argv) 364int conspy_main(int argc UNUSED_PARAM, char **argv)
364{ 365{
365 char tty_name[sizeof(DEV_TTY "NN")]; 366 char tty_name[sizeof(DEV_TTY "NN")];
366#define keybuf bb_common_bufsiz1 367#define keybuf bb_common_bufsiz1
368#define sizeof_keybuf COMMON_BUFSIZE
367 struct termios termbuf; 369 struct termios termbuf;
368 unsigned opts; 370 unsigned opts;
369 unsigned ttynum; 371 unsigned ttynum;
@@ -513,7 +515,7 @@ int conspy_main(int argc UNUSED_PARAM, char **argv)
513 default: 515 default:
514 // Read the keys pressed 516 // Read the keys pressed
515 k = keybuf + G.key_count; 517 k = keybuf + G.key_count;
516 bytes_read = read(G.kbd_fd, k, sizeof(keybuf) - G.key_count); 518 bytes_read = read(G.kbd_fd, k, sizeof_keybuf - G.key_count);
517 if (bytes_read < 0) 519 if (bytes_read < 0)
518 goto abort; 520 goto abort;
519 521
diff --git a/miscutils/crond.c b/miscutils/crond.c
index eb327f855..8536d43c5 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -60,6 +60,7 @@
60//usage: "\n -c DIR Cron dir. Default:"CONFIG_FEATURE_CROND_DIR"/crontabs" 60//usage: "\n -c DIR Cron dir. Default:"CONFIG_FEATURE_CROND_DIR"/crontabs"
61 61
62#include "libbb.h" 62#include "libbb.h"
63#include "common_bufsiz.h"
63#include <syslog.h> 64#include <syslog.h>
64 65
65/* glibc frees previous setenv'ed value when we do next setenv() 66/* glibc frees previous setenv'ed value when we do next setenv()
@@ -140,7 +141,7 @@ struct globals {
140 char *env_var_logname; 141 char *env_var_logname;
141#endif 142#endif
142} FIX_ALIASING; 143} FIX_ALIASING;
143#define G (*(struct globals*)&bb_common_bufsiz1) 144#define G (*(struct globals*)bb_common_bufsiz1)
144#define INIT_G() do { \ 145#define INIT_G() do { \
145 G.log_level = 8; \ 146 G.log_level = 8; \
146 G.crontab_dir_name = CRONTABS; \ 147 G.crontab_dir_name = CRONTABS; \
diff --git a/miscutils/dc.c b/miscutils/dc.c
index 9c74172ba..3fbb89f5b 100644
--- a/miscutils/dc.c
+++ b/miscutils/dc.c
@@ -4,6 +4,7 @@
4 */ 4 */
5 5
6#include "libbb.h" 6#include "libbb.h"
7#include "common_bufsiz.h"
7#include <math.h> 8#include <math.h>
8 9
9//usage:#define dc_trivial_usage 10//usage:#define dc_trivial_usage
@@ -47,7 +48,7 @@ struct globals {
47 double stack[1]; 48 double stack[1];
48} FIX_ALIASING; 49} FIX_ALIASING;
49enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(double) }; 50enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(double) };
50#define G (*(struct globals*)&bb_common_bufsiz1) 51#define G (*(struct globals*)bb_common_bufsiz1)
51#define pointer (G.pointer ) 52#define pointer (G.pointer )
52#define base (G.base ) 53#define base (G.base )
53#define stack (G.stack ) 54#define stack (G.stack )
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c
index 9557c41db..b26ad2c15 100644
--- a/miscutils/fbsplash.c
+++ b/miscutils/fbsplash.c
@@ -34,6 +34,7 @@
34//usage: "\n commands: 'NN' (% for progress bar) or 'exit'" 34//usage: "\n commands: 'NN' (% for progress bar) or 'exit'"
35 35
36#include "libbb.h" 36#include "libbb.h"
37#include "common_bufsiz.h"
37#include <linux/fb.h> 38#include <linux/fb.h>
38 39
39/* If you want logging messages on /tmp/fbsplash.log... */ 40/* If you want logging messages on /tmp/fbsplash.log... */
@@ -372,11 +373,12 @@ static void fb_drawimage(void)
372 * - A raster of Width * Height pixels in triplets of rgb 373 * - A raster of Width * Height pixels in triplets of rgb
373 * in pure binary by 1 or 2 bytes. (we support only 1 byte) 374 * in pure binary by 1 or 2 bytes. (we support only 1 byte)
374 */ 375 */
375#define concat_buf bb_common_bufsiz1 376#define concat_buf bb_common_bufsiz1
377#define sizeof_concat_buf COMMON_BUFSIZE
376 read_ptr = concat_buf; 378 read_ptr = concat_buf;
377 while (1) { 379 while (1) {
378 int w, h, max_color_val; 380 int w, h, max_color_val;
379 int rem = concat_buf + sizeof(concat_buf) - read_ptr; 381 int rem = concat_buf + sizeof_concat_buf - read_ptr;
380 if (rem < 2 382 if (rem < 2
381 || fgets(read_ptr, rem, theme_file) == NULL 383 || fgets(read_ptr, rem, theme_file) == NULL
382 ) { 384 ) {
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 8e201ac35..9e141de2f 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -63,6 +63,7 @@
63//usage: "\n -z Reread partition table" 63//usage: "\n -z Reread partition table"
64 64
65#include "libbb.h" 65#include "libbb.h"
66#include "common_bufsiz.h"
66/* must be _after_ libbb.h: */ 67/* must be _after_ libbb.h: */
67#include <linux/hdreg.h> 68#include <linux/hdreg.h>
68#include <sys/mount.h> 69#include <sys/mount.h>
@@ -367,7 +368,7 @@ struct globals {
367 unsigned char flushcache[4] = { WIN_FLUSHCACHE, 0, 0, 0 }; 368 unsigned char flushcache[4] = { WIN_FLUSHCACHE, 0, 0, 0 };
368#endif 369#endif
369} FIX_ALIASING; 370} FIX_ALIASING;
370#define G (*(struct globals*)&bb_common_bufsiz1) 371#define G (*(struct globals*)bb_common_bufsiz1)
371#define get_identity (G.get_identity ) 372#define get_identity (G.get_identity )
372#define get_geom (G.get_geom ) 373#define get_geom (G.get_geom )
373#define do_flush (G.do_flush ) 374#define do_flush (G.do_flush )
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index aa1c7c5cc..57bb72ae7 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -60,6 +60,7 @@
60 */ 60 */
61 61
62#include "libbb.h" 62#include "libbb.h"
63#include "common_bufsiz.h"
63 64
64#include <linux/i2c.h> 65#include <linux/i2c.h>
65#include <linux/i2c-dev.h> 66#include <linux/i2c-dev.h>
diff --git a/miscutils/inotifyd.c b/miscutils/inotifyd.c
index 908d657fd..1d28e8f99 100644
--- a/miscutils/inotifyd.c
+++ b/miscutils/inotifyd.c
@@ -56,6 +56,7 @@
56//usage: "\nWhen x event happens for all FILEs, inotifyd exits." 56//usage: "\nWhen x event happens for all FILEs, inotifyd exits."
57 57
58#include "libbb.h" 58#include "libbb.h"
59#include "common_bufsiz.h"
59#include <sys/inotify.h> 60#include <sys/inotify.h>
60 61
61static const char mask_names[] ALIGN1 = 62static const char mask_names[] ALIGN1 =
@@ -162,8 +163,9 @@ int inotifyd_main(int argc, char **argv)
162 // read out all pending events 163 // read out all pending events
163 // (NB: len must be int, not ssize_t or long!) 164 // (NB: len must be int, not ssize_t or long!)
164 xioctl(pfd.fd, FIONREAD, &len); 165 xioctl(pfd.fd, FIONREAD, &len);
165#define eventbuf bb_common_bufsiz1 166#define eventbuf bb_common_bufsiz1
166 ie = buf = (len <= sizeof(eventbuf)) ? eventbuf : xmalloc(len); 167#define sizeof_eventbuf COMMON_BUFSIZE
168 ie = buf = (len <= sizeof_eventbuf) ? eventbuf : xmalloc(len);
167 len = full_read(pfd.fd, buf, len); 169 len = full_read(pfd.fd, buf, len);
168 // process events. N.B. events may vary in length 170 // process events. N.B. events may vary in length
169 while (len > 0) { 171 while (len > 0) {
diff --git a/miscutils/less.c b/miscutils/less.c
index ccdb15fdc..94ecf1686 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -127,6 +127,7 @@
127#include <sched.h> /* sched_yield() */ 127#include <sched.h> /* sched_yield() */
128 128
129#include "libbb.h" 129#include "libbb.h"
130#include "common_bufsiz.h"
130#if ENABLE_FEATURE_LESS_REGEXP 131#if ENABLE_FEATURE_LESS_REGEXP
131#include "xregex.h" 132#include "xregex.h"
132#endif 133#endif
@@ -439,7 +440,8 @@ static int at_end(void)
439 */ 440 */
440static void read_lines(void) 441static void read_lines(void)
441{ 442{
442#define readbuf bb_common_bufsiz1 443#define readbuf bb_common_bufsiz1
444#define sizeof_readbuf COMMON_BUFSIZE
443 char *current_line, *p; 445 char *current_line, *p;
444 int w = width; 446 int w = width;
445 char last_terminated = terminated; 447 char last_terminated = terminated;
@@ -480,7 +482,7 @@ static void read_lines(void)
480 time_t t; 482 time_t t;
481 483
482 errno = 0; 484 errno = 0;
483 eof_error = safe_read(STDIN_FILENO, readbuf, sizeof(readbuf)); 485 eof_error = safe_read(STDIN_FILENO, readbuf, sizeof_readbuf);
484 if (errno != EAGAIN) 486 if (errno != EAGAIN)
485 break; 487 break;
486 t = time(NULL); 488 t = time(NULL);
diff --git a/miscutils/microcom.c b/miscutils/microcom.c
index 5e29a1acd..5eb2e6743 100644
--- a/miscutils/microcom.c
+++ b/miscutils/microcom.c
@@ -19,6 +19,7 @@
19//usage: "\n -X Disable special meaning of NUL and Ctrl-X from stdin" 19//usage: "\n -X Disable special meaning of NUL and Ctrl-X from stdin"
20 20
21#include "libbb.h" 21#include "libbb.h"
22#include "common_bufsiz.h"
22 23
23// set raw tty mode 24// set raw tty mode
24static void xget1(int fd, struct termios *t, struct termios *oldt) 25static void xget1(int fd, struct termios *t, struct termios *oldt)
@@ -155,10 +156,11 @@ int microcom_main(int argc UNUSED_PARAM, char **argv)
155skip_write: ; 156skip_write: ;
156 } 157 }
157 if (pfd[0].revents) { 158 if (pfd[0].revents) {
158#define iobuf bb_common_bufsiz1 159#define iobuf bb_common_bufsiz1
160#define sizeof_iobuf COMMON_BUFSIZE
159 ssize_t len; 161 ssize_t len;
160 // read from device -> write to stdout 162 // read from device -> write to stdout
161 len = safe_read(sfd, iobuf, sizeof(iobuf)); 163 len = safe_read(sfd, iobuf, sizeof_iobuf);
162 if (len > 0) 164 if (len > 0)
163 full_write(STDOUT_FILENO, iobuf, len); 165 full_write(STDOUT_FILENO, iobuf, len);
164 else { 166 else {