diff options
Diffstat (limited to 'networking')
-rw-r--r-- | networking/arp.c | 3 | ||||
-rw-r--r-- | networking/arping.c | 3 | ||||
-rw-r--r-- | networking/ftpd.c | 3 | ||||
-rw-r--r-- | networking/ftpgetput.c | 3 | ||||
-rw-r--r-- | networking/httpd.c | 10 | ||||
-rw-r--r-- | networking/ifupdown.c | 3 | ||||
-rw-r--r-- | networking/inetd.c | 3 | ||||
-rw-r--r-- | networking/isrv_identd.c | 6 | ||||
-rw-r--r-- | networking/libiproute/ipaddress.c | 3 | ||||
-rw-r--r-- | networking/libiproute/ipneigh.c | 3 | ||||
-rw-r--r-- | networking/libiproute/iproute.c | 3 | ||||
-rw-r--r-- | networking/nc.c | 3 | ||||
-rw-r--r-- | networking/ping.c | 5 | ||||
-rw-r--r-- | networking/slattach.c | 3 | ||||
-rw-r--r-- | networking/tc.c | 3 | ||||
-rw-r--r-- | networking/tcpudp.c | 3 | ||||
-rw-r--r-- | networking/telnet.c | 3 | ||||
-rw-r--r-- | networking/telnetd.c | 3 | ||||
-rw-r--r-- | networking/tftp.c | 6 | ||||
-rw-r--r-- | networking/udhcp/common.h | 1 | ||||
-rw-r--r-- | networking/udhcp/dhcpd.h | 2 | ||||
-rw-r--r-- | networking/udhcp/dhcprelay.c | 2 | ||||
-rw-r--r-- | networking/udhcp/files.c | 46 | ||||
-rw-r--r-- | networking/zcip.c | 3 |
24 files changed, 76 insertions, 50 deletions
diff --git a/networking/arp.c b/networking/arp.c index 0099aa534..5f7818663 100644 --- a/networking/arp.c +++ b/networking/arp.c | |||
@@ -32,6 +32,7 @@ | |||
32 | //usage: "\n -H HWTYPE Hardware address type" | 32 | //usage: "\n -H HWTYPE Hardware address type" |
33 | 33 | ||
34 | #include "libbb.h" | 34 | #include "libbb.h" |
35 | #include "common_bufsiz.h" | ||
35 | #include "inet_common.h" | 36 | #include "inet_common.h" |
36 | 37 | ||
37 | #include <arpa/inet.h> | 38 | #include <arpa/inet.h> |
@@ -69,7 +70,7 @@ struct globals { | |||
69 | const char *device; /* current device */ | 70 | const char *device; /* current device */ |
70 | smallint hw_set; /* flag if hw-type was set (-H) */ | 71 | smallint hw_set; /* flag if hw-type was set (-H) */ |
71 | } FIX_ALIASING; | 72 | } FIX_ALIASING; |
72 | #define G (*(struct globals*)&bb_common_bufsiz1) | 73 | #define G (*(struct globals*)bb_common_bufsiz1) |
73 | #define ap (G.ap ) | 74 | #define ap (G.ap ) |
74 | #define hw (G.hw ) | 75 | #define hw (G.hw ) |
75 | #define device (G.device ) | 76 | #define device (G.device ) |
diff --git a/networking/arping.c b/networking/arping.c index ef205e5e6..52f5ba51f 100644 --- a/networking/arping.c +++ b/networking/arping.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <netpacket/packet.h> | 28 | #include <netpacket/packet.h> |
29 | 29 | ||
30 | #include "libbb.h" | 30 | #include "libbb.h" |
31 | #include "common_bufsiz.h" | ||
31 | 32 | ||
32 | /* We don't expect to see 1000+ seconds delay, unsigned is enough */ | 33 | /* We don't expect to see 1000+ seconds delay, unsigned is enough */ |
33 | #define MONOTONIC_US() ((unsigned)monotonic_us()) | 34 | #define MONOTONIC_US() ((unsigned)monotonic_us()) |
@@ -60,7 +61,7 @@ struct globals { | |||
60 | unsigned brd_recv; | 61 | unsigned brd_recv; |
61 | unsigned req_recv; | 62 | unsigned req_recv; |
62 | } FIX_ALIASING; | 63 | } FIX_ALIASING; |
63 | #define G (*(struct globals*)&bb_common_bufsiz1) | 64 | #define G (*(struct globals*)bb_common_bufsiz1) |
64 | #define src (G.src ) | 65 | #define src (G.src ) |
65 | #define dst (G.dst ) | 66 | #define dst (G.dst ) |
66 | #define me (G.me ) | 67 | #define me (G.me ) |
diff --git a/networking/ftpd.c b/networking/ftpd.c index 8345ae67c..8553a28f5 100644 --- a/networking/ftpd.c +++ b/networking/ftpd.c | |||
@@ -29,6 +29,7 @@ | |||
29 | //usage: "\n DIR Change root to this directory" | 29 | //usage: "\n DIR Change root to this directory" |
30 | 30 | ||
31 | #include "libbb.h" | 31 | #include "libbb.h" |
32 | #include "common_bufsiz.h" | ||
32 | #include <syslog.h> | 33 | #include <syslog.h> |
33 | #include <netinet/tcp.h> | 34 | #include <netinet/tcp.h> |
34 | 35 | ||
@@ -123,7 +124,7 @@ struct globals { | |||
123 | char msg_ok [(sizeof("NNN " MSG_OK ) + 3) & 0xfffc]; | 124 | char msg_ok [(sizeof("NNN " MSG_OK ) + 3) & 0xfffc]; |
124 | char msg_err[(sizeof("NNN " MSG_ERR) + 3) & 0xfffc]; | 125 | char msg_err[(sizeof("NNN " MSG_ERR) + 3) & 0xfffc]; |
125 | } FIX_ALIASING; | 126 | } FIX_ALIASING; |
126 | #define G (*(struct globals*)&bb_common_bufsiz1) | 127 | #define G (*(struct globals*)bb_common_bufsiz1) |
127 | #define INIT_G() do { \ | 128 | #define INIT_G() do { \ |
128 | /* Moved to main */ \ | 129 | /* Moved to main */ \ |
129 | /*strcpy(G.msg_ok + 4, MSG_OK );*/ \ | 130 | /*strcpy(G.msg_ok + 4, MSG_OK );*/ \ |
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index b398bc874..61bc45c4e 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -50,6 +50,7 @@ | |||
50 | //usage: ) | 50 | //usage: ) |
51 | 51 | ||
52 | #include "libbb.h" | 52 | #include "libbb.h" |
53 | #include "common_bufsiz.h" | ||
53 | 54 | ||
54 | struct globals { | 55 | struct globals { |
55 | const char *user; | 56 | const char *user; |
@@ -60,7 +61,7 @@ struct globals { | |||
60 | int do_continue; | 61 | int do_continue; |
61 | char buf[4]; /* actually [BUFSZ] */ | 62 | char buf[4]; /* actually [BUFSZ] */ |
62 | } FIX_ALIASING; | 63 | } FIX_ALIASING; |
63 | #define G (*(struct globals*)&bb_common_bufsiz1) | 64 | #define G (*(struct globals*)bb_common_bufsiz1) |
64 | enum { BUFSZ = COMMON_BUFSIZE - offsetof(struct globals, buf) }; | 65 | enum { BUFSZ = COMMON_BUFSIZE - offsetof(struct globals, buf) }; |
65 | #define user (G.user ) | 66 | #define user (G.user ) |
66 | #define password (G.password ) | 67 | #define password (G.password ) |
diff --git a/networking/httpd.c b/networking/httpd.c index ed15fd883..ef90770ac 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -125,6 +125,7 @@ | |||
125 | //usage: "\n -d STRING URL decode STRING" | 125 | //usage: "\n -d STRING URL decode STRING" |
126 | 126 | ||
127 | #include "libbb.h" | 127 | #include "libbb.h" |
128 | #include "common_bufsiz.h" | ||
128 | #if ENABLE_PAM | 129 | #if ENABLE_PAM |
129 | /* PAM may include <locale.h>. We may need to undefine bbox's stub define: */ | 130 | /* PAM may include <locale.h>. We may need to undefine bbox's stub define: */ |
130 | # undef setlocale | 131 | # undef setlocale |
@@ -307,7 +308,8 @@ struct globals { | |||
307 | Htaccess *script_i; /* config script interpreters */ | 308 | Htaccess *script_i; /* config script interpreters */ |
308 | #endif | 309 | #endif |
309 | char *iobuf; /* [IOBUF_SIZE] */ | 310 | char *iobuf; /* [IOBUF_SIZE] */ |
310 | #define hdr_buf bb_common_bufsiz1 | 311 | #define hdr_buf bb_common_bufsiz1 |
312 | #define sizeof_hdr_buf COMMON_BUFSIZE | ||
311 | char *hdr_ptr; | 313 | char *hdr_ptr; |
312 | int hdr_cnt; | 314 | int hdr_cnt; |
313 | #if ENABLE_FEATURE_HTTPD_ERROR_PAGES | 315 | #if ENABLE_FEATURE_HTTPD_ERROR_PAGES |
@@ -1066,7 +1068,7 @@ static int get_line(void) | |||
1066 | alarm(HEADER_READ_TIMEOUT); | 1068 | alarm(HEADER_READ_TIMEOUT); |
1067 | while (1) { | 1069 | while (1) { |
1068 | if (hdr_cnt <= 0) { | 1070 | if (hdr_cnt <= 0) { |
1069 | hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf)); | 1071 | hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof_hdr_buf); |
1070 | if (hdr_cnt <= 0) | 1072 | if (hdr_cnt <= 0) |
1071 | break; | 1073 | break; |
1072 | hdr_ptr = hdr_buf; | 1074 | hdr_ptr = hdr_buf; |
@@ -1191,9 +1193,9 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post | |||
1191 | /* We expect data, prev data portion is eaten by CGI | 1193 | /* We expect data, prev data portion is eaten by CGI |
1192 | * and there *is* data to read from the peer | 1194 | * and there *is* data to read from the peer |
1193 | * (POSTDATA) */ | 1195 | * (POSTDATA) */ |
1194 | //count = post_len > (int)sizeof(hdr_buf) ? (int)sizeof(hdr_buf) : post_len; | 1196 | //count = post_len > (int)sizeof_hdr_buf ? (int)sizeof_hdr_buf : post_len; |
1195 | //count = safe_read(STDIN_FILENO, hdr_buf, count); | 1197 | //count = safe_read(STDIN_FILENO, hdr_buf, count); |
1196 | count = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf)); | 1198 | count = safe_read(STDIN_FILENO, hdr_buf, sizeof_hdr_buf); |
1197 | if (count > 0) { | 1199 | if (count > 0) { |
1198 | hdr_cnt = count; | 1200 | hdr_cnt = count; |
1199 | hdr_ptr = hdr_buf; | 1201 | hdr_ptr = hdr_buf; |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 2c6db926f..399ff6b5d 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c | |||
@@ -44,6 +44,7 @@ | |||
44 | //usage: "\n -f Force de/configuration" | 44 | //usage: "\n -f Force de/configuration" |
45 | 45 | ||
46 | #include "libbb.h" | 46 | #include "libbb.h" |
47 | #include "common_bufsiz.h" | ||
47 | /* After libbb.h, since it needs sys/types.h on some systems */ | 48 | /* After libbb.h, since it needs sys/types.h on some systems */ |
48 | #include <sys/utsname.h> | 49 | #include <sys/utsname.h> |
49 | #include <fnmatch.h> | 50 | #include <fnmatch.h> |
@@ -129,7 +130,7 @@ struct globals { | |||
129 | const char *startup_PATH; | 130 | const char *startup_PATH; |
130 | char *shell; | 131 | char *shell; |
131 | } FIX_ALIASING; | 132 | } FIX_ALIASING; |
132 | #define G (*(struct globals*)&bb_common_bufsiz1) | 133 | #define G (*(struct globals*)bb_common_bufsiz1) |
133 | #define INIT_G() do { } while (0) | 134 | #define INIT_G() do { } while (0) |
134 | 135 | ||
135 | 136 | ||
diff --git a/networking/inetd.c b/networking/inetd.c index 4f6673b12..aa35ffa2b 100644 --- a/networking/inetd.c +++ b/networking/inetd.c | |||
@@ -170,6 +170,7 @@ | |||
170 | #include <sys/un.h> | 170 | #include <sys/un.h> |
171 | 171 | ||
172 | #include "libbb.h" | 172 | #include "libbb.h" |
173 | #include "common_bufsiz.h" | ||
173 | 174 | ||
174 | #if ENABLE_FEATURE_INETD_RPC | 175 | #if ENABLE_FEATURE_INETD_RPC |
175 | # if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__) | 176 | # if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__) |
@@ -327,7 +328,7 @@ struct globals { | |||
327 | /* Used in next_line(), and as scratch read buffer */ | 328 | /* Used in next_line(), and as scratch read buffer */ |
328 | char line[256]; /* _at least_ 256, see LINE_SIZE */ | 329 | char line[256]; /* _at least_ 256, see LINE_SIZE */ |
329 | } FIX_ALIASING; | 330 | } FIX_ALIASING; |
330 | #define G (*(struct globals*)&bb_common_bufsiz1) | 331 | #define G (*(struct globals*)bb_common_bufsiz1) |
331 | enum { LINE_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line) }; | 332 | enum { LINE_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line) }; |
332 | #define rlim_ofile_cur (G.rlim_ofile_cur ) | 333 | #define rlim_ofile_cur (G.rlim_ofile_cur ) |
333 | #define rlim_ofile (G.rlim_ofile ) | 334 | #define rlim_ofile (G.rlim_ofile ) |
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c index 252c8aba9..f63ed8ee4 100644 --- a/networking/isrv_identd.c +++ b/networking/isrv_identd.c | |||
@@ -18,6 +18,7 @@ | |||
18 | //usage: "\n STRING Ident answer string (default: nobody)" | 18 | //usage: "\n STRING Ident answer string (default: nobody)" |
19 | 19 | ||
20 | #include "libbb.h" | 20 | #include "libbb.h" |
21 | #include "common_bufsiz.h" | ||
21 | #include <syslog.h> | 22 | #include <syslog.h> |
22 | #include "isrv.h" | 23 | #include "isrv.h" |
23 | 24 | ||
@@ -28,7 +29,8 @@ typedef struct identd_buf_t { | |||
28 | char buf[64 - sizeof(int)]; | 29 | char buf[64 - sizeof(int)]; |
29 | } identd_buf_t; | 30 | } identd_buf_t; |
30 | 31 | ||
31 | #define bogouser bb_common_bufsiz1 | 32 | #define bogouser bb_common_bufsiz1 |
33 | #define sizeof_bogouser COMMON_BUFSIZE | ||
32 | 34 | ||
33 | static int new_peer(isrv_state_t *state, int fd) | 35 | static int new_peer(isrv_state_t *state, int fd) |
34 | { | 36 | { |
@@ -118,7 +120,7 @@ int fakeidentd_main(int argc UNUSED_PARAM, char **argv) | |||
118 | opt = getopt32(argv, "fiwb:", &bind_address); | 120 | opt = getopt32(argv, "fiwb:", &bind_address); |
119 | strcpy(bogouser, "nobody"); | 121 | strcpy(bogouser, "nobody"); |
120 | if (argv[optind]) | 122 | if (argv[optind]) |
121 | strncpy(bogouser, argv[optind], sizeof(bogouser) - 1); | 123 | strncpy(bogouser, argv[optind], sizeof_bogouser - 1); |
122 | 124 | ||
123 | /* Daemonize if no -f and no -i and no -w */ | 125 | /* Daemonize if no -f and no -i and no -w */ |
124 | if (!(opt & OPT_fiw)) | 126 | if (!(opt & OPT_fiw)) |
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 5c975d8c5..2c0f514c7 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <net/if_arp.h> | 13 | #include <net/if_arp.h> |
14 | 14 | ||
15 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 15 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
16 | #include "common_bufsiz.h" | ||
16 | #include "rt_names.h" | 17 | #include "rt_names.h" |
17 | #include "utils.h" | 18 | #include "utils.h" |
18 | 19 | ||
@@ -39,7 +40,7 @@ struct filter_t { | |||
39 | } FIX_ALIASING; | 40 | } FIX_ALIASING; |
40 | typedef struct filter_t filter_t; | 41 | typedef struct filter_t filter_t; |
41 | 42 | ||
42 | #define G_filter (*(filter_t*)&bb_common_bufsiz1) | 43 | #define G_filter (*(filter_t*)bb_common_bufsiz1) |
43 | 44 | ||
44 | 45 | ||
45 | static void print_link_flags(unsigned flags, unsigned mdown) | 46 | static void print_link_flags(unsigned flags, unsigned mdown) |
diff --git a/networking/libiproute/ipneigh.c b/networking/libiproute/ipneigh.c index 179505c2d..151d3d109 100644 --- a/networking/libiproute/ipneigh.c +++ b/networking/libiproute/ipneigh.c | |||
@@ -8,6 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 10 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
11 | #include "common_bufsiz.h" | ||
11 | #include "rt_names.h" | 12 | #include "rt_names.h" |
12 | #include "utils.h" | 13 | #include "utils.h" |
13 | #include <linux/neighbour.h> | 14 | #include <linux/neighbour.h> |
@@ -40,7 +41,7 @@ struct filter_t { | |||
40 | } FIX_ALIASING; | 41 | } FIX_ALIASING; |
41 | typedef struct filter_t filter_t; | 42 | typedef struct filter_t filter_t; |
42 | 43 | ||
43 | #define G_filter (*(filter_t*)&bb_common_bufsiz1) | 44 | #define G_filter (*(filter_t*)bb_common_bufsiz1) |
44 | 45 | ||
45 | static int flush_update(void) | 46 | static int flush_update(void) |
46 | { | 47 | { |
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 82827488f..34d4f4758 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c | |||
@@ -11,6 +11,7 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include "ip_common.h" /* #include "libbb.h" is inside */ | 13 | #include "ip_common.h" /* #include "libbb.h" is inside */ |
14 | #include "common_bufsiz.h" | ||
14 | #include "rt_names.h" | 15 | #include "rt_names.h" |
15 | #include "utils.h" | 16 | #include "utils.h" |
16 | 17 | ||
@@ -43,7 +44,7 @@ struct filter_t { | |||
43 | } FIX_ALIASING; | 44 | } FIX_ALIASING; |
44 | typedef struct filter_t filter_t; | 45 | typedef struct filter_t filter_t; |
45 | 46 | ||
46 | #define G_filter (*(filter_t*)&bb_common_bufsiz1) | 47 | #define G_filter (*(filter_t*)bb_common_bufsiz1) |
47 | 48 | ||
48 | static int flush_update(void) | 49 | static int flush_update(void) |
49 | { | 50 | { |
diff --git a/networking/nc.c b/networking/nc.c index 2f9e17466..50edee450 100644 --- a/networking/nc.c +++ b/networking/nc.c | |||
@@ -8,6 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "libbb.h" | 10 | #include "libbb.h" |
11 | #include "common_bufsiz.h" | ||
11 | 12 | ||
12 | //config:config NC | 13 | //config:config NC |
13 | //config: bool "nc" | 14 | //config: bool "nc" |
@@ -252,7 +253,7 @@ int nc_main(int argc, char **argv) | |||
252 | fd = STDIN_FILENO; | 253 | fd = STDIN_FILENO; |
253 | while (1) { | 254 | while (1) { |
254 | if (FD_ISSET(fd, &testfds)) { | 255 | if (FD_ISSET(fd, &testfds)) { |
255 | nread = safe_read(fd, iobuf, sizeof(iobuf)); | 256 | nread = safe_read(fd, iobuf, COMMON_BUFSIZE); |
256 | if (fd == cfd) { | 257 | if (fd == cfd) { |
257 | if (nread < 1) | 258 | if (nread < 1) |
258 | exit(EXIT_SUCCESS); | 259 | exit(EXIT_SUCCESS); |
diff --git a/networking/ping.c b/networking/ping.c index 0eb1ae799..761660979 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <net/if.h> | 28 | #include <net/if.h> |
29 | #include <netinet/ip_icmp.h> | 29 | #include <netinet/ip_icmp.h> |
30 | #include "libbb.h" | 30 | #include "libbb.h" |
31 | #include "common_bufsiz.h" | ||
31 | 32 | ||
32 | #ifdef __BIONIC__ | 33 | #ifdef __BIONIC__ |
33 | /* should be in netinet/ip_icmp.h */ | 34 | /* should be in netinet/ip_icmp.h */ |
@@ -186,7 +187,7 @@ struct globals { | |||
186 | char *hostname; | 187 | char *hostname; |
187 | char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN]; | 188 | char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN]; |
188 | } FIX_ALIASING; | 189 | } FIX_ALIASING; |
189 | #define G (*(struct globals*)&bb_common_bufsiz1) | 190 | #define G (*(struct globals*)bb_common_bufsiz1) |
190 | #define INIT_G() do { } while (0) | 191 | #define INIT_G() do { } while (0) |
191 | 192 | ||
192 | static void noresp(int ign UNUSED_PARAM) | 193 | static void noresp(int ign UNUSED_PARAM) |
@@ -378,7 +379,7 @@ struct globals { | |||
378 | } pingaddr; | 379 | } pingaddr; |
379 | unsigned char rcvd_tbl[MAX_DUP_CHK / 8]; | 380 | unsigned char rcvd_tbl[MAX_DUP_CHK / 8]; |
380 | } FIX_ALIASING; | 381 | } FIX_ALIASING; |
381 | #define G (*(struct globals*)&bb_common_bufsiz1) | 382 | #define G (*(struct globals*)bb_common_bufsiz1) |
382 | #define if_index (G.if_index ) | 383 | #define if_index (G.if_index ) |
383 | #define source_lsa (G.source_lsa ) | 384 | #define source_lsa (G.source_lsa ) |
384 | #define str_I (G.str_I ) | 385 | #define str_I (G.str_I ) |
diff --git a/networking/slattach.c b/networking/slattach.c index 14e0c1941..d9d8fe7b8 100644 --- a/networking/slattach.c +++ b/networking/slattach.c | |||
@@ -27,6 +27,7 @@ | |||
27 | //usage: "\n -F Disable RTS/CTS flow control" | 27 | //usage: "\n -F Disable RTS/CTS flow control" |
28 | 28 | ||
29 | #include "libbb.h" | 29 | #include "libbb.h" |
30 | #include "common_bufsiz.h" | ||
30 | #include "libiproute/utils.h" /* invarg_1_to_2() */ | 31 | #include "libiproute/utils.h" /* invarg_1_to_2() */ |
31 | 32 | ||
32 | struct globals { | 33 | struct globals { |
@@ -34,7 +35,7 @@ struct globals { | |||
34 | int saved_disc; | 35 | int saved_disc; |
35 | struct termios saved_state; | 36 | struct termios saved_state; |
36 | } FIX_ALIASING; | 37 | } FIX_ALIASING; |
37 | #define G (*(struct globals*)&bb_common_bufsiz1) | 38 | #define G (*(struct globals*)bb_common_bufsiz1) |
38 | #define handle (G.handle ) | 39 | #define handle (G.handle ) |
39 | #define saved_disc (G.saved_disc ) | 40 | #define saved_disc (G.saved_disc ) |
40 | #define saved_state (G.saved_state ) | 41 | #define saved_state (G.saved_state ) |
diff --git a/networking/tc.c b/networking/tc.c index c84c18a67..1372ca081 100644 --- a/networking/tc.c +++ b/networking/tc.c | |||
@@ -29,6 +29,7 @@ | |||
29 | //usage: "filter show [ dev STRING ] [ root | parent CLASSID ]" | 29 | //usage: "filter show [ dev STRING ] [ root | parent CLASSID ]" |
30 | 30 | ||
31 | #include "libbb.h" | 31 | #include "libbb.h" |
32 | #include "common_bufsiz.h" | ||
32 | 33 | ||
33 | #include "libiproute/utils.h" | 34 | #include "libiproute/utils.h" |
34 | #include "libiproute/ip_common.h" | 35 | #include "libiproute/ip_common.h" |
@@ -63,7 +64,7 @@ struct globals { | |||
63 | uint32_t filter_prio; | 64 | uint32_t filter_prio; |
64 | uint32_t filter_proto; | 65 | uint32_t filter_proto; |
65 | } FIX_ALIASING; | 66 | } FIX_ALIASING; |
66 | #define G (*(struct globals*)&bb_common_bufsiz1) | 67 | #define G (*(struct globals*)bb_common_bufsiz1) |
67 | #define filter_ifindex (G.filter_ifindex) | 68 | #define filter_ifindex (G.filter_ifindex) |
68 | #define filter_qdisc (G.filter_qdisc) | 69 | #define filter_qdisc (G.filter_qdisc) |
69 | #define filter_parent (G.filter_parent) | 70 | #define filter_parent (G.filter_parent) |
diff --git a/networking/tcpudp.c b/networking/tcpudp.c index 3df6a98d8..624973042 100644 --- a/networking/tcpudp.c +++ b/networking/tcpudp.c | |||
@@ -67,6 +67,7 @@ | |||
67 | //usage: "\n -v Verbose" | 67 | //usage: "\n -v Verbose" |
68 | 68 | ||
69 | #include "libbb.h" | 69 | #include "libbb.h" |
70 | #include "common_bufsiz.h" | ||
70 | 71 | ||
71 | /* Wants <limits.h> etc, thus included after libbb.h: */ | 72 | /* Wants <limits.h> etc, thus included after libbb.h: */ |
72 | #ifdef __linux__ | 73 | #ifdef __linux__ |
@@ -91,7 +92,7 @@ struct globals { | |||
91 | char **env_cur; | 92 | char **env_cur; |
92 | char *env_var[1]; /* actually bigger */ | 93 | char *env_var[1]; /* actually bigger */ |
93 | } FIX_ALIASING; | 94 | } FIX_ALIASING; |
94 | #define G (*(struct globals*)&bb_common_bufsiz1) | 95 | #define G (*(struct globals*)bb_common_bufsiz1) |
95 | #define verbose (G.verbose ) | 96 | #define verbose (G.verbose ) |
96 | #define max_per_host (G.max_per_host) | 97 | #define max_per_host (G.max_per_host) |
97 | #define cur_per_host (G.cur_per_host) | 98 | #define cur_per_host (G.cur_per_host) |
diff --git a/networking/telnet.c b/networking/telnet.c index 944cf1bd6..2946bc831 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
@@ -39,6 +39,7 @@ | |||
39 | #include <arpa/telnet.h> | 39 | #include <arpa/telnet.h> |
40 | #include <netinet/in.h> | 40 | #include <netinet/in.h> |
41 | #include "libbb.h" | 41 | #include "libbb.h" |
42 | #include "common_bufsiz.h" | ||
42 | 43 | ||
43 | #ifdef __BIONIC__ | 44 | #ifdef __BIONIC__ |
44 | /* should be in arpa/telnet.h */ | 45 | /* should be in arpa/telnet.h */ |
@@ -108,7 +109,7 @@ struct globals { | |||
108 | struct termios termios_def; | 109 | struct termios termios_def; |
109 | struct termios termios_raw; | 110 | struct termios termios_raw; |
110 | } FIX_ALIASING; | 111 | } FIX_ALIASING; |
111 | #define G (*(struct globals*)&bb_common_bufsiz1) | 112 | #define G (*(struct globals*)bb_common_bufsiz1) |
112 | #define INIT_G() do { \ | 113 | #define INIT_G() do { \ |
113 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 114 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
114 | } while (0) | 115 | } while (0) |
diff --git a/networking/telnetd.c b/networking/telnetd.c index 25d05fe7a..13d5a8f64 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #define DEBUG 0 | 44 | #define DEBUG 0 |
45 | 45 | ||
46 | #include "libbb.h" | 46 | #include "libbb.h" |
47 | #include "common_bufsiz.h" | ||
47 | #include <syslog.h> | 48 | #include <syslog.h> |
48 | 49 | ||
49 | #if DEBUG | 50 | #if DEBUG |
@@ -82,7 +83,7 @@ struct globals { | |||
82 | const char *issuefile; | 83 | const char *issuefile; |
83 | int maxfd; | 84 | int maxfd; |
84 | } FIX_ALIASING; | 85 | } FIX_ALIASING; |
85 | #define G (*(struct globals*)&bb_common_bufsiz1) | 86 | #define G (*(struct globals*)bb_common_bufsiz1) |
86 | #define INIT_G() do { \ | 87 | #define INIT_G() do { \ |
87 | G.loginpath = "/bin/login"; \ | 88 | G.loginpath = "/bin/login"; \ |
88 | G.issuefile = "/etc/issue.net"; \ | 89 | G.issuefile = "/etc/issue.net"; \ |
diff --git a/networking/tftp.c b/networking/tftp.c index ad9308e52..8aeb79aca 100644 --- a/networking/tftp.c +++ b/networking/tftp.c | |||
@@ -51,6 +51,7 @@ | |||
51 | //usage: "\n -l Log to syslog (inetd mode requires this)" | 51 | //usage: "\n -l Log to syslog (inetd mode requires this)" |
52 | 52 | ||
53 | #include "libbb.h" | 53 | #include "libbb.h" |
54 | #include "common_bufsiz.h" | ||
54 | #include <syslog.h> | 55 | #include <syslog.h> |
55 | 56 | ||
56 | #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT | 57 | #if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT |
@@ -128,7 +129,7 @@ struct globals { | |||
128 | bb_progress_t pmt; | 129 | bb_progress_t pmt; |
129 | #endif | 130 | #endif |
130 | } FIX_ALIASING; | 131 | } FIX_ALIASING; |
131 | #define G (*(struct globals*)&bb_common_bufsiz1) | 132 | #define G (*(struct globals*)bb_common_bufsiz1) |
132 | #define INIT_G() do { \ | 133 | #define INIT_G() do { \ |
133 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 134 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
134 | } while (0) | 135 | } while (0) |
@@ -757,7 +758,8 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) | |||
757 | { | 758 | { |
758 | len_and_sockaddr *our_lsa; | 759 | len_and_sockaddr *our_lsa; |
759 | len_and_sockaddr *peer_lsa; | 760 | len_and_sockaddr *peer_lsa; |
760 | char *local_file, *mode, *user_opt; | 761 | char *mode, *user_opt; |
762 | char *local_file = local_file; | ||
761 | const char *error_msg; | 763 | const char *error_msg; |
762 | int opt, result, opcode; | 764 | int opt, result, opcode; |
763 | IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;) | 765 | IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;) |
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 496ab11a1..a526494d7 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h | |||
@@ -9,6 +9,7 @@ | |||
9 | #define UDHCP_COMMON_H 1 | 9 | #define UDHCP_COMMON_H 1 |
10 | 10 | ||
11 | #include "libbb.h" | 11 | #include "libbb.h" |
12 | #include "common_bufsiz.h" | ||
12 | #include <netinet/udp.h> | 13 | #include <netinet/udp.h> |
13 | #include <netinet/ip.h> | 14 | #include <netinet/ip.h> |
14 | 15 | ||
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h index 183e7e24c..9dd5bef9e 100644 --- a/networking/udhcp/dhcpd.h +++ b/networking/udhcp/dhcpd.h | |||
@@ -57,7 +57,7 @@ struct server_config_t { | |||
57 | struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */ | 57 | struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */ |
58 | } FIX_ALIASING; | 58 | } FIX_ALIASING; |
59 | 59 | ||
60 | #define server_config (*(struct server_config_t*)&bb_common_bufsiz1) | 60 | #define server_config (*(struct server_config_t*)bb_common_bufsiz1) |
61 | /* client_config sits in 2nd half of bb_common_bufsiz1 */ | 61 | /* client_config sits in 2nd half of bb_common_bufsiz1 */ |
62 | 62 | ||
63 | #if ENABLE_FEATURE_UDHCP_PORT | 63 | #if ENABLE_FEATURE_UDHCP_PORT |
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c index f82ac05b4..1722a85de 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
@@ -33,7 +33,7 @@ struct xid_item { | |||
33 | struct xid_item *next; | 33 | struct xid_item *next; |
34 | } FIX_ALIASING; | 34 | } FIX_ALIASING; |
35 | 35 | ||
36 | #define dhcprelay_xid_list (*(struct xid_item*)&bb_common_bufsiz1) | 36 | #define dhcprelay_xid_list (*(struct xid_item*)bb_common_bufsiz1) |
37 | 37 | ||
38 | static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client) | 38 | static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client) |
39 | { | 39 | { |
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 7b57c6258..b22425352 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -57,33 +57,35 @@ static int FAST_FUNC read_staticlease(const char *const_line, void *arg) | |||
57 | struct config_keyword { | 57 | struct config_keyword { |
58 | const char *keyword; | 58 | const char *keyword; |
59 | int (*handler)(const char *line, void *var) FAST_FUNC; | 59 | int (*handler)(const char *line, void *var) FAST_FUNC; |
60 | void *var; | 60 | unsigned ofs; |
61 | const char *def; | 61 | const char *def; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | #define OFS(field) offsetof(struct server_config_t, field) | ||
65 | |||
64 | static const struct config_keyword keywords[] = { | 66 | static const struct config_keyword keywords[] = { |
65 | /* keyword handler variable address default */ | 67 | /* keyword handler variable address default */ |
66 | {"start" , udhcp_str2nip , &server_config.start_ip , "192.168.0.20"}, | 68 | {"start" , udhcp_str2nip , OFS(start_ip ), "192.168.0.20"}, |
67 | {"end" , udhcp_str2nip , &server_config.end_ip , "192.168.0.254"}, | 69 | {"end" , udhcp_str2nip , OFS(end_ip ), "192.168.0.254"}, |
68 | {"interface" , read_str , &server_config.interface , "eth0"}, | 70 | {"interface" , read_str , OFS(interface ), "eth0"}, |
69 | /* Avoid "max_leases value not sane" warning by setting default | 71 | /* Avoid "max_leases value not sane" warning by setting default |
70 | * to default_end_ip - default_start_ip + 1: */ | 72 | * to default_end_ip - default_start_ip + 1: */ |
71 | {"max_leases" , read_u32 , &server_config.max_leases , "235"}, | 73 | {"max_leases" , read_u32 , OFS(max_leases ), "235"}, |
72 | {"auto_time" , read_u32 , &server_config.auto_time , "7200"}, | 74 | {"auto_time" , read_u32 , OFS(auto_time ), "7200"}, |
73 | {"decline_time" , read_u32 , &server_config.decline_time , "3600"}, | 75 | {"decline_time" , read_u32 , OFS(decline_time ), "3600"}, |
74 | {"conflict_time", read_u32 , &server_config.conflict_time, "3600"}, | 76 | {"conflict_time", read_u32 , OFS(conflict_time), "3600"}, |
75 | {"offer_time" , read_u32 , &server_config.offer_time , "60"}, | 77 | {"offer_time" , read_u32 , OFS(offer_time ), "60"}, |
76 | {"min_lease" , read_u32 , &server_config.min_lease_sec, "60"}, | 78 | {"min_lease" , read_u32 , OFS(min_lease_sec), "60"}, |
77 | {"lease_file" , read_str , &server_config.lease_file , LEASES_FILE}, | 79 | {"lease_file" , read_str , OFS(lease_file ), LEASES_FILE}, |
78 | {"pidfile" , read_str , &server_config.pidfile , "/var/run/udhcpd.pid"}, | 80 | {"pidfile" , read_str , OFS(pidfile ), "/var/run/udhcpd.pid"}, |
79 | {"siaddr" , udhcp_str2nip , &server_config.siaddr_nip , "0.0.0.0"}, | 81 | {"siaddr" , udhcp_str2nip , OFS(siaddr_nip ), "0.0.0.0"}, |
80 | /* keywords with no defaults must be last! */ | 82 | /* keywords with no defaults must be last! */ |
81 | {"option" , udhcp_str2optset, &server_config.options , ""}, | 83 | {"option" , udhcp_str2optset, OFS(options ), ""}, |
82 | {"opt" , udhcp_str2optset, &server_config.options , ""}, | 84 | {"opt" , udhcp_str2optset, OFS(options ), ""}, |
83 | {"notify_file" , read_str , &server_config.notify_file , NULL}, | 85 | {"notify_file" , read_str , OFS(notify_file ), NULL}, |
84 | {"sname" , read_str , &server_config.sname , NULL}, | 86 | {"sname" , read_str , OFS(sname ), NULL}, |
85 | {"boot_file" , read_str , &server_config.boot_file , NULL}, | 87 | {"boot_file" , read_str , OFS(boot_file ), NULL}, |
86 | {"static_lease" , read_staticlease, &server_config.static_leases, ""}, | 88 | {"static_lease" , read_staticlease, OFS(static_leases), ""}, |
87 | }; | 89 | }; |
88 | enum { KWS_WITH_DEFAULTS = ARRAY_SIZE(keywords) - 6 }; | 90 | enum { KWS_WITH_DEFAULTS = ARRAY_SIZE(keywords) - 6 }; |
89 | 91 | ||
@@ -95,17 +97,17 @@ void FAST_FUNC read_config(const char *file) | |||
95 | char *token[2]; | 97 | char *token[2]; |
96 | 98 | ||
97 | for (i = 0; i < KWS_WITH_DEFAULTS; i++) | 99 | for (i = 0; i < KWS_WITH_DEFAULTS; i++) |
98 | keywords[i].handler(keywords[i].def, keywords[i].var); | 100 | keywords[i].handler(keywords[i].def, (char*)&server_config + keywords[i].ofs); |
99 | 101 | ||
100 | parser = config_open(file); | 102 | parser = config_open(file); |
101 | while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) { | 103 | while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) { |
102 | for (k = keywords, i = 0; i < ARRAY_SIZE(keywords); k++, i++) { | 104 | for (k = keywords, i = 0; i < ARRAY_SIZE(keywords); k++, i++) { |
103 | if (strcasecmp(token[0], k->keyword) == 0) { | 105 | if (strcasecmp(token[0], k->keyword) == 0) { |
104 | if (!k->handler(token[1], k->var)) { | 106 | if (!k->handler(token[1], (char*)&server_config + k->ofs)) { |
105 | bb_error_msg("can't parse line %u in %s", | 107 | bb_error_msg("can't parse line %u in %s", |
106 | parser->lineno, file); | 108 | parser->lineno, file); |
107 | /* reset back to the default value */ | 109 | /* reset back to the default value */ |
108 | k->handler(k->def, k->var); | 110 | k->handler(k->def, (char*)&server_config + k->ofs); |
109 | } | 111 | } |
110 | break; | 112 | break; |
111 | } | 113 | } |
diff --git a/networking/zcip.c b/networking/zcip.c index c93082619..79643458c 100644 --- a/networking/zcip.c +++ b/networking/zcip.c | |||
@@ -40,6 +40,7 @@ | |||
40 | //usage: "\nexits only on I/O errors (link down etc)" | 40 | //usage: "\nexits only on I/O errors (link down etc)" |
41 | 41 | ||
42 | #include "libbb.h" | 42 | #include "libbb.h" |
43 | #include "common_bufsiz.h" | ||
43 | #include <netinet/ether.h> | 44 | #include <netinet/ether.h> |
44 | #include <net/if.h> | 45 | #include <net/if.h> |
45 | #include <net/if_arp.h> | 46 | #include <net/if_arp.h> |
@@ -90,7 +91,7 @@ struct globals { | |||
90 | struct ether_addr our_ethaddr; | 91 | struct ether_addr our_ethaddr; |
91 | uint32_t localnet_ip; | 92 | uint32_t localnet_ip; |
92 | } FIX_ALIASING; | 93 | } FIX_ALIASING; |
93 | #define G (*(struct globals*)&bb_common_bufsiz1) | 94 | #define G (*(struct globals*)bb_common_bufsiz1) |
94 | #define INIT_G() do { } while (0) | 95 | #define INIT_G() do { } while (0) |
95 | 96 | ||
96 | 97 | ||