From spwpun at gmail.com Wed Dec 1 01:41:59 2021 From: spwpun at gmail.com (Ping Lee) Date: Wed, 1 Dec 2021 09:41:59 +0800 Subject: Tar component in busybox version 1.34.1 has a memory leak bug when trying to unpack a tar file. Message-ID: Hi~ It seems that I found a bug on busybox version 1.34.1: In libbb/xfuncs_printf.c:50, malloc twice for archive_handle and archive_hadle->fileheader with 184 and 72 bytes heap space. Back to tar_main function, the two pointers(tar_handle?tar_handle->file_header) hasn't been freed when return. Complie cmds: ``` make O=/path/to/build defconfig make O=/path/to/build menuconfig # and choice ASAN options cd /path/to/build && make -j4 ``` Reproduce cmd: ``` ./busybox_unstripped tar -xf test.tar ``` Backtarce in gdb: ``` [#0] 0x555555e7022e ? tar_main(argc=0x3, argv=0x7fffffffe430) [#1] 0x555555b06aac ? run_applet_no_and_exit(applet_no=0x148, name=0x7fffffffe709 "tar", argv=0x7fffffffe430) [#2] 0x555555b06b6b ? run_applet_and_exit(name=0x7fffffffe709 "tar", argv=0x7fffffffe430) [#3] 0x555555b067cf ? busybox_main(argv=0x7fffffffe430) [#4] 0x555555b06b29 ? run_applet_and_exit(name=0x7fffffffe6f6 "busybox_unstripped", argv=0x7fffffffe428) [#5] 0x555555b06cbf ? main(argc=0x4, argv=0x7fffffffe428) ``` LeakSanitizer log: ``` ================================================================= ==120986==ERROR: LeakSanitizer: detected memory leaks Direct leak of 184 byte(s) in 1 object(s) allocated from: #0 0x7efda806bb40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) #1 0x555577ed8987 in xmalloc /home/zy/packages/dhcp-targets/busybox-1.34.1/libbb/xfuncs_printf.c:50 Indirect leak of 72 byte(s) in 1 object(s) allocated from: #0 0x7efda806bb40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) #1 0x555577ed8987 in xmalloc /home/zy/packages/dhcp-targets/busybox-1.34.1/libbb/xfuncs_printf.c:50 SUMMARY: AddressSanitizer: 256 byte(s) leaked in 2 allocation(s). ``` The attachment is the tar file to test, it's just a simple tar file. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: test.tar Type: application/x-tar Size: 10240 bytes Desc: not available URL: From David.Laight at ACULAB.COM Wed Dec 1 09:22:55 2021 From: David.Laight at ACULAB.COM (David Laight) Date: Wed, 1 Dec 2021 09:22:55 +0000 Subject: Tar component in busybox version 1.34.1 has a memory leak bug when trying to unpack a tar file. In-Reply-To: References: Message-ID: <23c2f47d8d8a4e35a5fad8bfac118357@AcuMS.aculab.com> From: busybox On Behalf Of Ping Lee > Sent: 01 December 2021 01:42 > It seems that I found a bug on busybox version 1.34.1: > In libbb/xfuncs_printf.c:50, malloc twice for archive_handle and archive_hadle->fileheader with 184 and 72 bytes heap space. > Back to tar_main function, the two pointers(tar_handle?tar_handle->file_header) hasn't been freed when return. It can't matter it is a short-lived program that is going to exit. It would only be a problem if the code were in a loop. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) From ariadne at dereferenced.org Wed Dec 1 09:41:21 2021 From: ariadne at dereferenced.org (Ariadne Conill) Date: Wed, 1 Dec 2021 03:41:21 -0600 (CST) Subject: Tar component in busybox version 1.34.1 has a memory leak bug when trying to unpack a tar file. In-Reply-To: <23c2f47d8d8a4e35a5fad8bfac118357@AcuMS.aculab.com> References: <23c2f47d8d8a4e35a5fad8bfac118357@AcuMS.aculab.com> Message-ID: Hi, On Wed, 1 Dec 2021, David Laight wrote: > From: busybox On Behalf Of Ping Lee >> Sent: 01 December 2021 01:42 > >> It seems that I found a bug on busybox version 1.34.1: >> In libbb/xfuncs_printf.c:50, malloc twice for archive_handle and archive_hadle->fileheader with 184 and 72 bytes heap space. > >> Back to tar_main function, the two pointers(tar_handle?tar_handle->file_header) hasn't been freed when return. > > It can't matter it is a short-lived program that is going to exit. > It would only be a problem if the code were in a loop. It can matter: consider large tar files on memory constrained devices. tar may fail to complete correctly, due to running out of memory, and in the process of running out of memory, may invoke the OOM killer in the process, which might kill some other process. Ariadne From farmatito at tiscali.it Wed Dec 1 12:42:43 2021 From: farmatito at tiscali.it (tito) Date: Wed, 1 Dec 2021 13:42:43 +0100 Subject: Tar component in busybox version 1.34.1 has a memory leak bug when trying to unpack a tar file. In-Reply-To: References: <23c2f47d8d8a4e35a5fad8bfac118357@AcuMS.aculab.com> Message-ID: <20211201134243.7006aa77@devuan> On Wed, 1 Dec 2021 03:41:21 -0600 (CST) Ariadne Conill wrote: > Hi, > > On Wed, 1 Dec 2021, David Laight wrote: > > > From: busybox On Behalf Of Ping Lee > >> Sent: 01 December 2021 01:42 > > > >> It seems that I found a bug on busybox version 1.34.1: > >> In libbb/xfuncs_printf.c:50, malloc twice for archive_handle and archive_hadle->fileheader with 184 and 72 bytes heap space. > > > >> Back to tar_main function, the two pointers(tar_handle?tar_handle->file_header) hasn't been freed when return. > > > > It can't matter it is a short-lived program that is going to exit. > > It would only be a problem if the code were in a loop. > > It can matter: consider large tar files on memory constrained devices. > tar may fail to complete correctly, due to running out of memory, and in > the process of running out of memory, may invoke the OOM killer in the > process, which might kill some other process. > > Ariadne Hi, // Die if we can't allocate size bytes of memory. void* FAST_FUNC xmalloc(size_t size) { void *ptr = malloc(size); if (ptr == NULL && size != 0) bb_die_memory_exhausted(); return ptr; } Ciao, Tito From mconrad at intellitree.com Wed Dec 1 20:17:42 2021 From: mconrad at intellitree.com (Michael Conrad) Date: Wed, 01 Dec 2021 20:17:42 +0000 (UTC) Subject: Tar component in busybox version 1.34.1 has a memory leak bug when trying to unpack a tar file. In-Reply-To: <20211201134243.7006aa77@devuan> References: <23c2f47d8d8a4e35a5fad8bfac118357@AcuMS.aculab.com> <20211201134243.7006aa77@devuan> Message-ID: On 12/1/21 7:42 AM, tito wrote: > >> It can matter: consider large tar files on memory constrained devices. >> tar may fail to complete correctly, due to running out of memory, and in >> the process of running out of memory, may invoke the OOM killer in the >> process, which might kill some other process. >> >> Ariadne > Hi, > > // Die if we can't allocate size bytes of memory. > void* FAST_FUNC xmalloc(size_t size) > { > void *ptr = malloc(size); > if (ptr == NULL && size != 0) > bb_die_memory_exhausted(); > return ptr; > } > > Ciao, > Tito A stock Linux system will happily slaughter your system services with the OOM killer before malloc ever returns NULL. In fact, I think the only way I've ever seen a program get NULL from malloc is if it exhausts 32-bit address space. But, anyone assembling a embedded system has to be aware of the proper way to configure the OOM killer to kill the correct things first, so tar shouldn't be running with any privileges that would cause a real problem. But back to the original question, > Hi~ > > It seems that I found a bug on busybox version 1.34.1: > In libbb/xfuncs_printf.c:50, malloc twice for archive_handle and > archive_hadle->fileheader with 184 and 72 bytes heap space. > > Back to tar_main function, the two pointers(tar_handle?tar_handle->file_header) > hasn't been freed when return. This isn't a bug. Busybox frequently leaves out the 'free()' operations for anything that is a one-time allocation for the life of the process, because freeing it does nothing more than take up space and time. Memory allocation tools will produce lots of errors when you use them on busybox. It only needs fixed if the memory usage *grows un-bounded* during execution. From ska-dietlibc at skarnet.org Wed Dec 1 20:58:27 2021 From: ska-dietlibc at skarnet.org (Laurent Bercot) Date: Wed, 01 Dec 2021 20:58:27 +0000 Subject: Tar component in busybox version 1.34.1 has a memory leak bug when trying to unpack a tar file. In-Reply-To: References: <23c2f47d8d8a4e35a5fad8bfac118357@acums.aculab.com> <20211201134243.7006aa77@devuan> Message-ID: >A stock Linux system will happily slaughter your system services with the OOM killer before malloc ever returns NULL. Only if overcommit is activated, which is not a good idea in embedded systems where busybox is likely to be used. Also, resource limits are a thing, and proper administration practices make use of them. malloc returning NULL is not so far out as people think it is, far from it. It *does* happen. -- Laurent From zajec5 at gmail.com Mon Dec 6 11:56:27 2021 From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=) Date: Mon, 6 Dec 2021 12:56:27 +0100 Subject: xxd: incompatible -p option Message-ID: Hi, I deal with ~4 MiB of binary data stored as hex numbers in 1-line text file. I need to convert numbers to raw binary data. That can be done with -r -p options. With standalone xxd it works perfectly fine: $ cat data.bin | xxd -r -p | wc -c 3518210 With busybox not so much: $ cat data.bin | busybox xxd -r -p | wc -c 30 It seems that -p option implies -c 20 while it should be -c ?: $ cat data.bin | busybox xxd -r -p -c 999999999 | wc -c 3518210 Is that someting that could be fixed? -- Rafa? From henrique at nic.br Wed Dec 8 14:20:00 2021 From: henrique at nic.br (Henrique de Moraes Holschuh) Date: Wed, 8 Dec 2021 11:20:00 -0300 Subject: [PATCH 3/3] nslookup: query class: remove support for class HS and ANY In-Reply-To: References: Message-ID: Remove the support for classes HS (Hesiod) and ANY (wildcard), and with these gone, also remove the nice, table-driven support for specifying query classes and use an if(strcasecmp()) hardcoded tree instead. This reduces some functionality and results in uglier code, but it does decrease the size of the "query class" support. NOTE: This change should not be applied if the decrease in size is not considered worth the functionality and code quality loss. I personally feel it is *not* worth the 19 bytes reduction in size. With this change: function old new delta nslookup_main 945 955 +10 .rodata 95465 95468 +3 qclasses 32 - -32 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 2/0 up/down: 13/-32) Total: -19 bytes It brings down the "query class" feature cost to 179 - 19 = 154 bytes. Signed-off-by: Henrique de Moraes Holschuh --- networking/nslookup.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/networking/nslookup.c b/networking/nslookup.c index 1cbf8becc..664ed84cc 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -270,16 +270,6 @@ struct query { // unsigned char reply[512]; }; -static const struct { - int class; - char name[3]; -} qclasses[] ALIGN1 = { - { C_IN, "IN" }, - { C_CHAOS, "CH" }, - { C_HS, "HS" }, - { C_ANY, "ANY" }, -}; - static const struct { unsigned char type; char name[7]; @@ -949,14 +939,12 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) option_mask32 |= OPT_debug; } if (i == 5) { - for (i = 0;; i++) { - if (i >= ARRAY_SIZE(qclasses)) - bb_error_msg_and_die("invalid query class \"%s\"", val); - if (strcasecmp(qclasses[i].name, val) == 0) { - G.query_class = qclasses[i].class; - break; - } - } + if (strcasecmp("IN", val) == 0) + G.query_class = C_IN; + else if (strcasecmp("CH", val) == 0) + G.query_class = C_CHAOS; + else + bb_error_msg_and_die("invalid query class \"%s\"", val); } if (i > 5) { G.default_timeout = xatou_range(val, 1, INT_MAX / 1000); -- 2.20.1 From henrique at nic.br Wed Dec 8 14:19:59 2021 From: henrique at nic.br (Henrique de Moraes Holschuh) Date: Wed, 8 Dec 2021 11:19:59 -0300 Subject: [PATCH 2/3] nslookup: query class: move query_class to a global In-Reply-To: References: Message-ID: Size optimization: move the query class to a global static variable, this decreases overall code size, but increases BSS by sizeof int. This commit results in: function old new delta add_query 117 114 -3 nslookup_main 959 945 -14 add_query_with_search 160 141 -19 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-36) Total: -36 bytes This brings down the size cost of the "query class" feature to: 209 - 36 = 173 bytes. Signed-off-by: Henrique de Moraes Holschuh --- networking/nslookup.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/networking/nslookup.c b/networking/nslookup.c index 35e29eaae..1cbf8becc 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -327,6 +327,7 @@ struct globals { unsigned default_timeout; unsigned query_count; unsigned serv_count; + int query_class; struct ns *server; struct query *query; char *search; @@ -339,6 +340,7 @@ struct globals { G.default_port = 53; \ G.default_retry = 2; \ G.default_timeout = 5; \ + G.query_class = C_IN; \ } while (0) enum { @@ -782,7 +784,7 @@ static void parse_resolvconf(void) G.search = NULL; } -static void add_query(int class, int type, const char *dname) +static void add_query(int type, const char *dname) { struct query *new_q; unsigned count; @@ -793,10 +795,10 @@ static void add_query(int class, int type, const char *dname) G.query = xrealloc_vector(G.query, /*4=2^2:*/ 2, count); new_q = &G.query[count]; - dbg("new query#%u class %u type %u for '%s'\n", count, class, type, dname); + dbg("new query#%u class %u type %u for '%s'\n", count, G.query_class, type, dname); new_q->name = dname; - qlen = res_mkquery(QUERY, dname, class, type, + qlen = res_mkquery(QUERY, dname, G.query_class, type, /*data:*/ NULL, /*datalen:*/ 0, /*newrr:*/ NULL, new_q->query, sizeof(new_q->query) @@ -804,12 +806,12 @@ static void add_query(int class, int type, const char *dname) new_q->qlen = qlen; } -static void add_query_with_search(int class, int type, const char *dname) +static void add_query_with_search(int type, const char *dname) { char *s; if (type == T_PTR || !G.search || strchr(dname, '.')) { - add_query(class, type, dname); + add_query(type, dname); return; } @@ -819,7 +821,7 @@ static void add_query_with_search(int class, int type, const char *dname) e = skip_non_whitespace(s); fullname = xasprintf("%s.%.*s", dname, (int)(e - s), s); - add_query(class, type, fullname); + add_query(type, fullname); s = skip_whitespace(e); if (!*s) break; @@ -862,7 +864,6 @@ int nslookup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int nslookup_main(int argc UNUSED_PARAM, char **argv) { unsigned types; - int qclass; int rc; int err; @@ -872,7 +873,6 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) * if they precede the arguments and are prefixed with a hyphen." */ types = 0; - qclass = C_IN; argv++; for (;;) { const char *options = @@ -953,7 +953,7 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) if (i >= ARRAY_SIZE(qclasses)) bb_error_msg_and_die("invalid query class \"%s\"", val); if (strcasecmp(qclasses[i].name, val) == 0) { - qclass = qclasses[i].class; + G.query_class = qclasses[i].class; break; } } @@ -986,18 +986,18 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) ptr = make_ptr(argv[0]); if (ptr) { - add_query(qclass, T_PTR, ptr); + add_query(T_PTR, ptr); } else { - add_query_with_search(qclass, T_A, argv[0]); + add_query_with_search(T_A, argv[0]); #if ENABLE_FEATURE_IPV6 - add_query_with_search(qclass, T_AAAA, argv[0]); + add_query_with_search(T_AAAA, argv[0]); #endif } } else { int c; for (c = 0; c < ARRAY_SIZE(qtypes); c++) { if (types & (1 << c)) - add_query_with_search(qclass, qtypes[c].type, argv[0]); + add_query_with_search(qtypes[c].type, argv[0]); } } -- 2.20.1 From henrique at nic.br Wed Dec 8 14:19:58 2021 From: henrique at nic.br (Henrique de Moraes Holschuh) Date: Wed, 8 Dec 2021 11:19:58 -0300 Subject: [PATCH 1/3] nslookup: add support for DNS query class In-Reply-To: References: Message-ID: There is more (although not *much* more) to the DNS than class IN, and the major implementations of nslookup do support the other query classes. Class CH is relevant for dnsops, e.g. when dealing with DNS anycast (see RFC7108) and looking for specific DNS server information (such as the classic "version.bind" query). This is the full-feature proposal (supports also HS and ANY query classes) with better code readability and no increase in bss usage. make bloatcheck against master, after this commit is applied: function old new delta nslookup_main 848 959 +111 qclasses - 32 +32 .rodata 95434 95465 +31 add_query_with_search 141 160 +19 packed_usage 34128 34140 +12 add_query 113 117 +4 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 5/0 up/down: 209/0) Total: 209 bytes Signed-off-by: Henrique de Moraes Holschuh --- networking/nslookup.c | 49 +++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/networking/nslookup.c b/networking/nslookup.c index de7b5c0e7..35e29eaae 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -21,7 +21,7 @@ //kbuild:lib-$(CONFIG_NSLOOKUP) += nslookup.o //usage:#define nslookup_trivial_usage -//usage: IF_FEATURE_NSLOOKUP_BIG("[-type=QUERY_TYPE] [-debug] ") "HOST [DNS_SERVER]" +//usage: IF_FEATURE_NSLOOKUP_BIG("[-class=QUERY_CLASS] [-type=QUERY_TYPE] [-debug] ") "HOST [DNS_SERVER]" //usage:#define nslookup_full_usage "\n\n" //usage: "Query DNS about HOST" //usage: IF_FEATURE_NSLOOKUP_BIG("\n") @@ -270,6 +270,16 @@ struct query { // unsigned char reply[512]; }; +static const struct { + int class; + char name[3]; +} qclasses[] ALIGN1 = { + { C_IN, "IN" }, + { C_CHAOS, "CH" }, + { C_HS, "HS" }, + { C_ANY, "ANY" }, +}; + static const struct { unsigned char type; char name[7]; @@ -772,7 +782,7 @@ static void parse_resolvconf(void) G.search = NULL; } -static void add_query(int type, const char *dname) +static void add_query(int class, int type, const char *dname) { struct query *new_q; unsigned count; @@ -783,10 +793,10 @@ static void add_query(int type, const char *dname) G.query = xrealloc_vector(G.query, /*4=2^2:*/ 2, count); new_q = &G.query[count]; - dbg("new query#%u type %u for '%s'\n", count, type, dname); + dbg("new query#%u class %u type %u for '%s'\n", count, class, type, dname); new_q->name = dname; - qlen = res_mkquery(QUERY, dname, C_IN, type, + qlen = res_mkquery(QUERY, dname, class, type, /*data:*/ NULL, /*datalen:*/ 0, /*newrr:*/ NULL, new_q->query, sizeof(new_q->query) @@ -794,12 +804,12 @@ static void add_query(int type, const char *dname) new_q->qlen = qlen; } -static void add_query_with_search(int type, const char *dname) +static void add_query_with_search(int class, int type, const char *dname) { char *s; if (type == T_PTR || !G.search || strchr(dname, '.')) { - add_query(type, dname); + add_query(class, type, dname); return; } @@ -809,7 +819,7 @@ static void add_query_with_search(int type, const char *dname) e = skip_non_whitespace(s); fullname = xasprintf("%s.%.*s", dname, (int)(e - s), s); - add_query(type, fullname); + add_query(class, type, fullname); s = skip_whitespace(e); if (!*s) break; @@ -852,6 +862,7 @@ int nslookup_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int nslookup_main(int argc UNUSED_PARAM, char **argv) { unsigned types; + int qclass; int rc; int err; @@ -861,6 +872,7 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) * if they precede the arguments and are prefixed with a hyphen." */ types = 0; + qclass = C_IN; argv++; for (;;) { const char *options = @@ -893,8 +905,9 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) "port\0" /* 2 */ "retry\0" /* 3 */ "debug\0" /* 4 */ + "class\0" /* 5 */ "t\0" /* disambiguate with "type": else -t=2 fails */ - "timeout\0" /* 6 */ + "timeout\0" /* 7 */ ""; int i; char *arg; @@ -935,7 +948,17 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) if (i == 4) { option_mask32 |= OPT_debug; } - if (i > 4) { + if (i == 5) { + for (i = 0;; i++) { + if (i >= ARRAY_SIZE(qclasses)) + bb_error_msg_and_die("invalid query class \"%s\"", val); + if (strcasecmp(qclasses[i].name, val) == 0) { + qclass = qclasses[i].class; + break; + } + } + } + if (i > 5) { G.default_timeout = xatou_range(val, 1, INT_MAX / 1000); } } @@ -963,18 +986,18 @@ int nslookup_main(int argc UNUSED_PARAM, char **argv) ptr = make_ptr(argv[0]); if (ptr) { - add_query(T_PTR, ptr); + add_query(qclass, T_PTR, ptr); } else { - add_query_with_search(T_A, argv[0]); + add_query_with_search(qclass, T_A, argv[0]); #if ENABLE_FEATURE_IPV6 - add_query_with_search(T_AAAA, argv[0]); + add_query_with_search(qclass, T_AAAA, argv[0]); #endif } } else { int c; for (c = 0; c < ARRAY_SIZE(qtypes); c++) { if (types & (1 << c)) - add_query_with_search(qtypes[c].type, argv[0]); + add_query_with_search(qclass, qtypes[c].type, argv[0]); } } -- 2.20.1 From henrique at nic.br Wed Dec 8 14:19:57 2021 From: henrique at nic.br (Henrique de Moraes Holschuh) Date: Wed, 8 Dec 2021 11:19:57 -0300 Subject: [PATCH 0/3] nslookup: add -class option (query class) Message-ID: This patch series adds support for nslookup -class=, an standard feature that is present in other major implementations of nslookup. If there are any suggestions for changes that are required for this patch set to be accepted in BusyBox, I am willing to implement them. Rationale: Class CH (chaos) is used in dnsops (DNS operations) to publish metadata about the DNS server (this includes recursive resolvers too). It is mainly used to query the remote DNS server's software/version, and to identify which node is answering queries in anycast/cluster setups. When you need this, you *need* this. Moreso when you're doing it remotely (think busybox installed inside a network appliance). Class HS (hesiod) and ANY (wildcard) are of far more limited use right now. Added for completeness (but see coments about the last patch, which is optional and removes them). NIC.br wrote this patch because we'd like to see class CH query support become a bit more generally available in network appliances using embedded BusyBox, such as OpenWRT routers. Patch breakdown: PATCH 1/3: The first patch implements the full feature, and increases code size of the nslookup applet by 209 bytes in AMD64. This is the patch I'd like to see applied to BusyBox. PATCH 2/3: The second patch is optional, and increases BSS size by the size of an int, in order to reduce the overall code size increase (in AMD64) by 36 bytes. If this is considered a good tradeoff, it could be applied. PATCH 3/3: The last patch is *very* optional, to be used only if it is the only way this additional nslookup feature would be accepted into busybox. It removes support for class HS and ANY, and uses some ugly coding to further reduce size by 19 bytes in AMD64. Code size changes were measured using "make bloatcheck" on a Debian 10 AMD64 host, default compiler (gcc). Henrique de Moraes Holschuh (3): nslookup: add support for DNS query class nslookup: query class: move query_class to a global nslookup: query class: remove support for class HS and ANY networking/nslookup.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) -- 2.20.1 From danomimanchego123 at gmail.com Thu Dec 9 00:35:52 2021 From: danomimanchego123 at gmail.com (Danomi Manchego) Date: Wed, 8 Dec 2021 19:35:52 -0500 Subject: udhcpc6 client_id option bug Message-ID: maybHi, I've been using BusyBox 1.34.1 for IPv6 stuff. I noticed that the DHCPv6 RELEASE does not include the client ID option (required by RFC8415, sec. 18.2.7), even though there is code to do it in send_d6_release: /* Client-id */ ci = udhcp_find_option(client_data.options, D6_OPT_CLIENTID); if (ci) opt_ptr = mempcpy(opt_ptr, ci->data, D6_OPT_DATA + 2+2 + 6); When udhcpc6 first starts, it creates its own client ID option if none is provided, so it *should* be there: clientid_mac_ptr = NULL; if (!udhcp_find_option(client_data.options, D6_OPT_CLIENTID)) { /* not set, set the default client ID */ clientid_mac_ptr = udhcp_insert_new_option( &client_data.options, D6_OPT_CLIENTID, 2+2 + 6, /*dhcp6:*/ 1); clientid_mac_ptr += 2+2; /* skip option code, len */ clientid_mac_ptr[1] = 3; /* DUID-LL */ clientid_mac_ptr[3] = 1; /* type: ethernet */ clientid_mac_ptr += 2+2; /* skip DUID-LL, ethernet */ } I found that even if I insert another udhcp_find_option after the udhcp_insert_new_option call, the just-now-added option is *still* not found. I think it is due to an issue with the OPT_CODE handling. D6_OPT_CLIENTID is 1, so it fits within a single byte but nonetheless, the following occurs: * udhcp_insert_new_option treats code for IPv6 as follows: new->data[D6_OPT_CODE] = code >> 8; new->data[D6_OPT_CODE + 1] = code & 0xff; * udhcp_find_option tests the code as follows: while (opt_list && opt_list->data[OPT_CODE] < code) ... if (opt_list && opt_list->data[OPT_CODE] == code) So yes, OPT_CODE and D6_OPT_CODE are both 0, but the D6_OPT_CLIENTID = 1 value means that the 1 is in the seconds byte, and udhcp_find_option is only looking at the first byte, So the send_d6_release can never find it the created option. Maybe udhcp_find_option needs a "bool dhcpv6" arg just like udhcp_insert_new_option, or else maybe there needs to be a udhcp_find_option6 option? Danomi - From David.Laight at ACULAB.COM Thu Dec 9 09:07:22 2021 From: David.Laight at ACULAB.COM (David Laight) Date: Thu, 9 Dec 2021 09:07:22 +0000 Subject: [PATCH 3/3] nslookup: query class: remove support for class HS and ANY In-Reply-To: References: Message-ID: From: Moraes Holschuh > Sent: 08 December 2021 14:20 > > Remove the support for classes HS (Hesiod) and ANY (wildcard), and with > these gone, also remove the nice, table-driven support for specifying > query classes and use an if(strcasecmp()) hardcoded tree instead. > > This reduces some functionality and results in uglier code, but it does > decrease the size of the "query class" support. > > NOTE: This change should not be applied if the decrease in size is not > considered worth the functionality and code quality loss. I personally > feel it is *not* worth the 19 bytes reduction in size. Personally I suspect that modern systems aren't as memory/disc constrained as those when busybox was first written. So additional code in a paged executable doesn't matter as much. Very small systems are actually unlikely to nslookup at all. This also applies to some of the other applets. The defaults could include all the 'expected' options that only increase the code size by a few hundred bytes. Indeed all the relevant options could be hidden behind a big 'optimise applets for size' option. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) From peter at korsgaard.com Fri Dec 10 13:29:41 2021 From: peter at korsgaard.com (Peter Korsgaard) Date: Fri, 10 Dec 2021 14:29:41 +0100 Subject: [PATCH] libarchive/get_header_ar.c: fix extraction of archives from binutils in deterministic mode In-Reply-To: <20211126153857.23988-1-peter@korsgaard.com> (Peter Korsgaard's message of "Fri, 26 Nov 2021 16:38:57 +0100") References: <20211126153857.23988-1-peter@korsgaard.com> Message-ID: <87r1ak4mgq.fsf@dell.be.48ers.dk> >>>>> "Peter" == Peter Korsgaard writes: > GNU binutils in deterministic mode (ar rD or built with > --enable-deterministic-archives) hard codes file mode to 0644 (NOT 0100644) > since https://github.com/bminor/binutils-gdb/commit/36e4dce69dd2 > This confuses busybox ar x (data_extract_all): > touch a; ar rD a.ar a > ar: creating a.ar > busybox ar x a.ar > ar: unrecognized file type > hexdump -C a.ar > 00000000 21 3c 61 72 63 68 3e 0a 61 2f 20 20 20 20 20 20 |!.a/ | > 00000010 20 20 20 20 20 20 20 20 30 20 20 20 20 20 20 20 | 0 | > 00000020 20 20 20 20 30 20 20 20 20 20 30 20 20 20 20 20 | 0 0 | > 00000030 36 34 34 20 20 20 20 20 30 20 20 20 20 20 20 20 |644 0 | > 00000040 20 20 60 0a | `.| > As a workaround, force the mode bits to S_IFREG, as nothing else makes sense > for ar. Ping? > Signed-off-by: Peter Korsgaard > --- > archival/libarchive/get_header_ar.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > diff --git a/archival/libarchive/get_header_ar.c b/archival/libarchive/get_header_ar.c > index 3a19d6ff7..6bd897392 100644 > --- a/archival/libarchive/get_header_ar.c > +++ b/archival/libarchive/get_header_ar.c > @@ -92,8 +92,12 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle) > /* Only size is always present, the rest may be missing in > * long filename pseudo file. Thus we decode the rest > * after dealing with long filename pseudo file. > + * > + * GNU binutils in deterministic mode hard codes mode to 0644 (NOT > + * 0100644). AR archives can only contain files, so force file > + * mode. > */ > - typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode)); > + typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode)) | S_IFREG; > typed-> gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid)); > typed-> uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid)); > typed-> mtime = read_num(ar.formatted.date, 10, sizeof(ar.formatted.date)); > -- > 2.20.1 -- Bye, Peter Korsgaard From alex_y_xu at yahoo.ca Fri Dec 10 15:01:07 2021 From: alex_y_xu at yahoo.ca (Alex Xu (Hello71)) Date: Fri, 10 Dec 2021 10:01:07 -0500 Subject: [PATCH] find: fix -exec + flush with parens References: <20211210150107.134564-1-alex_y_xu.ref@yahoo.ca> Message-ID: <20211210150107.134564-1-alex_y_xu@yahoo.ca> With CONFIG_FEATURE_FIND_PAREN=y: function old new delta find_main 598 618 +20 With CONFIG_FEATURE_FIND_PAREN=n, no change. Fixes https://bugs.busybox.net/show_bug.cgi?id=12881. --- findutils/find.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/findutils/find.c b/findutils/find.c index fdc5c152d..0d1be36bc 100644 --- a/findutils/find.c +++ b/findutils/find.c @@ -560,6 +560,12 @@ static char *strcpy_upcase(char *dst, const char *src) } #endif +#if ENABLE_FEATURE_FIND_PAREN +ACTF(paren) +{ + return exec_actions(ap->subexpr, fileName, statbuf); +} +#endif ACTF(name) { int r; @@ -812,11 +818,10 @@ ACTF(exec) return do_exec(ap, fileName); } # if ENABLE_FEATURE_FIND_EXEC_PLUS -static int flush_exec_plus(void) +static int flush_exec_plus(action ***appp) { action *ap; action **app; - action ***appp = G.actions; while ((app = *appp++) != NULL) { while ((ap = *app++) != NULL) { if (ap->f == (action_fp)func_exec) { @@ -830,6 +835,11 @@ static int flush_exec_plus(void) return 1; } } +# if ENABLE_FEATURE_FIND_PAREN + if (ap->f == (action_fp)func_paren) { + return flush_exec_plus(((action_paren *)ap)->subexpr); + } +# endif } } return 0; @@ -860,12 +870,6 @@ ACTF(print) puts(fileName); return TRUE; } -#if ENABLE_FEATURE_FIND_PAREN -ACTF(paren) -{ - return exec_actions(ap->subexpr, fileName, statbuf); -} -#endif #if ENABLE_FEATURE_FIND_SIZE ACTF(size) { @@ -1679,6 +1683,6 @@ int find_main(int argc UNUSED_PARAM, char **argv) } } - IF_FEATURE_FIND_EXEC_PLUS(G.exitstatus |= flush_exec_plus();) + IF_FEATURE_FIND_EXEC_PLUS(G.exitstatus |= flush_exec_plus(G.actions);) return G.exitstatus; } -- 2.34.1 From nolange79 at gmail.com Fri Dec 10 21:17:10 2021 From: nolange79 at gmail.com (Norbert Lange) Date: Fri, 10 Dec 2021 22:17:10 +0100 Subject: How to go forward with zstd Message-ID: Hello, the question is still open whether BB is ok with taking the upstream zstd sources and semi-automatically export them [1]. cost is around 17K in binary size with a few manual code removals, ie- without diverting from upstream too much. That code is also available on github [2] upstream would be willing to support continuous testing, should we have some modifications that can end up there (ie. separate codepaths guarded by macros). So probably that would mean getting the sources exported *fully* automated, then check if those compile and work with some testing stubs. [3] Please respond on whats supposed to happen now. Regards, Norbert [1] http://lists.busybox.net/pipermail/busybox/2021-September/089235.html [2] https://github.com/nolange/busybox/commits/zstdapplets [3] https://github.com/facebook/zstd/issues/2806 From vda.linux at googlemail.com Sun Dec 12 02:21:38 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 12 Dec 2021 03:21:38 +0100 Subject: [PATCH] wget: custom Content-Type for --post-data and --post-file In-Reply-To: References: Message-ID: THe patch is whitespace-damaged. Also buggy if !ENABLE_FEATURE_WGET_AUTHENTICATION. Fixed and applied. On Mon, Oct 18, 2021 at 8:03 PM Ildar Shaimordanov wrote: > > Allow end-users to customize Content-Type for --post-data and --post-file. > > More explanation in this PR: https://github.com/rmyorston/busybox-w32/pull/233 > > The real use-case: > wget https://api.github.com/markdown/raw --header "Content-Type: text/plain" > > Signed-off-by: Ildar Shaimordanov > --- > networking/wget.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/networking/wget.c b/networking/wget.c > index 91ef99eab..789979c1a 100644 > --- a/networking/wget.c > +++ b/networking/wget.c > @@ -213,6 +213,7 @@ enum { > HDR_RANGE = (1<<2), > HDR_AUTH = (1<<3) * ENABLE_FEATURE_WGET_AUTHENTICATION, > HDR_PROXY_AUTH = (1<<4) * ENABLE_FEATURE_WGET_AUTHENTICATION, > + HDR_CONTENT_TYPE = (1<<5), > }; > static const char wget_user_headers[] ALIGN1 = > "Host:\0" > @@ -222,18 +223,21 @@ static const char wget_user_headers[] ALIGN1 = > "Authorization:\0" > "Proxy-Authorization:\0" > # endif > + "Content-Type:\0" > ; > # define USR_HEADER_HOST (G.user_headers & HDR_HOST) > # define USR_HEADER_USER_AGENT (G.user_headers & HDR_USER_AGENT) > # define USR_HEADER_RANGE (G.user_headers & HDR_RANGE) > # define USR_HEADER_AUTH (G.user_headers & HDR_AUTH) > # define USR_HEADER_PROXY_AUTH (G.user_headers & HDR_PROXY_AUTH) > +# define USR_HEADER_CONTENT_TYPE (G.user_headers & HDR_CONTENT_TYPE) > #else /* No long options, no user-headers :( */ > # define USR_HEADER_HOST 0 > # define USR_HEADER_USER_AGENT 0 > # define USR_HEADER_RANGE 0 > # define USR_HEADER_AUTH 0 > # define USR_HEADER_PROXY_AUTH 0 > +# define USR_HEADER_CONTENT_TYPE 0 > #endif > > /* Globals */ > @@ -1261,8 +1265,13 @@ static void download_one_url(const char *url) > } > > if (G.post_data) { > + /* Don't overwrite the user-specified header */ > + if (!USR_HEADER_CONTENT_TYPE) { > + SENDFMT(sfp, > + "Content-Type: application/x-www-form-urlencoded\r\n" > + ); > + } > SENDFMT(sfp, > - "Content-Type: application/x-www-form-urlencoded\r\n" > "Content-Length: %u\r\n" > "\r\n" > "%s", > -- > 2.28.0 > > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vda.linux at googlemail.com Sun Dec 12 12:17:08 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 12 Dec 2021 13:17:08 +0100 Subject: [PATCH] Makefile.flags: use all cflags for crypt and rt checks In-Reply-To: <20211108163642.10645-1-lists@kaiser.cx> References: <20211108163642.10645-1-lists@kaiser.cx> Message-ID: Applied, thank you. On Mon, Nov 8, 2021 at 5:56 PM Martin Kaiser wrote: > > From: Martin Kaiser > > To check if libcrypt and librt are available, we check if we can > compile and link a simple test program. > > These checks do not match the actual linking if CONFIG_STATIC is enabled. > For CONFIG_STATIC, CFLAGS_busybox is set to -static. The checks don't use > CFLAGS_busybox and detect a shared libcrypt or librt. If we link busybox > later and we have no static libcrypt or librt, linking will fail. > > Update the libcrypt and librt checks to use CFLAGS_busybox. > > Signed-off-by: Martin Kaiser > --- > Makefile.flags | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/Makefile.flags b/Makefile.flags > index 667481983..c34356230 100644 > --- a/Makefile.flags > +++ b/Makefile.flags > @@ -151,8 +151,8 @@ LDLIBS += m > # gcc-4.2.1 fails if we try to feed C source on stdin: > # echo 'int main(void){return 0;}' | $(CC) $(CFLAGS) -lcrypt -o /dev/null -xc - > # fall back to using a temp file: > -CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >bb_libtest.c; $(CC) $(CFLAGS) -lcrypt -o /dev/null bb_libtest.c >/dev/null 2>&1 && echo "y"; rm bb_libtest.c) > -RT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >bb_libtest.c; $(CC) $(CFLAGS) -lrt -o /dev/null bb_libtest.c >/dev/null 2>&1 && echo "y"; rm bb_libtest.c) > +CRYPT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >bb_libtest.c; $(CC) $(CFLAGS) $(CFLAGS_busybox) -lcrypt -o /dev/null bb_libtest.c >/dev/null 2>&1 && echo "y"; rm bb_libtest.c) > +RT_AVAILABLE := $(shell echo 'int main(void){return 0;}' >bb_libtest.c; $(CC) $(CFLAGS) $(CFLAGS_busybox) -lrt -o /dev/null bb_libtest.c >/dev/null 2>&1 && echo "y"; rm bb_libtest.c) > ifeq ($(CRYPT_AVAILABLE),y) > LDLIBS += crypt > endif > -- > 2.20.1 > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vda.linux at googlemail.com Sun Dec 12 15:34:24 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 12 Dec 2021 16:34:24 +0100 Subject: xxd: incompatible -p option In-Reply-To: References: Message-ID: On Mon, Dec 6, 2021 at 12:56 PM Rafa? Mi?ecki wrote: > Hi, > > I deal with ~4 MiB of binary data stored as hex numbers in 1-line text > file. I need to convert numbers to raw binary data. That can be done > with -r -p options. > > With standalone xxd it works perfectly fine: > $ cat data.bin | xxd -r -p | wc -c > 3518210 > > With busybox not so much: > $ cat data.bin | busybox xxd -r -p | wc -c > 30 Can't reproduce with the current git. Can you? From vda.linux at googlemail.com Sun Dec 12 16:17:06 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 12 Dec 2021 17:17:06 +0100 Subject: udhcpc6 client_id option bug In-Reply-To: References: Message-ID: On Thu, Dec 9, 2021 at 1:36 AM Danomi Manchego wrote: > Maybe udhcp_find_option needs a "bool dhcpv6" arg just like > udhcp_insert_new_option, or else maybe there needs to be a > udhcp_find_option6 option? Yes. Done so in git, please try it. From peter0x44 at snopyta.org Sun Dec 12 17:07:58 2021 From: peter0x44 at snopyta.org (Peter0x44) Date: Sun, 12 Dec 2021 17:07:58 +0000 Subject: xxd: incompatible -p option In-Reply-To: References: Message-ID: On Sun Dec 12, 2021 at 3:34 PM GMT, Denys Vlasenko wrote: > On Mon, Dec 6, 2021 at 12:56 PM Rafa? Mi?ecki > wrote: > > Hi, > > > > I deal with ~4 MiB of binary data stored as hex numbers in 1-line text > > file. I need to convert numbers to raw binary data. That can be done > > with -r -p options. > > > > With standalone xxd it works perfectly fine: > > $ cat data.bin | xxd -r -p | wc -c > > 3518210 > > > > With busybox not so much: > > $ cat data.bin | busybox xxd -r -p | wc -c > > 30 > > Can't reproduce with the current git. Can you? I can reproduce using my distribution-provided busybox (v1.34.1), but not with the current git $ cat data.bin | busybox xxd -r -p | wc -c 1930 $ cat data.bin | ./busybox xxd -r -p | wc -c 15444 I bisected it down to commit 86ba007b84ae1ebe35e88c57e023caac3d2d9903 which fixed it for me. Regards, Peter D. From zajec5 at gmail.com Sun Dec 12 17:40:32 2021 From: zajec5 at gmail.com (=?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?=) Date: Sun, 12 Dec 2021 18:40:32 +0100 Subject: xxd: incompatible -p option In-Reply-To: References: Message-ID: <4e739e0a-b2a5-03a2-fde5-beb478066fe5@gmail.com> On 12.12.2021 18:07, Peter0x44 wrote: > On Sun Dec 12, 2021 at 3:34 PM GMT, Denys Vlasenko wrote: >> On Mon, Dec 6, 2021 at 12:56 PM Rafa? Mi?ecki >> wrote: >>> Hi, >>> >>> I deal with ~4 MiB of binary data stored as hex numbers in 1-line text >>> file. I need to convert numbers to raw binary data. That can be done >>> with -r -p options. >>> >>> With standalone xxd it works perfectly fine: >>> $ cat data.bin | xxd -r -p | wc -c >>> 3518210 >>> >>> With busybox not so much: >>> $ cat data.bin | busybox xxd -r -p | wc -c >>> 30 >> >> Can't reproduce with the current git. Can you? > > I can reproduce using my distribution-provided busybox (v1.34.1), but not > with the current git > > $ cat data.bin | busybox xxd -r -p | wc -c > 1930 > $ cat data.bin | ./busybox xxd -r -p | wc -c > 15444 > > I bisected it down to commit 86ba007b84ae1ebe35e88c57e023caac3d2d9903 which fixed it for me. Thanks a lot for finding that for me! From vda.linux at googlemail.com Mon Dec 13 02:24:28 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 13 Dec 2021 03:24:28 +0100 Subject: [PATCH] libarchive/get_header_ar.c: fix extraction of archives from binutils in deterministic mode In-Reply-To: <87r1ak4mgq.fsf@dell.be.48ers.dk> References: <20211126153857.23988-1-peter@korsgaard.com> <87r1ak4mgq.fsf@dell.be.48ers.dk> Message-ID: Applied, thanks! On Fri, Dec 10, 2021 at 2:30 PM Peter Korsgaard wrote: > > >>>>> "Peter" == Peter Korsgaard writes: > > > GNU binutils in deterministic mode (ar rD or built with > > --enable-deterministic-archives) hard codes file mode to 0644 (NOT 0100644) > > since https://github.com/bminor/binutils-gdb/commit/36e4dce69dd2 > > > This confuses busybox ar x (data_extract_all): > > > touch a; ar rD a.ar a > > ar: creating a.ar > > > busybox ar x a.ar > > ar: unrecognized file type > > hexdump -C a.ar > > 00000000 21 3c 61 72 63 68 3e 0a 61 2f 20 20 20 20 20 20 |!.a/ | > > 00000010 20 20 20 20 20 20 20 20 30 20 20 20 20 20 20 20 | 0 | > > 00000020 20 20 20 20 30 20 20 20 20 20 30 20 20 20 20 20 | 0 0 | > > 00000030 36 34 34 20 20 20 20 20 30 20 20 20 20 20 20 20 |644 0 | > > 00000040 20 20 60 0a | `.| > > > As a workaround, force the mode bits to S_IFREG, as nothing else makes sense > > for ar. > > Ping? > > > Signed-off-by: Peter Korsgaard > > --- > > archival/libarchive/get_header_ar.c | 6 +++++- > > 1 file changed, 5 insertions(+), 1 deletion(-) > > > diff --git a/archival/libarchive/get_header_ar.c b/archival/libarchive/get_header_ar.c > > index 3a19d6ff7..6bd897392 100644 > > --- a/archival/libarchive/get_header_ar.c > > +++ b/archival/libarchive/get_header_ar.c > > @@ -92,8 +92,12 @@ char FAST_FUNC get_header_ar(archive_handle_t *archive_handle) > > /* Only size is always present, the rest may be missing in > > * long filename pseudo file. Thus we decode the rest > > * after dealing with long filename pseudo file. > > + * > > + * GNU binutils in deterministic mode hard codes mode to 0644 (NOT > > + * 0100644). AR archives can only contain files, so force file > > + * mode. > > */ > > - typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode)); > > + typed->mode = read_num(ar.formatted.mode, 8, sizeof(ar.formatted.mode)) | S_IFREG; > > typed-> gid = read_num(ar.formatted.gid, 10, sizeof(ar.formatted.gid)); > > typed-> uid = read_num(ar.formatted.uid, 10, sizeof(ar.formatted.uid)); > > typed-> mtime = read_num(ar.formatted.date, 10, sizeof(ar.formatted.date)); > > -- > > 2.20.1 > > -- > Bye, Peter Korsgaard > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vincent.stehle at arm.com Mon Dec 13 09:07:18 2021 From: vincent.stehle at arm.com (=?UTF-8?q?Vincent=20Stehl=C3=A9?=) Date: Mon, 13 Dec 2021 10:07:18 +0100 Subject: [PATCH] fdisk: recognize EBBR protective partitions Message-ID: <20211213090718.18837-1-vincent.stehle@arm.com> The MBR partition type 0xF8 is used by the Arm EBBR specification[1] for protective partitions over fixed-location firmware images. [1]: https://github.com/ARM-software/ebbr Signed-off-by: Vincent Stehl? --- util-linux/fdisk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c index 1c2a7d683..664830357 100644 --- a/util-linux/fdisk.c +++ b/util-linux/fdisk.c @@ -355,6 +355,7 @@ static const char *const i386_sys_types[] ALIGN_PTR = { "\xef" "EFI (FAT-12/16/32)", /* Intel EFI System Partition */ "\xf0" "Linux/PA-RISC boot", /* Linux/PA-RISC boot loader */ "\xf2" "DOS secondary", /* DOS 3.3+ secondary */ + "\xf8" "EBBR protective", /* Arm EBBR firmware protective partition */ "\xfd" "Linux raid autodetect", /* New (2.2.x) raid partition with autodetect using persistent superblock */ -- 2.33.0 From danomimanchego123 at gmail.com Mon Dec 13 13:27:58 2021 From: danomimanchego123 at gmail.com (Danomi Manchego) Date: Mon, 13 Dec 2021 08:27:58 -0500 Subject: udhcpc6 client_id option bug In-Reply-To: References: Message-ID: The mods looks good: I can see in Wireshark that the Client ID option is now included in the release. This in turn allows my IPv6-enabled router to offer that address back to me when I next solicit rather than offering me a different address, now that it is no longer discarding the release message. So - much better. Thank your for your prompt response on this. Regards, Danomi - On Sun, Dec 12, 2021 at 11:17 AM Denys Vlasenko wrote: > > On Thu, Dec 9, 2021 at 1:36 AM Danomi Manchego > wrote: > > > Maybe udhcp_find_option needs a "bool dhcpv6" arg just like > > udhcp_insert_new_option, or else maybe there needs to be a > > udhcp_find_option6 option? > > Yes. Done so in git, please try it. From vda.linux at googlemail.com Mon Dec 13 17:36:34 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Mon, 13 Dec 2021 18:36:34 +0100 Subject: How to go forward with zstd In-Reply-To: References: Message-ID: On Fri, Dec 10, 2021 at 10:17 PM Norbert Lange wrote: > Hello, > > the question is still open whether BB is ok with taking the upstream > zstd sources and semi-automatically export them [1]. cost is around > 17K in binary size with a few manual code removals, ie- without > diverting from upstream too much. That code is also available on > github [2] > > upstream would be willing to support continuous testing, should we > have some modifications that can end up there (ie. separate codepaths > guarded by macros). So probably that would mean getting the sources > exported *fully* automated, then check if those compile and work with > some testing stubs. [3] Well... code as it stands now is not written with much thought about keeping size smaller. I can easily find places which I'm not happy about. Look at this: zstd_internal.h static UNUSED_ATTR const U32 LL_bits[MaxLL+1] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 6, 7, 8, 9,10,11,12, 13,14,15,16 }; static UNUSED_ATTR const S16 LL_defaultNorm[MaxLL+1] = { 4, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 1, 1, 1, 1, -1,-1,-1,-1 }; All "bits" arrays fit into 16 bit ints. All "defaultNorm" arrays fit into 8-bit signed ints. Also, defining arrays in .h files is wrong. I bet with detailed review many more things like this are to be discovered. Anyone is willing to submit patches upstream until it looks better? -- vda From nolange79 at gmail.com Mon Dec 13 23:23:27 2021 From: nolange79 at gmail.com (Norbert Lange) Date: Tue, 14 Dec 2021 00:23:27 +0100 Subject: How to go forward with zstd In-Reply-To: References: Message-ID: Am Mo., 13. Dez. 2021 um 18:36 Uhr schrieb Denys Vlasenko : > > On Fri, Dec 10, 2021 at 10:17 PM Norbert Lange wrote: > > Hello, > > > > the question is still open whether BB is ok with taking the upstream > > zstd sources and semi-automatically export them [1]. cost is around > > 17K in binary size with a few manual code removals, ie- without > > diverting from upstream too much. That code is also available on > > github [2] > > > > upstream would be willing to support continuous testing, should we > > have some modifications that can end up there (ie. separate codepaths > > guarded by macros). So probably that would mean getting the sources > > exported *fully* automated, then check if those compile and work with > > some testing stubs. [3] > > Well... code as it stands now is not written with much thought > about keeping size smaller. I can easily find places > which I'm not happy about. Look at this: Yeah, I just wonder whether you thing its feasible change upstream so that you are satisfied. It is a different project, different goals, it will never be as small as code written from ground up to be small. Some unhappy places would live in a subfolder, always as kinda alien code. How far do you want to change it? > > zstd_internal.h > > static UNUSED_ATTR const U32 LL_bits[MaxLL+1] = { > 0, 0, 0, 0, 0, 0, 0, 0, > 0, 0, 0, 0, 0, 0, 0, 0, > 1, 1, 1, 1, 2, 2, 3, 3, > 4, 6, 7, 8, 9,10,11,12, > 13,14,15,16 > }; > static UNUSED_ATTR const S16 LL_defaultNorm[MaxLL+1] = { > 4, 3, 2, 2, 2, 2, 2, 2, > 2, 2, 2, 2, 2, 1, 1, 1, > 2, 2, 2, 2, 2, 2, 2, 2, > 2, 3, 2, 1, 1, 1, 1, 1, > -1,-1,-1,-1 > }; > > All "bits" arrays fit into 16 bit ints. All "defaultNorm" > arrays fit into 8-bit signed ints. Yeah, did some test, apparently possible to change all of those used for decompression. Gonna review this a bit more and send it upstream. > > Also, defining arrays in .h files is wrong. pointer tricks with errno could be considered wrong ;) My patch just includes all .h and .c files, so it makes no practical difference for us. > > I bet with detailed review many more things like this > are to be discovered. Yeah, some things might be just because of different goals, ie. giving up "small" for "fast". Or keeping the legacy decompressors alive. > Anyone is willing to submit patches upstream > until it looks better? To an extend I am. Norbert From viordash at mail.ru Wed Dec 15 08:28:17 2021 From: viordash at mail.ru (=?UTF-8?B?Vml0YWxpeSBPcmF6b3Y=?=) Date: Wed, 15 Dec 2021 11:28:17 +0300 Subject: =?UTF-8?B?REhDUCBDbGllbnQ6IERIQ1BOQUsgYmVoYXZpb3Ig?= Message-ID: <1639556897.456297749@f511.i.mail.ru> Hi! ? Faced with the issue of not responding to DHCPNAK from another server , I then compared the behavior between busybox udhcp client and isc dhclient when receiving DHCPNAK. And behaviors are different. Your client checks for server_id matching, this check was introduced for the fix, Bug 4267 . But in isc dhclient there is no check for server_id and it seems to me correct, because in rfc2131 I did not find requirements for matching server_id in the request for the client, but I found the following text: RFC 2131?? [Page 17] If the client receives a DHCPNAK message, the client restarts the ???? configuration process. ? Here is another piece of text from rfc2131 , which I believe points to the key moment of using server_id in the client: RFC 2131?? [Page 23] DHCP clients MUST ?? use the IP address provided in the 'server identifier' option for any ?? unicast requests to the DHCP server. ? this is also consistent with rfc2132 : RFC 2132?? [Page 27] DHCP clients use the ?? contents of the 'server identifier' field as the destination address ?? for any DHCP messages unicast to the DHCP server. ? ? PS. Bug?14456 ? Best Regards Vitaliy Orazov -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmy at pobox.com Thu Dec 16 11:19:03 2021 From: rmy at pobox.com (Ron Yorston) Date: Thu, 16 Dec 2021 11:19:03 +0000 Subject: [PATCH] printf: allow 0 as a flag and allow multiple flags Message-ID: <61bb20a7.G2X9IHHbaFM5tDVb%rmy@pobox.com> The '%' character in a format specification may be followed by one or more flags from the list "+- #0". BusyBox printf didn't support the '0' flag or allow multiple flags to be provided. As a result the formats '%0*d' and '%0 d' were considered to be invalid. The lack of support for '0' was pointed out by Andrew Snyder on the musl mailing list: https://www.openwall.com/lists/musl/2021/12/14/2 function old new delta printf_main 860 891 +31 .rodata 99281 99282 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0) Total: 32 bytes Signed-off-by: Ron Yorston --- coreutils/printf.c | 8 +++++--- testsuite/printf.tests | 10 ++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/coreutils/printf.c b/coreutils/printf.c index dd94c8ade..e5cf5f942 100644 --- a/coreutils/printf.c +++ b/coreutils/printf.c @@ -313,9 +313,11 @@ static char **print_formatted(char *f, char **argv, int *conv_err) } break; } - if (*f && strchr("-+ #", *f)) { - ++f; - ++direc_length; + if (*f) { + while (strchr("-+ #0", *f)) { + ++f; + ++direc_length; + } } if (*f == '*') { ++f; diff --git a/testsuite/printf.tests b/testsuite/printf.tests index 050edef71..728bbf4bf 100755 --- a/testsuite/printf.tests +++ b/testsuite/printf.tests @@ -143,4 +143,14 @@ testing "printf aborts on %r" \ "printf: %r: invalid format\n""1\n" \ "" "" +testing "printf treats leading 0 as flag" \ + "${bb}printf '%0*d\n' 2 1 2>&1; echo \$?" \ + "01\n""0\n" \ + "" "" + +testing "printf handles multiple flags" \ + "${bb}printf '%0 d\n' 2 2>&1; echo \$?" \ + " 2\n""0\n" \ + "" "" + exit $FAILCOUNT -- 2.33.1 From vda.linux at googlemail.com Fri Dec 17 20:10:05 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Fri, 17 Dec 2021 21:10:05 +0100 Subject: [PATCH] printf: allow 0 as a flag and allow multiple flags In-Reply-To: <61bb20a7.G2X9IHHbaFM5tDVb%rmy@pobox.com> References: <61bb20a7.G2X9IHHbaFM5tDVb%rmy@pobox.com> Message-ID: On Thu, Dec 16, 2021 at 12:26 PM Ron Yorston wrote: > The '%' character in a format specification may be followed by > one or more flags from the list "+- #0". BusyBox printf didn't > support the '0' flag or allow multiple flags to be provided. > As a result the formats '%0*d' and '%0 d' were considered to be > invalid. > > The lack of support for '0' was pointed out by Andrew Snyder on the > musl mailing list: > > https://www.openwall.com/lists/musl/2021/12/14/2 > > function old new delta > printf_main 860 891 +31 > .rodata 99281 99282 +1 > ------------------------------------------------------------------------------ > (add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0) Total: 32 bytes > > Signed-off-by: Ron Yorston > --- > coreutils/printf.c | 8 +++++--- > testsuite/printf.tests | 10 ++++++++++ > 2 files changed, 15 insertions(+), 3 deletions(-) > > diff --git a/coreutils/printf.c b/coreutils/printf.c > index dd94c8ade..e5cf5f942 100644 > --- a/coreutils/printf.c > +++ b/coreutils/printf.c > @@ -313,9 +313,11 @@ static char **print_formatted(char *f, char **argv, int *conv_err) > } > break; > } > - if (*f && strchr("-+ #", *f)) { > - ++f; > - ++direc_length; > + if (*f) { > + while (strchr("-+ #0", *f)) { > + ++f; > + ++direc_length; > + } This can walk off the end of "f", doesn't it? [strchr("anything", '\0') is not NULL] I propose while (*f && strchr("-+ #0", *f)) { ++f; ++direc_length; } From vda.linux at googlemail.com Fri Dec 17 20:45:12 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Fri, 17 Dec 2021 21:45:12 +0100 Subject: [PATCH] find: implement -samefile In-Reply-To: <20211128101148.9715-1-aaro.koskinen@iki.fi> References: <20211128101148.9715-1-aaro.koskinen@iki.fi> Message-ID: Applied, thanks On Sun, Nov 28, 2021 at 11:28 AM Aaro Koskinen wrote: > > Implement -samefile. > > Signed-off-by: Aaro Koskinen > --- > findutils/find.c | 35 +++++++++++++++++++++++++++++++++++ > 1 file changed, 35 insertions(+) > > diff --git a/findutils/find.c b/findutils/find.c > index fdc5c152d..87fd5b9bc 100644 > --- a/findutils/find.c > +++ b/findutils/find.c > @@ -155,6 +155,13 @@ > //config: default y > //config: depends on FIND > //config: > +//config:config FEATURE_FIND_SAMEFILE > +//config: bool "Enable -samefile: reference file matching" > +//config: default y > +//config: depends on FIND > +//config: help > +//config: Support the 'find -samefile' option for searching by a reference file. > +//config: > //config:config FEATURE_FIND_EXEC > //config: bool "Enable -exec: execute commands" > //config: default y > @@ -350,6 +357,9 @@ > //usage: IF_FEATURE_FIND_INUM( > //usage: "\n -inum N File has inode number N" > //usage: ) > +//usage: IF_FEATURE_FIND_SAMEFILE( > +//usage: "\n -samefile FILE File is same as FILE" > +//usage: ) > //usage: IF_FEATURE_FIND_USER( > //usage: "\n -user NAME/ID File is owned by given user" > //usage: ) > @@ -444,6 +454,7 @@ IF_FEATURE_FIND_MTIME( ACTS(mtime, unsigned char time_type; unsigned char mtime > IF_FEATURE_FIND_MMIN( ACTS(mmin, unsigned char time_type; unsigned char mmin_char; unsigned mmin_mins;)) > IF_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;)) > IF_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;)) > +IF_FEATURE_FIND_SAMEFILE(ACTS(samefile, ino_t inode_num; dev_t device;)) > IF_FEATURE_FIND_USER( ACTS(user, uid_t uid;)) > IF_FEATURE_FIND_SIZE( ACTS(size, char size_char; off_t size;)) > IF_FEATURE_FIND_CONTEXT(ACTS(context, security_context_t context;)) > @@ -731,6 +742,13 @@ ACTF(inum) > return (statbuf->st_ino == ap->inode_num); > } > #endif > +#if ENABLE_FEATURE_FIND_SAMEFILE > +ACTF(samefile) > +{ > + return statbuf->st_ino == ap->inode_num && > + statbuf->st_dev == ap->device; > +} > +#endif > #if ENABLE_FEATURE_FIND_EXEC > static int do_exec(action_exec *ap, const char *fileName) > { > @@ -1125,6 +1143,7 @@ static action*** parse_params(char **argv) > IF_FEATURE_FIND_CMIN( PARM_cmin ,) > IF_FEATURE_FIND_NEWER( PARM_newer ,) > IF_FEATURE_FIND_INUM( PARM_inum ,) > + IF_FEATURE_FIND_SAMEFILE(PARM_samefile ,) > IF_FEATURE_FIND_USER( PARM_user ,) > IF_FEATURE_FIND_GROUP( PARM_group ,) > IF_FEATURE_FIND_SIZE( PARM_size ,) > @@ -1173,6 +1192,7 @@ static action*** parse_params(char **argv) > IF_FEATURE_FIND_CMIN( "-cmin\0" ) > IF_FEATURE_FIND_NEWER( "-newer\0" ) > IF_FEATURE_FIND_INUM( "-inum\0" ) > + IF_FEATURE_FIND_SAMEFILE("-samefile\0") > IF_FEATURE_FIND_USER( "-user\0" ) > IF_FEATURE_FIND_GROUP( "-group\0" ) > IF_FEATURE_FIND_SIZE( "-size\0" ) > @@ -1511,6 +1531,21 @@ static action*** parse_params(char **argv) > ap->inode_num = xatoul(arg1); > } > #endif > +#if ENABLE_FEATURE_FIND_SAMEFILE > + else if (parm == PARM_samefile) { > + action_samefile *ap; > + struct stat stbuf; > + dbg("%d", __LINE__); > + if (G.recurse_flags & (ACTION_FOLLOWLINKS | > + ACTION_FOLLOWLINKS_L0)) > + xstat(arg1, &stbuf); > + else if (lstat(arg1, &stbuf)) > + bb_perror_msg_and_die("can't stat '%s'", arg1); > + ap = ALLOC_ACTION(samefile); > + ap->inode_num = stbuf.st_ino; > + ap->device = stbuf.st_dev; > + } > +#endif > #if ENABLE_FEATURE_FIND_USER > else if (parm == PARM_user) { > action_user *ap; > -- > 2.17.0 > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vda.linux at googlemail.com Fri Dec 17 21:13:27 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Fri, 17 Dec 2021 22:13:27 +0100 Subject: [PATCH] cmp: add support for -n In-Reply-To: <20211125161132.366897-1-walter.lozano@collabora.com> References: <20211125161132.366897-1-walter.lozano@collabora.com> Message-ID: Applied, thank you On Thu, Nov 25, 2021 at 5:12 PM Walter Lozano wrote: > > Add support to for "-n" to cmp in order to compare at most n bytes. > > Signed-off-by: Walter Lozano > --- > editors/cmp.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/editors/cmp.c b/editors/cmp.c > index e106d814e..e219f589a 100644 > --- a/editors/cmp.c > +++ b/editors/cmp.c > @@ -35,9 +35,10 @@ static const char fmt_differ[] ALIGN1 = "%s %s differ: char %"OFF_FMT"u, line %u > // This fmt_l_opt uses gnu-isms. SUSv3 would be "%.0s%.0s%"OFF_FMT"u %o %o\n" > static const char fmt_l_opt[] ALIGN1 = "%.0s%.0s%"OFF_FMT"u %3o %3o\n"; > > -#define OPT_STR "sl" > +#define OPT_STR "sln:" > #define CMP_OPT_s (1<<0) > #define CMP_OPT_l (1<<1) > +#define CMP_OPT_n (1<<2) > > int cmp_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; > int cmp_main(int argc UNUSED_PARAM, char **argv) > @@ -50,13 +51,16 @@ int cmp_main(int argc UNUSED_PARAM, char **argv) > int c1, c2; > unsigned opt; > int retval = 0; > + char * n_arg = NULL; > + int max_count = -1; > > opt = getopt32(argv, "^" > OPT_STR > "\0" "-1" > IF_DESKTOP(":?4") > IF_NOT_DESKTOP(":?2") > - ":l--s:s--l" > + ":l--s:s--l", > + &n_arg > ); > argv += optind; > > @@ -90,6 +94,9 @@ int cmp_main(int argc UNUSED_PARAM, char **argv) > else > fmt = fmt_differ; > > + if (opt & CMP_OPT_n) > + max_count = atoi(n_arg); > + > if (ENABLE_DESKTOP) { > while (skip1) { getc(fp1); skip1--; } > while (skip2) { getc(fp2); skip2--; } > @@ -133,7 +140,7 @@ int cmp_main(int argc UNUSED_PARAM, char **argv) > if (c1 == '\n') { > ++line_pos; > } > - } while (c1 != EOF); > + } while (c1 != EOF && (max_count == -1 || max_count >= 0 && char_pos < max_count)); > > die_if_ferror(fp1, filename1); > die_if_ferror(fp2, filename2); > -- > 2.30.2 > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vda.linux at googlemail.com Fri Dec 17 21:36:01 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Fri, 17 Dec 2021 22:36:01 +0100 Subject: [PATCH v2] ed: add support for -p command-line option as mandated by POSIX In-Reply-To: <20211121112445.19442-1-soeren@soeren-tempel.net> References: <1105fb72-27c3-87f3-3fb2-ba724cf9b7ea@gigawatt.nl> <20211121112445.19442-1-soeren@soeren-tempel.net> Message-ID: Applied, thank you. On Sun, Nov 21, 2021 at 12:25 PM wrote: > > From: S?ren Tempel > > The POSIX.1-2008 specification of ed(1) mandates two command-line > options: -p (for specifying a prompt string) and -s (to suppress writing > of byte counts). This commit adds support for the former. Furthermore, > it also changes the default prompt string to an empty string (instead > of ": ") since this is also mandated by POSIX: > > -p string Use string as the prompt string when in command mode. > By default, there shall be no prompt string. > > Support for the remaining -s option will be added in a separate commit > since it requires a general restructuring of error handling in Busybox > ed. > > Signed-off-by: S?ren Tempel > --- > editors/ed.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/editors/ed.c b/editors/ed.c > index 0d96d263c..a54a0b0a6 100644 > --- a/editors/ed.c > +++ b/editors/ed.c > @@ -48,6 +48,7 @@ struct globals { > char *bufBase; > char *bufPtr; > char *fileName; > + const char *prompt; > LINE lines; > smallint dirty; > int marks[26]; > @@ -57,6 +58,7 @@ struct globals { > #define bufBase (G.bufBase ) > #define bufPtr (G.bufPtr ) > #define fileName (G.fileName ) > +#define prompt (G.prompt ) > #define curNum (G.curNum ) > #define lastNum (G.lastNum ) > #define bufUsed (G.bufUsed ) > @@ -790,7 +792,7 @@ static void doCommands(void) > * 0 on ctrl-C, > * >0 length of input string, including terminating '\n' > */ > - len = read_line_input(NULL, ": ", buf, sizeof(buf)); > + len = read_line_input(NULL, prompt, buf, sizeof(buf)); > if (len <= 0) > return; > while (len && isspace(buf[--len])) > @@ -994,6 +996,8 @@ static void doCommands(void) > int ed_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; > int ed_main(int argc UNUSED_PARAM, char **argv) > { > + int opt; > + > INIT_G(); > > bufSize = INITBUF_SIZE; > @@ -1002,8 +1006,15 @@ int ed_main(int argc UNUSED_PARAM, char **argv) > lines.next = &lines; > lines.prev = &lines; > > - if (argv[1]) { > - fileName = xstrdup(argv[1]); > + opt = getopt32(argv, "p:", &prompt); > + if (!(opt & 0x01)) > + prompt = ""; /* no prompt by default */ > + > + argc -= optind; > + argv += optind; > + > + if (argc >= 1) { > + fileName = xstrdup(argv[0]); > if (!readLines(fileName, 1)) { > return EXIT_SUCCESS; > } > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vda.linux at googlemail.com Fri Dec 17 22:10:26 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Fri, 17 Dec 2021 23:10:26 +0100 Subject: [PATCH] timeout: Add support for "-k" parameter. In-Reply-To: References: Message-ID: On Sat, Oct 9, 2021 at 1:28 PM Matthew Slowe wrote: > Add support for GNU coreutils "-k" parameter to timeout applet. > > This patch moves the timing and process checking code into a separate > reusable function and adds a optional second timeout which will send a > SIGKILL to the process if it's still alive. /* Just sleep(HUGE_NUM); kill(parent) may kill wrong process! */ - while (1) { - sleep1(); - if (--timeout <= 0) - break; - if (kill(parent, 0)) { - /* process is gone */ + if (timeout_wait(timeout, pid) == EXIT_SUCCESS) You waiting for a wrong process: should be "parent", not "pid" (pid is 0 here). + return EXIT_SUCCESS; + kill(parent, signo); + + if (kill_timeout > 0) { + if (timeout_wait(kill_timeout, pid) == EXIT_SUCCESS) Here too. return EXIT_SUCCESS; - } + kill(parent, SIGKILL); } - kill(parent, signo); From David.Laight at ACULAB.COM Sun Dec 19 13:50:14 2021 From: David.Laight at ACULAB.COM (David Laight) Date: Sun, 19 Dec 2021 13:50:14 +0000 Subject: [PATCH] printf: allow 0 as a flag and allow multiple flags In-Reply-To: References: <61bb20a7.G2X9IHHbaFM5tDVb%rmy@pobox.com> Message-ID: From: Denys Vlasenko > Sent: 17 December 2021 20:10 > > On Thu, Dec 16, 2021 at 12:26 PM Ron Yorston wrote: > > The '%' character in a format specification may be followed by > > one or more flags from the list "+- #0". BusyBox printf didn't > > support the '0' flag or allow multiple flags to be provided. > > As a result the formats '%0*d' and '%0 d' were considered to be > > invalid. > > > > The lack of support for '0' was pointed out by Andrew Snyder on the > > musl mailing list: > > > > https://www.openwall.com/lists/musl/2021/12/14/2 > > > > function old new delta > > printf_main 860 891 +31 > > .rodata 99281 99282 +1 > > ------------------------------------------------------------------------------ > > (add/remove: 0/0 grow/shrink: 2/0 up/down: 32/0) Total: 32 bytes > > > > Signed-off-by: Ron Yorston > > --- > > coreutils/printf.c | 8 +++++--- > > testsuite/printf.tests | 10 ++++++++++ > > 2 files changed, 15 insertions(+), 3 deletions(-) > > > > diff --git a/coreutils/printf.c b/coreutils/printf.c > > index dd94c8ade..e5cf5f942 100644 > > --- a/coreutils/printf.c > > +++ b/coreutils/printf.c > > @@ -313,9 +313,11 @@ static char **print_formatted(char *f, char **argv, int *conv_err) > > } > > break; > > } > > - if (*f && strchr("-+ #", *f)) { > > - ++f; > > - ++direc_length; > > + if (*f) { > > + while (strchr("-+ #0", *f)) { > > + ++f; > > + ++direc_length; > > + } > > This can walk off the end of "f", doesn't it? > [strchr("anything", '\0') is not NULL] > I propose > > while (*f && strchr("-+ #0", *f)) { > ++f; > ++direc_length; > } Or: tmp = strspn(f, "-+ #0"); direc_length += tmp - f; f = tmp; Except that I'd have thought it would need to remember which flags are set. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) From rmy at pobox.com Sun Dec 19 14:58:25 2021 From: rmy at pobox.com (Ron Yorston) Date: Sun, 19 Dec 2021 14:58:25 +0000 Subject: [PATCH] printf: allow 0 as a flag and allow multiple flags In-Reply-To: References: <61bb20a7.G2X9IHHbaFM5tDVb%rmy@pobox.com> Message-ID: <61bf4891.9vMtZmfC6NdlgkJ3%rmy@pobox.com> David Laight wrote: >Or: > tmp = strspn(f, "-+ #0"); > direc_length += tmp - f; > f = tmp; Yes, that seems to work too, and it saves 28 bytes. Though since strspn() returns the length of the initial segment it needs to be: size_t tmp; ... tmp = strspn(f, "-+ #0"); direc_length += tmp; f += tmp; >Except that I'd have thought it would need to remember which flags are set. They're retained in the format string which is pointed to by direc_start. Ron From vda.linux at googlemail.com Sun Dec 19 22:16:37 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 19 Dec 2021 23:16:37 +0100 Subject: [PATCH] ed: fix current line number for file passed via the command-line In-Reply-To: <20211117140853.20743-1-soeren@soeren-tempel.net> References: <20211117140853.20743-1-soeren@soeren-tempel.net> Message-ID: Applied, thanks On Wed, Nov 17, 2021 at 3:16 PM wrote: > > From: S?ren Tempel > > POSIX.1-2008 mandates the following regarding the file command-line > argument: > > If the file argument is given, ed shall simulate an e command > on the file named by the pathname [?] > > The specification for the e command mandates the following behaviour > regarding the current line number in POSIX.1-2008: > > The current line number shall be set to the address of the last > line of the buffer. > > However, without this commit, busybox ed will set the current line > number to 1 if a file is given on the command-line and this file is not > empty (lastNum != 0). This is incorrect and fixed in this commit by not > modifying the current line number in ed_main(). As such, the current > line number will be zero for empty files and otherwise be set to the > address of the last line of the buffer. > > Signed-off-by: S?ren Tempel > --- > editors/ed.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/editors/ed.c b/editors/ed.c > index 14540e566..cb903bca7 100644 > --- a/editors/ed.c > +++ b/editors/ed.c > @@ -1010,8 +1010,6 @@ int ed_main(int argc UNUSED_PARAM, char **argv) > if (!readLines(fileName, 1)) { > return EXIT_SUCCESS; > } > - if (lastNum) > - setCurNum(1); > dirty = FALSE; > } > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From vda.linux at googlemail.com Sun Dec 19 22:18:40 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sun, 19 Dec 2021 23:18:40 +0100 Subject: [PATCH] ed: align output of read command with POSIX.1-2008 In-Reply-To: <20211117141225.21136-1-soeren@soeren-tempel.net> References: <20211117141225.21136-1-soeren@soeren-tempel.net> Message-ID: Applied, thanks On Wed, Nov 17, 2021 at 3:19 PM wrote: > > From: S?ren Tempel > > POSIX.1-2008 mandates the following regarding the read command: > > If the read is successful, and -s was not specified, the number > of bytes read shall be written to standard output in the > following format: > > "%d\n", > > This commit aligns the output of busybox ed with POSIX.1-2008 by > removing the file name from the output for the read command. > > This slipped through in 4836a0708fd0aaeb82871a3762b40fcf4b61e812. > > Signed-off-by: S?ren Tempel > --- > editors/ed.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/editors/ed.c b/editors/ed.c > index cb903bca7..0d96d263c 100644 > --- a/editors/ed.c > +++ b/editors/ed.c > @@ -400,9 +400,6 @@ static int readLines(const char *file, int num) > charCount = 0; > cc = 0; > > - printf("\"%s\", ", file); > - fflush_all(); > - > do { > cp = memchr(bufPtr, '\n', bufUsed); > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From asmadeus at codewreck.org Tue Dec 21 12:52:29 2021 From: asmadeus at codewreck.org (Dominique Martinet) Date: Tue, 21 Dec 2021 21:52:29 +0900 Subject: [PATCH] sed: do not ignore 'g' modifier when match starts with ^ Message-ID: <20211221125229.1077970-1-asmadeus@codewreck.org> It is perfectly valid to start a regex with ^ and have other patterns with \| that can match more than once, e.g. the following example should print ca, as illustrated with gnu sed: $ echo 'abca' | sed -e 's/^a\|b//g' ca busybox before patch: $ echo 'abca' | busybox sed -e 's/^a\|b//g' bca busybox after patch: $ echo 'abca' | ./busybox sed -e 's/^a\|b//g' ca regcomp handles ^ perfectly well as illustrated with the second 'a' that did not match in the example, we ca leave the non-repeating to it if appropriate. The check had been added before using regcomp and was required at the time (f36635cec6da) but no longer makes sense now. (tested with glibc and musl libc) Signed-off-by: Dominique Martinet --- stumbled on this because one of my script stripping first/last char in a single 's/^x\|x$//g' didn't work on alpine with busybox sed. Thanks! editors/sed.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/editors/sed.c b/editors/sed.c index a6845a979668..e8c82ac63ac4 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -435,8 +435,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr) switch (substr[idx]) { /* Replace all occurrences */ case 'g': - if (match[0] != '^') - sed_cmd->which_match = 0; + sed_cmd->which_match = 0; break; /* Print pattern space */ case 'p': -- 2.31.1 From vda.linux at googlemail.com Sat Dec 25 03:21:10 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Sat, 25 Dec 2021 04:21:10 +0100 Subject: [PATCH] sed: do not ignore 'g' modifier when match starts with ^ In-Reply-To: <20211221125229.1077970-1-asmadeus@codewreck.org> References: <20211221125229.1077970-1-asmadeus@codewreck.org> Message-ID: Applied, thank you On Tue, Dec 21, 2021 at 2:01 PM Dominique Martinet wrote: > > It is perfectly valid to start a regex with ^ and have other patterns > with \| that can match more than once, e.g. the following example > should print ca, as illustrated with gnu sed: > $ echo 'abca' | sed -e 's/^a\|b//g' > ca > > busybox before patch: > $ echo 'abca' | busybox sed -e 's/^a\|b//g' > bca > > busybox after patch: > $ echo 'abca' | ./busybox sed -e 's/^a\|b//g' > ca > > regcomp handles ^ perfectly well as illustrated with the second 'a' that > did not match in the example, we ca leave the non-repeating to it if > appropriate. > The check had been added before using regcomp and was required at the > time (f36635cec6da) but no longer makes sense now. > > (tested with glibc and musl libc) > > Signed-off-by: Dominique Martinet > --- > > stumbled on this because one of my script stripping first/last char in a > single 's/^x\|x$//g' didn't work on alpine with busybox sed. > > Thanks! > > > editors/sed.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/editors/sed.c b/editors/sed.c > index a6845a979668..e8c82ac63ac4 100644 > --- a/editors/sed.c > +++ b/editors/sed.c > @@ -435,8 +435,7 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr) > switch (substr[idx]) { > /* Replace all occurrences */ > case 'g': > - if (match[0] != '^') > - sed_cmd->which_match = 0; > + sed_cmd->which_match = 0; > break; > /* Print pattern space */ > case 'p': > -- > 2.31.1 > > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox From bootc at debian.org Mon Dec 27 19:26:19 2021 From: bootc at debian.org (Chris Boot) Date: Mon, 27 Dec 2021 19:26:19 +0000 Subject: scripts/shell.c doesn't support '\0' Message-ID: <331c7f6c-44c6-8cdc-97ec-826f4a6c1b38@debian.org> Hi all, I've started experimentally packaging BusyBox 1.35.0 for Debian, and found that the "awk printf('%c') can output NUL" test kept failing. It turns out that scripts/shell.c cannot output a NUL for the "\0" in the test string, thus breaking this test. I had a quick look at scripts/shell.c but I couldn't work out how to fix it, so I think that's best left for someone else. Instead, the workaround I found was to change the shebang for testsuite/awk.tests to "#!/usr/bin/env ash" and add an "unset ECHO" on the next line. That uses the newly built busybox ash to run those tests, and this can handle "echo -ne" unlike dash (the Debian Almquist Shell) which is used for /bin/sh. Best regards, Chris -- Chris Boot bootc at debian.org From vda.linux at googlemail.com Tue Dec 28 08:07:37 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 28 Dec 2021 09:07:37 +0100 Subject: scripts/shell.c doesn't support '\0' In-Reply-To: <331c7f6c-44c6-8cdc-97ec-826f4a6c1b38@debian.org> References: <331c7f6c-44c6-8cdc-97ec-826f4a6c1b38@debian.org> Message-ID: On Mon, Dec 27, 2021 at 8:31 PM Chris Boot wrote: > Hi all, > > I've started experimentally packaging BusyBox 1.35.0 for Debian, and > found that the "awk printf('%c') can output NUL" test kept failing. Works for me. > It > turns out that scripts/shell.c cannot output a NUL for the "\0" in the > test string, thus breaking this test. What is scripts/shell.c? I don't see such a file. From soeren at soeren-tempel.net Tue Dec 28 10:45:52 2021 From: soeren at soeren-tempel.net (soeren at soeren-tempel.net) Date: Tue, 28 Dec 2021 11:45:52 +0100 Subject: [PATCH] ed: add support for -s command-line option as mandated by POSIX Message-ID: <20211228104552.29821-1-soeren@soeren-tempel.net> From: S?ren Tempel Apart from the -p option, POSIX also mandates an -s option which suppresses the output of byte counts for the e, E, r, and w command. >From these commands, Busybox ed presently only implements the r and w commands. This commit ensures that these two command do not output any bytes counts when the -s option is passed. The shell escape command, also effected by the -s option, is not implemented by Busybox at the moment. --- editors/ed.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/editors/ed.c b/editors/ed.c index dfe0f1a77..a7595dc45 100644 --- a/editors/ed.c +++ b/editors/ed.c @@ -18,7 +18,7 @@ //applet:IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP)) -//usage:#define ed_trivial_usage "[-p PROMPT] [FILE]" +//usage:#define ed_trivial_usage "[-p PROMPT] [-s] [FILE]" //usage:#define ed_full_usage "" #include "libbb.h" @@ -52,6 +52,7 @@ struct globals { LINE lines; smallint dirty; int marks[26]; + int silentMode; }; #define G (*ptr_to_globals) #define curLine (G.curLine ) @@ -66,6 +67,7 @@ struct globals { #define dirty (G.dirty ) #define lines (G.lines ) #define marks (G.marks ) +#define silentMode (G.silentMode ) #define INIT_G() do { \ setup_common_bufsiz(); \ SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ @@ -458,7 +460,8 @@ static int readLines(const char *file, int num) * in the following format: * "%d\n", */ - printf("%u\n", charCount); + if (!silentMode) + printf("%u\n", charCount); return TRUE; } @@ -510,7 +513,8 @@ static int writeLines(const char *file, int num1, int num2) * unless the -s option was specified, in the following format: * "%d\n", */ - printf("%u\n", charCount); + if (!silentMode) + printf("%u\n", charCount); return TRUE; } @@ -996,6 +1000,8 @@ static void doCommands(void) int ed_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int ed_main(int argc UNUSED_PARAM, char **argv) { + int opt; + INIT_G(); bufSize = INITBUF_SIZE; @@ -1005,7 +1011,8 @@ int ed_main(int argc UNUSED_PARAM, char **argv) lines.prev = &lines; prompt = ""; /* no prompt by default */ - getopt32(argv, "p:", &prompt); + opt = getopt32(argv, "sp:", &prompt); + silentMode = opt & 0x01; argv += optind; if (argv[0]) { From bootc at debian.org Tue Dec 28 11:00:03 2021 From: bootc at debian.org (Chris Boot) Date: Tue, 28 Dec 2021 11:00:03 +0000 Subject: scripts/shell.c doesn't support '\0' In-Reply-To: References: <331c7f6c-44c6-8cdc-97ec-826f4a6c1b38@debian.org> Message-ID: On 28/12/2021 08:07, Denys Vlasenko wrote: > On Mon, Dec 27, 2021 at 8:31 PM Chris Boot wrote: >> Hi all, >> >> I've started experimentally packaging BusyBox 1.35.0 for Debian, and >> found that the "awk printf('%c') can output NUL" test kept failing. > > Works for me. I would only expect it to fail if /bin/sh is a shell whose 'echo' doesn't understand the '-ne' flags, such as dash. >> It >> turns out that scripts/shell.c cannot output a NUL for the "\0" in the >> test string, thus breaking this test. > > What is scripts/shell.c? I don't see such a file. Sorry, I was a bit tired last night. The source is scripts/echo.c, which gets built to testsuite/echo-ne in testsuite/testing.sh. -- Chris Boot bootc at debian.org From vda.linux at googlemail.com Tue Dec 28 20:07:49 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 28 Dec 2021 21:07:49 +0100 Subject: scripts/shell.c doesn't support '\0' In-Reply-To: References: <331c7f6c-44c6-8cdc-97ec-826f4a6c1b38@debian.org> Message-ID: On Tue, Dec 28, 2021 at 12:00 PM Chris Boot wrote: > On 28/12/2021 08:07, Denys Vlasenko wrote: > >> It > >> turns out that scripts/shell.c cannot output a NUL for the "\0" in the > >> test string, thus breaking this test. > > > > What is scripts/shell.c? I don't see such a file. > > Sorry, I was a bit tired last night. The source is scripts/echo.c, which > gets built to testsuite/echo-ne in testsuite/testing.sh. Fixed in git, can you confirm? From vda.linux at googlemail.com Tue Dec 28 20:20:03 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Tue, 28 Dec 2021 21:20:03 +0100 Subject: [PATCH] ed: add support for -s command-line option as mandated by POSIX In-Reply-To: <20211228104552.29821-1-soeren@soeren-tempel.net> References: <20211228104552.29821-1-soeren@soeren-tempel.net> Message-ID: On Tue, Dec 28, 2021 at 11:46 AM wrote: > > From: S?ren Tempel > > Apart from the -p option, POSIX also mandates an -s option which > suppresses the output of byte counts for the e, E, r, and w command. > From these commands, Busybox ed presently only implements the r and w > commands. This commit ensures that these two command do not output any > bytes counts when the -s option is passed. The shell escape command, > also effected by the -s option, is not implemented by Busybox at the > moment. > @@ -52,6 +52,7 @@ struct globals { > LINE lines; > smallint dirty; > int marks[26]; > + int silentMode; > }; No need for a new variable. Please use existing option_mask32 instead: if (!(option_mask32 & OPT_SILENT)) printf("%u\n", charCount); From bootc at debian.org Tue Dec 28 22:20:47 2021 From: bootc at debian.org (Chris Boot) Date: Tue, 28 Dec 2021 22:20:47 +0000 Subject: scripts/shell.c doesn't support '\0' In-Reply-To: References: <331c7f6c-44c6-8cdc-97ec-826f4a6c1b38@debian.org> Message-ID: <26ccead1-2005-4b80-5c77-86f533a41fc4@debian.org> On 28/12/2021 20:07, Denys Vlasenko wrote: > On Tue, Dec 28, 2021 at 12:00 PM Chris Boot wrote: >> On 28/12/2021 08:07, Denys Vlasenko wrote: >>>> It >>>> turns out that scripts/shell.c cannot output a NUL for the "\0" in the >>>> test string, thus breaking this test. >>> >>> What is scripts/shell.c? I don't see such a file. >> >> Sorry, I was a bit tired last night. The source is scripts/echo.c, which >> gets built to testsuite/echo-ne in testsuite/testing.sh. > > Fixed in git, can you confirm? Thanks Denys, all the tests pass with that patch applied. Many thanks for sorting this out so fast! Best regards, Chris -- Chris Boot bootc at debian.org From soeren at soeren-tempel.net Wed Dec 29 15:15:50 2021 From: soeren at soeren-tempel.net (soeren at soeren-tempel.net) Date: Wed, 29 Dec 2021 16:15:50 +0100 Subject: [PATCH v2] ed: add support for -s command-line option as mandated by POSIX In-Reply-To: References: Message-ID: <20211229151550.16793-1-soeren@soeren-tempel.net> From: S?ren Tempel Apart from the -p option, POSIX also mandates an -s option which suppresses the output of byte counts for the e, E, r, and w command. >From these commands, Busybox ed presently only implements the r and w commands. This commit ensures that these two command do not output any bytes counts when the -s option is passed. The shell escape command, also effected by the -s option, is not implemented by Busybox at the moment. --- Instead of introducing a new global variable, this version of the patch reuses the existing option_mask32 variable. editors/ed.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/editors/ed.c b/editors/ed.c index dfe0f1a77..36b045733 100644 --- a/editors/ed.c +++ b/editors/ed.c @@ -18,7 +18,7 @@ //applet:IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP)) -//usage:#define ed_trivial_usage "[-p PROMPT] [FILE]" +//usage:#define ed_trivial_usage "[-p PROMPT] [-s] [FILE]" //usage:#define ed_full_usage "" #include "libbb.h" @@ -71,6 +71,11 @@ struct globals { SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ } while (0) +#define OPTION_STR "sp:" +enum { + OPT_s = 0x01, +}; + static int bad_nums(int num1, int num2, const char *for_what) { if ((num1 < 1) || (num2 > lastNum) || (num1 > num2)) { @@ -458,7 +463,8 @@ static int readLines(const char *file, int num) * in the following format: * "%d\n", */ - printf("%u\n", charCount); + if (!(option_mask32 & OPT_s)) + printf("%u\n", charCount); return TRUE; } @@ -510,7 +516,8 @@ static int writeLines(const char *file, int num1, int num2) * unless the -s option was specified, in the following format: * "%d\n", */ - printf("%u\n", charCount); + if (!(option_mask32 & OPT_s)) + printf("%u\n", charCount); return TRUE; } @@ -1005,7 +1012,7 @@ int ed_main(int argc UNUSED_PARAM, char **argv) lines.prev = &lines; prompt = ""; /* no prompt by default */ - getopt32(argv, "p:", &prompt); + getopt32(argv, OPTION_STR, &prompt); argv += optind; if (argv[0]) { From vda.linux at googlemail.com Wed Dec 29 18:00:47 2021 From: vda.linux at googlemail.com (Denys Vlasenko) Date: Wed, 29 Dec 2021 19:00:47 +0100 Subject: [PATCH v2] ed: add support for -s command-line option as mandated by POSIX In-Reply-To: <20211229151550.16793-1-soeren@soeren-tempel.net> References: <20211229151550.16793-1-soeren@soeren-tempel.net> Message-ID: Applied, thank you On Wed, Dec 29, 2021 at 4:16 PM wrote: > > From: S?ren Tempel > > Apart from the -p option, POSIX also mandates an -s option which > suppresses the output of byte counts for the e, E, r, and w command. > From these commands, Busybox ed presently only implements the r and w > commands. This commit ensures that these two command do not output any > bytes counts when the -s option is passed. The shell escape command, > also effected by the -s option, is not implemented by Busybox at the > moment. > --- > Instead of introducing a new global variable, this version of the patch > reuses the existing option_mask32 variable. > > editors/ed.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/editors/ed.c b/editors/ed.c > index dfe0f1a77..36b045733 100644 > --- a/editors/ed.c > +++ b/editors/ed.c > @@ -18,7 +18,7 @@ > > //applet:IF_ED(APPLET(ed, BB_DIR_BIN, BB_SUID_DROP)) > > -//usage:#define ed_trivial_usage "[-p PROMPT] [FILE]" > +//usage:#define ed_trivial_usage "[-p PROMPT] [-s] [FILE]" > //usage:#define ed_full_usage "" > > #include "libbb.h" > @@ -71,6 +71,11 @@ struct globals { > SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ > } while (0) > > +#define OPTION_STR "sp:" > +enum { > + OPT_s = 0x01, > +}; > + > static int bad_nums(int num1, int num2, const char *for_what) > { > if ((num1 < 1) || (num2 > lastNum) || (num1 > num2)) { > @@ -458,7 +463,8 @@ static int readLines(const char *file, int num) > * in the following format: > * "%d\n", > */ > - printf("%u\n", charCount); > + if (!(option_mask32 & OPT_s)) > + printf("%u\n", charCount); > return TRUE; > } > > @@ -510,7 +516,8 @@ static int writeLines(const char *file, int num1, int num2) > * unless the -s option was specified, in the following format: > * "%d\n", > */ > - printf("%u\n", charCount); > + if (!(option_mask32 & OPT_s)) > + printf("%u\n", charCount); > return TRUE; > } > > @@ -1005,7 +1012,7 @@ int ed_main(int argc UNUSED_PARAM, char **argv) > lines.prev = &lines; > > prompt = ""; /* no prompt by default */ > - getopt32(argv, "p:", &prompt); > + getopt32(argv, OPTION_STR, &prompt); > argv += optind; > > if (argv[0]) { > _______________________________________________ > busybox mailing list > busybox at busybox.net > http://lists.busybox.net/mailman/listinfo/busybox