diff options
author | Ron Yorston <rmy@pobox.com> | 2016-05-16 09:33:03 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-05-16 09:33:03 +0100 |
commit | 35d2f5bccb0f3dde600702ebcdb5424d4d50be4a (patch) | |
tree | 6e0ff0341c69839e268459a199682628bae734ed /networking | |
parent | 248a2600a2f4b442101ad568d1994b908bb28d4b (diff) | |
parent | f2559e5c2b7bd2c5fa0dd8e88d0a931da92a23af (diff) | |
download | busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.tar.gz busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.tar.bz2 busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'networking')
32 files changed, 149 insertions, 82 deletions
diff --git a/networking/arp.c b/networking/arp.c index 0099aa534..9381eb53a 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,12 +70,13 @@ 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 ) |
76 | #define hw_set (G.hw_set ) | 77 | #define hw_set (G.hw_set ) |
77 | #define INIT_G() do { \ | 78 | #define INIT_G() do { \ |
79 | setup_common_bufsiz(); \ | ||
78 | device = ""; \ | 80 | device = ""; \ |
79 | } while (0) | 81 | } while (0) |
80 | 82 | ||
diff --git a/networking/arping.c b/networking/arping.c index ef205e5e6..6b0de4de2 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 ) |
@@ -76,6 +77,7 @@ struct globals { | |||
76 | #define brd_recv (G.brd_recv ) | 77 | #define brd_recv (G.brd_recv ) |
77 | #define req_recv (G.req_recv ) | 78 | #define req_recv (G.req_recv ) |
78 | #define INIT_G() do { \ | 79 | #define INIT_G() do { \ |
80 | setup_common_bufsiz(); \ | ||
79 | count = -1; \ | 81 | count = -1; \ |
80 | } while (0) | 82 | } while (0) |
81 | 83 | ||
diff --git a/networking/ftpd.c b/networking/ftpd.c index 8345ae67c..360d1e6be 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,8 +124,9 @@ 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 { \ |
129 | setup_common_bufsiz(); \ | ||
128 | /* Moved to main */ \ | 130 | /* Moved to main */ \ |
129 | /*strcpy(G.msg_ok + 4, MSG_OK );*/ \ | 131 | /*strcpy(G.msg_ok + 4, MSG_OK );*/ \ |
130 | /*strcpy(G.msg_err + 4, MSG_ERR);*/ \ | 132 | /*strcpy(G.msg_err + 4, MSG_ERR);*/ \ |
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 607e82713..0bfe388a8 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 ) |
@@ -70,6 +71,7 @@ enum { BUFSZ = COMMON_BUFSIZE - offsetof(struct globals, buf) }; | |||
70 | #define do_continue (G.do_continue ) | 71 | #define do_continue (G.do_continue ) |
71 | #define buf (G.buf ) | 72 | #define buf (G.buf ) |
72 | #define INIT_G() do { \ | 73 | #define INIT_G() do { \ |
74 | setup_common_bufsiz(); \ | ||
73 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 75 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
74 | } while (0) | 76 | } while (0) |
75 | 77 | ||
diff --git a/networking/httpd.c b/networking/httpd.c index ed15fd883..abe83a458 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 |
@@ -368,6 +370,7 @@ enum { | |||
368 | # define content_gzip 0 | 370 | # define content_gzip 0 |
369 | #endif | 371 | #endif |
370 | #define INIT_G() do { \ | 372 | #define INIT_G() do { \ |
373 | setup_common_bufsiz(); \ | ||
371 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ | 374 | SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
372 | IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ | 375 | IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ |
373 | IF_FEATURE_HTTPD_RANGES(range_start = -1;) \ | 376 | IF_FEATURE_HTTPD_RANGES(range_start = -1;) \ |
@@ -1066,7 +1069,7 @@ static int get_line(void) | |||
1066 | alarm(HEADER_READ_TIMEOUT); | 1069 | alarm(HEADER_READ_TIMEOUT); |
1067 | while (1) { | 1070 | while (1) { |
1068 | if (hdr_cnt <= 0) { | 1071 | if (hdr_cnt <= 0) { |
1069 | hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf)); | 1072 | hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof_hdr_buf); |
1070 | if (hdr_cnt <= 0) | 1073 | if (hdr_cnt <= 0) |
1071 | break; | 1074 | break; |
1072 | hdr_ptr = hdr_buf; | 1075 | hdr_ptr = hdr_buf; |
@@ -1191,9 +1194,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 | 1194 | /* We expect data, prev data portion is eaten by CGI |
1192 | * and there *is* data to read from the peer | 1195 | * and there *is* data to read from the peer |
1193 | * (POSTDATA) */ | 1196 | * (POSTDATA) */ |
1194 | //count = post_len > (int)sizeof(hdr_buf) ? (int)sizeof(hdr_buf) : post_len; | 1197 | //count = post_len > (int)sizeof_hdr_buf ? (int)sizeof_hdr_buf : post_len; |
1195 | //count = safe_read(STDIN_FILENO, hdr_buf, count); | 1198 | //count = safe_read(STDIN_FILENO, hdr_buf, count); |
1196 | count = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf)); | 1199 | count = safe_read(STDIN_FILENO, hdr_buf, sizeof_hdr_buf); |
1197 | if (count > 0) { | 1200 | if (count > 0) { |
1198 | hdr_cnt = count; | 1201 | hdr_cnt = count; |
1199 | hdr_ptr = hdr_buf; | 1202 | hdr_ptr = hdr_buf; |
diff --git a/networking/ifupdown.c b/networking/ifupdown.c index 2c6db926f..25b04c9d7 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,8 +130,8 @@ 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 { setup_common_bufsiz(); } while (0) |
134 | 135 | ||
135 | 136 | ||
136 | static const char keywords_up_down[] ALIGN1 = | 137 | static const char keywords_up_down[] ALIGN1 = |
diff --git a/networking/inetd.c b/networking/inetd.c index 4f6673b12..8d44b5198 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 ) |
@@ -349,6 +350,7 @@ enum { LINE_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line) }; | |||
349 | #define allsock (G.allsock ) | 350 | #define allsock (G.allsock ) |
350 | #define line (G.line ) | 351 | #define line (G.line ) |
351 | #define INIT_G() do { \ | 352 | #define INIT_G() do { \ |
353 | setup_common_bufsiz(); \ | ||
352 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 354 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
353 | rlim_ofile_cur = OPEN_MAX; \ | 355 | rlim_ofile_cur = OPEN_MAX; \ |
354 | global_queuelen = 128; \ | 356 | global_queuelen = 128; \ |
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c index 252c8aba9..8a15926e5 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 | ||
@@ -115,10 +116,12 @@ int fakeidentd_main(int argc UNUSED_PARAM, char **argv) | |||
115 | unsigned opt; | 116 | unsigned opt; |
116 | int fd; | 117 | int fd; |
117 | 118 | ||
119 | setup_common_bufsiz(); | ||
120 | |||
118 | opt = getopt32(argv, "fiwb:", &bind_address); | 121 | opt = getopt32(argv, "fiwb:", &bind_address); |
119 | strcpy(bogouser, "nobody"); | 122 | strcpy(bogouser, "nobody"); |
120 | if (argv[optind]) | 123 | if (argv[optind]) |
121 | strncpy(bogouser, argv[optind], sizeof(bogouser) - 1); | 124 | strncpy(bogouser, argv[optind], COMMON_BUFSIZE - 1); |
122 | 125 | ||
123 | /* Daemonize if no -f and no -i and no -w */ | 126 | /* Daemonize if no -f and no -i and no -w */ |
124 | if (!(opt & OPT_fiw)) | 127 | if (!(opt & OPT_fiw)) |
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 5c975d8c5..d9e099607 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,8 +40,8 @@ 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 | #define INIT_G() do { setup_common_bufsiz(); } while (0) | |
44 | 45 | ||
45 | static void print_link_flags(unsigned flags, unsigned mdown) | 46 | static void print_link_flags(unsigned flags, unsigned mdown) |
46 | { | 47 | { |
@@ -744,6 +745,9 @@ int FAST_FUNC do_ipaddr(char **argv) | |||
744 | /* 0 1 2 3 4 5 6 7 8 */ | 745 | /* 0 1 2 3 4 5 6 7 8 */ |
745 | "add\0""change\0""chg\0""replace\0""delete\0""list\0""show\0""lst\0""flush\0"; | 746 | "add\0""change\0""chg\0""replace\0""delete\0""list\0""show\0""lst\0""flush\0"; |
746 | int cmd = 2; | 747 | int cmd = 2; |
748 | |||
749 | INIT_G(); | ||
750 | |||
747 | if (*argv) { | 751 | if (*argv) { |
748 | cmd = index_in_substrings(commands, *argv); | 752 | cmd = index_in_substrings(commands, *argv); |
749 | if (cmd < 0) | 753 | if (cmd < 0) |
diff --git a/networking/libiproute/ipneigh.c b/networking/libiproute/ipneigh.c index 179505c2d..2a1c20e20 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,8 @@ 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) |
45 | #define INIT_G() do { setup_common_bufsiz(); } while (0) | ||
44 | 46 | ||
45 | static int flush_update(void) | 47 | static int flush_update(void) |
46 | { | 48 | { |
@@ -60,7 +62,7 @@ static unsigned nud_state_a2n(char *arg) | |||
60 | "stale\0" "incomplete\0" "delay\0" "probe\0" | 62 | "stale\0" "incomplete\0" "delay\0" "probe\0" |
61 | "failed\0" | 63 | "failed\0" |
62 | ; | 64 | ; |
63 | static uint8_t nuds[] = { | 65 | static uint8_t nuds[] ALIGN1 = { |
64 | NUD_PERMANENT,NUD_REACHABLE, NUD_NOARP,NUD_NONE, | 66 | NUD_PERMANENT,NUD_REACHABLE, NUD_NOARP,NUD_NONE, |
65 | NUD_STALE, NUD_INCOMPLETE,NUD_DELAY,NUD_PROBE, | 67 | NUD_STALE, NUD_INCOMPLETE,NUD_DELAY,NUD_PROBE, |
66 | NUD_FAILED | 68 | NUD_FAILED |
@@ -338,6 +340,8 @@ int FAST_FUNC do_ipneigh(char **argv) | |||
338 | /*0-1*/ "show\0" "flush\0"; | 340 | /*0-1*/ "show\0" "flush\0"; |
339 | int command_num; | 341 | int command_num; |
340 | 342 | ||
343 | INIT_G(); | ||
344 | |||
341 | if (!*argv) | 345 | if (!*argv) |
342 | return ipneigh_list_or_flush(argv, 0); | 346 | return ipneigh_list_or_flush(argv, 0); |
343 | 347 | ||
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 82827488f..e674e9a0d 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,8 @@ 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) |
48 | #define INIT_G() do { setup_common_bufsiz(); } while (0) | ||
47 | 49 | ||
48 | static int flush_update(void) | 50 | static int flush_update(void) |
49 | { | 51 | { |
@@ -902,6 +904,8 @@ int FAST_FUNC do_iproute(char **argv) | |||
902 | unsigned flags = 0; | 904 | unsigned flags = 0; |
903 | int cmd = RTM_NEWROUTE; | 905 | int cmd = RTM_NEWROUTE; |
904 | 906 | ||
907 | INIT_G(); | ||
908 | |||
905 | if (!*argv) | 909 | if (!*argv) |
906 | return iproute_list_or_flush(argv, 0); | 910 | return iproute_list_or_flush(argv, 0); |
907 | 911 | ||
diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index c7533a4a7..cbb5daf95 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c | |||
@@ -71,11 +71,15 @@ int FAST_FUNC rtnl_dump_request(struct rtnl_handle *rth, int type, void *req, in | |||
71 | struct nlmsghdr nlh; | 71 | struct nlmsghdr nlh; |
72 | struct sockaddr_nl nladdr; | 72 | struct sockaddr_nl nladdr; |
73 | struct iovec iov[2] = { { &nlh, sizeof(nlh) }, { req, len } }; | 73 | struct iovec iov[2] = { { &nlh, sizeof(nlh) }, { req, len } }; |
74 | /* Use designated initializers, struct layout is non-portable */ | ||
74 | struct msghdr msg = { | 75 | struct msghdr msg = { |
75 | (void*)&nladdr, sizeof(nladdr), | 76 | .msg_name = (void*)&nladdr, |
76 | iov, 2, | 77 | .msg_namelen = sizeof(nladdr), |
77 | NULL, 0, | 78 | .msg_iov = iov, |
78 | 0 | 79 | .msg_iovlen = 2, |
80 | .msg_control = NULL, | ||
81 | .msg_controllen = 0, | ||
82 | .msg_flags = 0 | ||
79 | }; | 83 | }; |
80 | 84 | ||
81 | memset(&nladdr, 0, sizeof(nladdr)); | 85 | memset(&nladdr, 0, sizeof(nladdr)); |
@@ -104,12 +108,15 @@ static int rtnl_dump_filter(struct rtnl_handle *rth, | |||
104 | while (1) { | 108 | while (1) { |
105 | int status; | 109 | int status; |
106 | struct nlmsghdr *h; | 110 | struct nlmsghdr *h; |
107 | 111 | /* Use designated initializers, struct layout is non-portable */ | |
108 | struct msghdr msg = { | 112 | struct msghdr msg = { |
109 | (void*)&nladdr, sizeof(nladdr), | 113 | .msg_name = (void*)&nladdr, |
110 | &iov, 1, | 114 | .msg_namelen = sizeof(nladdr), |
111 | NULL, 0, | 115 | .msg_iov = &iov, |
112 | 0 | 116 | .msg_iovlen = 1, |
117 | .msg_control = NULL, | ||
118 | .msg_controllen = 0, | ||
119 | .msg_flags = 0 | ||
113 | }; | 120 | }; |
114 | 121 | ||
115 | status = recvmsg(rth->fd, &msg, 0); | 122 | status = recvmsg(rth->fd, &msg, 0); |
@@ -211,11 +218,15 @@ int FAST_FUNC rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, | |||
211 | struct sockaddr_nl nladdr; | 218 | struct sockaddr_nl nladdr; |
212 | struct iovec iov = { (void*)n, n->nlmsg_len }; | 219 | struct iovec iov = { (void*)n, n->nlmsg_len }; |
213 | char *buf = xmalloc(8*1024); /* avoid big stack buffer */ | 220 | char *buf = xmalloc(8*1024); /* avoid big stack buffer */ |
221 | /* Use designated initializers, struct layout is non-portable */ | ||
214 | struct msghdr msg = { | 222 | struct msghdr msg = { |
215 | (void*)&nladdr, sizeof(nladdr), | 223 | .msg_name = (void*)&nladdr, |
216 | &iov, 1, | 224 | .msg_namelen = sizeof(nladdr), |
217 | NULL, 0, | 225 | .msg_iov = &iov, |
218 | 0 | 226 | .msg_iovlen = 1, |
227 | .msg_control = NULL, | ||
228 | .msg_controllen = 0, | ||
229 | .msg_flags = 0 | ||
219 | }; | 230 | }; |
220 | 231 | ||
221 | memset(&nladdr, 0, sizeof(nladdr)); | 232 | memset(&nladdr, 0, sizeof(nladdr)); |
diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index da2b53cbf..4c32ae574 100644 --- a/networking/libiproute/ll_proto.c +++ b/networking/libiproute/ll_proto.c | |||
@@ -84,7 +84,7 @@ ETH_P_IP | |||
84 | 84 | ||
85 | /* Keep declarations above and below in sync! */ | 85 | /* Keep declarations above and below in sync! */ |
86 | 86 | ||
87 | static const char llproto_names[] = | 87 | static const char llproto_names[] ALIGN1 = |
88 | #define __PF(f,n) #n "\0" | 88 | #define __PF(f,n) #n "\0" |
89 | __PF(LOOP,loop) | 89 | __PF(LOOP,loop) |
90 | __PF(PUP,pup) | 90 | __PF(PUP,pup) |
diff --git a/networking/libiproute/ll_types.c b/networking/libiproute/ll_types.c index bb42e269e..62ee0cc54 100644 --- a/networking/libiproute/ll_types.c +++ b/networking/libiproute/ll_types.c | |||
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | const char* FAST_FUNC ll_type_n2a(int type, char *buf) | 17 | const char* FAST_FUNC ll_type_n2a(int type, char *buf) |
18 | { | 18 | { |
19 | static const char arphrd_name[] = | 19 | static const char arphrd_name[] ALIGN1 = |
20 | /* 0, */ "generic" "\0" | 20 | /* 0, */ "generic" "\0" |
21 | /* ARPHRD_LOOPBACK, */ "loopback" "\0" | 21 | /* ARPHRD_LOOPBACK, */ "loopback" "\0" |
22 | /* ARPHRD_ETHER, */ "ether" "\0" | 22 | /* ARPHRD_ETHER, */ "ether" "\0" |
@@ -105,7 +105,7 @@ const char* FAST_FUNC ll_type_n2a(int type, char *buf) | |||
105 | 105 | ||
106 | /* Keep these arrays in sync! */ | 106 | /* Keep these arrays in sync! */ |
107 | 107 | ||
108 | static const uint16_t arphrd_type[] = { | 108 | static const uint16_t arphrd_type[] ALIGN2 = { |
109 | 0, /* "generic" "\0" */ | 109 | 0, /* "generic" "\0" */ |
110 | ARPHRD_LOOPBACK, /* "loopback" "\0" */ | 110 | ARPHRD_LOOPBACK, /* "loopback" "\0" */ |
111 | ARPHRD_ETHER, /* "ether" "\0" */ | 111 | ARPHRD_ETHER, /* "ether" "\0" */ |
diff --git a/networking/nc.c b/networking/nc.c index 2f9e17466..13a9b48a8 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" |
@@ -238,6 +239,8 @@ int nc_main(int argc, char **argv) | |||
238 | FD_SET(cfd, &readfds); | 239 | FD_SET(cfd, &readfds); |
239 | FD_SET(STDIN_FILENO, &readfds); | 240 | FD_SET(STDIN_FILENO, &readfds); |
240 | 241 | ||
242 | #define iobuf bb_common_bufsiz1 | ||
243 | setup_common_bufsiz(); | ||
241 | for (;;) { | 244 | for (;;) { |
242 | int fd; | 245 | int fd; |
243 | int ofd; | 246 | int ofd; |
@@ -248,11 +251,10 @@ int nc_main(int argc, char **argv) | |||
248 | if (select(cfd + 1, &testfds, NULL, NULL, NULL) < 0) | 251 | if (select(cfd + 1, &testfds, NULL, NULL, NULL) < 0) |
249 | bb_perror_msg_and_die("select"); | 252 | bb_perror_msg_and_die("select"); |
250 | 253 | ||
251 | #define iobuf bb_common_bufsiz1 | ||
252 | fd = STDIN_FILENO; | 254 | fd = STDIN_FILENO; |
253 | while (1) { | 255 | while (1) { |
254 | if (FD_ISSET(fd, &testfds)) { | 256 | if (FD_ISSET(fd, &testfds)) { |
255 | nread = safe_read(fd, iobuf, sizeof(iobuf)); | 257 | nread = safe_read(fd, iobuf, COMMON_BUFSIZE); |
256 | if (fd == cfd) { | 258 | if (fd == cfd) { |
257 | if (nread < 1) | 259 | if (nread < 1) |
258 | exit(EXIT_SUCCESS); | 260 | exit(EXIT_SUCCESS); |
diff --git a/networking/ping.c b/networking/ping.c index 0eb1ae799..cfe682646 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,8 +187,8 @@ 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 { setup_common_bufsiz(); } while (0) |
191 | 192 | ||
192 | static void noresp(int ign UNUSED_PARAM) | 193 | static void noresp(int ign UNUSED_PARAM) |
193 | { | 194 | { |
@@ -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 ) |
@@ -397,6 +398,7 @@ struct globals { | |||
397 | #define pingaddr (G.pingaddr ) | 398 | #define pingaddr (G.pingaddr ) |
398 | #define rcvd_tbl (G.rcvd_tbl ) | 399 | #define rcvd_tbl (G.rcvd_tbl ) |
399 | #define INIT_G() do { \ | 400 | #define INIT_G() do { \ |
401 | setup_common_bufsiz(); \ | ||
400 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 402 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
401 | datalen = DEFDATALEN; \ | 403 | datalen = DEFDATALEN; \ |
402 | timeout = MAXWAIT; \ | 404 | timeout = MAXWAIT; \ |
diff --git a/networking/slattach.c b/networking/slattach.c index 14e0c1941..2d1305e32 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,11 +35,11 @@ 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 ) |
41 | #define INIT_G() do { } while (0) | 42 | #define INIT_G() do { setup_common_bufsiz(); } while (0) |
42 | 43 | ||
43 | 44 | ||
44 | /* | 45 | /* |
diff --git a/networking/tc.c b/networking/tc.c index c84c18a67..d0bcbdeaa 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,13 +64,14 @@ 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) |
70 | #define filter_prio (G.filter_prio) | 71 | #define filter_prio (G.filter_prio) |
71 | #define filter_proto (G.filter_proto) | 72 | #define filter_proto (G.filter_proto) |
72 | #define INIT_G() do { \ | 73 | #define INIT_G() do { \ |
74 | setup_common_bufsiz(); \ | ||
73 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 75 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
74 | } while (0) | 76 | } while (0) |
75 | 77 | ||
diff --git a/networking/tcpudp.c b/networking/tcpudp.c index 3df6a98d8..31bc70459 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) |
@@ -100,6 +101,7 @@ struct globals { | |||
100 | #define env_cur (G.env_cur ) | 101 | #define env_cur (G.env_cur ) |
101 | #define env_var (G.env_var ) | 102 | #define env_var (G.env_var ) |
102 | #define INIT_G() do { \ | 103 | #define INIT_G() do { \ |
104 | setup_common_bufsiz(); \ | ||
103 | cmax = 30; \ | 105 | cmax = 30; \ |
104 | env_cur = &env_var[0]; \ | 106 | env_cur = &env_var[0]; \ |
105 | } while (0) | 107 | } while (0) |
diff --git a/networking/telnet.c b/networking/telnet.c index 944cf1bd6..d2daf5c8c 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,8 +109,9 @@ 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 { \ |
114 | setup_common_bufsiz(); \ | ||
113 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 115 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
114 | } while (0) | 116 | } while (0) |
115 | 117 | ||
diff --git a/networking/telnetd.c b/networking/telnetd.c index 25d05fe7a..13c36aa46 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,8 +83,9 @@ 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 { \ |
88 | setup_common_bufsiz(); \ | ||
87 | G.loginpath = "/bin/login"; \ | 89 | G.loginpath = "/bin/login"; \ |
88 | G.issuefile = "/etc/issue.net"; \ | 90 | G.issuefile = "/etc/issue.net"; \ |
89 | } while (0) | 91 | } while (0) |
diff --git a/networking/telnetd.ctrlSQ.patch b/networking/telnetd.ctrlSQ.patch index 7060e1c6e..bc26d2279 100644 --- a/networking/telnetd.ctrlSQ.patch +++ b/networking/telnetd.ctrlSQ.patch | |||
@@ -94,9 +94,9 @@ exceptional conditions. | |||
94 | #endif | 94 | #endif |
95 | +#ifdef TIOCPKT | 95 | +#ifdef TIOCPKT |
96 | + int control; | 96 | + int control; |
97 | + static const char lflow_on[] = | 97 | + static const char lflow_on[] ALIGN1 = |
98 | + {IAC, SB, TELOPT_LFLOW, LFLOW_ON, IAC, SE}; | 98 | + {IAC, SB, TELOPT_LFLOW, LFLOW_ON, IAC, SE}; |
99 | + static const char lflow_off[] = | 99 | + static const char lflow_off[] ALIGN1 = |
100 | + {IAC, SB, TELOPT_LFLOW, LFLOW_OFF, IAC, SE}; | 100 | + {IAC, SB, TELOPT_LFLOW, LFLOW_OFF, IAC, SE}; |
101 | +# define RESERVED sizeof(lflow_on) | 101 | +# define RESERVED sizeof(lflow_on) |
102 | +#else | 102 | +#else |
diff --git a/networking/tftp.c b/networking/tftp.c index ad9308e52..e879c4674 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,8 +129,9 @@ 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 { \ |
134 | setup_common_bufsiz(); \ | ||
133 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ | 135 | BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \ |
134 | } while (0) | 136 | } while (0) |
135 | 137 | ||
@@ -757,7 +759,8 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv) | |||
757 | { | 759 | { |
758 | len_and_sockaddr *our_lsa; | 760 | len_and_sockaddr *our_lsa; |
759 | len_and_sockaddr *peer_lsa; | 761 | len_and_sockaddr *peer_lsa; |
760 | char *local_file, *mode, *user_opt; | 762 | char *mode, *user_opt; |
763 | char *local_file = local_file; | ||
761 | const char *error_msg; | 764 | const char *error_msg; |
762 | int opt, result, opcode; | 765 | int opt, result, opcode; |
763 | IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;) | 766 | 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/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c index 422254d62..c77669a31 100644 --- a/networking/udhcp/d6_dhcpc.c +++ b/networking/udhcp/d6_dhcpc.c | |||
@@ -930,6 +930,8 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv) | |||
930 | int retval; | 930 | int retval; |
931 | fd_set rfds; | 931 | fd_set rfds; |
932 | 932 | ||
933 | setup_common_bufsiz(); | ||
934 | |||
933 | /* Default options */ | 935 | /* Default options */ |
934 | IF_FEATURE_UDHCP_PORT(SERVER_PORT6 = 547;) | 936 | IF_FEATURE_UDHCP_PORT(SERVER_PORT6 = 547;) |
935 | IF_FEATURE_UDHCP_PORT(CLIENT_PORT6 = 546;) | 937 | IF_FEATURE_UDHCP_PORT(CLIENT_PORT6 = 546;) |
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 660b943ce..fc7b6216d 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -109,7 +109,7 @@ enum { | |||
109 | /*** Script execution code ***/ | 109 | /*** Script execution code ***/ |
110 | 110 | ||
111 | /* get a rough idea of how long an option will be (rounding up...) */ | 111 | /* get a rough idea of how long an option will be (rounding up...) */ |
112 | static const uint8_t len_of_option_as_string[] = { | 112 | static const uint8_t len_of_option_as_string[] ALIGN1 = { |
113 | [OPTION_IP ] = sizeof("255.255.255.255 "), | 113 | [OPTION_IP ] = sizeof("255.255.255.255 "), |
114 | [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2, | 114 | [OPTION_IP_PAIR ] = sizeof("255.255.255.255 ") * 2, |
115 | [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "), | 115 | [OPTION_STATIC_ROUTES ] = sizeof("255.255.255.255/32 255.255.255.255 "), |
@@ -1268,6 +1268,8 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
1268 | int retval; | 1268 | int retval; |
1269 | fd_set rfds; | 1269 | fd_set rfds; |
1270 | 1270 | ||
1271 | setup_common_bufsiz(); | ||
1272 | |||
1271 | /* Default options */ | 1273 | /* Default options */ |
1272 | IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;) | 1274 | IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;) |
1273 | IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;) | 1275 | IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;) |
diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 2671ea3e2..e93a9f1da 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c | |||
@@ -310,10 +310,10 @@ int udhcpd_main(int argc UNUSED_PARAM, char **argv) | |||
310 | unsigned arpping_ms; | 310 | unsigned arpping_ms; |
311 | IF_FEATURE_UDHCP_PORT(char *str_P;) | 311 | IF_FEATURE_UDHCP_PORT(char *str_P;) |
312 | 312 | ||
313 | #if ENABLE_FEATURE_UDHCP_PORT | 313 | setup_common_bufsiz(); |
314 | SERVER_PORT = 67; | 314 | |
315 | CLIENT_PORT = 68; | 315 | IF_FEATURE_UDHCP_PORT(SERVER_PORT = 67;) |
316 | #endif | 316 | IF_FEATURE_UDHCP_PORT(CLIENT_PORT = 68;) |
317 | 317 | ||
318 | #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 | 318 | #if defined CONFIG_UDHCP_DEBUG && CONFIG_UDHCP_DEBUG >= 1 |
319 | opt_complementary = "vv"; | 319 | opt_complementary = "vv"; |
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..f52a0cf88 100644 --- a/networking/udhcp/dhcprelay.c +++ b/networking/udhcp/dhcprelay.c | |||
@@ -33,7 +33,8 @@ 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 | #define INIT_G() do { setup_common_bufsiz(); } while (0) | ||
37 | 38 | ||
38 | static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client) | 39 | static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client) |
39 | { | 40 | { |
@@ -257,6 +258,8 @@ int dhcprelay_main(int argc, char **argv) | |||
257 | int num_sockets, max_socket; | 258 | int num_sockets, max_socket; |
258 | uint32_t our_nip; | 259 | uint32_t our_nip; |
259 | 260 | ||
261 | INIT_G(); | ||
262 | |||
260 | server_addr.sin_family = AF_INET; | 263 | server_addr.sin_family = AF_INET; |
261 | server_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST); | 264 | server_addr.sin_addr.s_addr = htonl(INADDR_BROADCAST); |
262 | server_addr.sin_port = htons(SERVER_PORT); | 265 | server_addr.sin_port = htons(SERVER_PORT); |
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/wget.c b/networking/wget.c index 87d3bbd13..c725edb5b 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -146,10 +146,10 @@ struct host_info { | |||
146 | char *host; | 146 | char *host; |
147 | int port; | 147 | int port; |
148 | }; | 148 | }; |
149 | static const char P_FTP[] = "ftp"; | 149 | static const char P_FTP[] ALIGN1 = "ftp"; |
150 | static const char P_HTTP[] = "http"; | 150 | static const char P_HTTP[] ALIGN1 = "http"; |
151 | #if ENABLE_FEATURE_WGET_OPENSSL || ENABLE_FEATURE_WGET_SSL_HELPER | 151 | #if ENABLE_FEATURE_WGET_OPENSSL || ENABLE_FEATURE_WGET_SSL_HELPER |
152 | static const char P_HTTPS[] = "https"; | 152 | static const char P_HTTPS[] ALIGN1 = "https"; |
153 | #endif | 153 | #endif |
154 | 154 | ||
155 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS | 155 | #if ENABLE_FEATURE_WGET_LONG_OPTIONS |
diff --git a/networking/zcip.c b/networking/zcip.c index c93082619..47f3216a0 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,8 +91,8 @@ 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 { setup_common_bufsiz(); } while (0) |
95 | 96 | ||
96 | 97 | ||
97 | /** | 98 | /** |