From ee1e0987e4c81b4a5369174ce22b0671198abb6b Mon Sep 17 00:00:00 2001 From: Maxim Storchak Date: Tue, 29 Dec 2020 17:29:05 +0200 Subject: httpd: fix offset for sendfile If the Range: header is not present it the request, the offset passed to sendfile is wrong, and httpd falls back to the read-write loop. function old new delta send_file_and_exit 857 865 +8 handle_incoming_and_exit 2239 2230 -9 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 8/-9) Total: -1 bytes Signed-off-by: Maxim Storchak Signed-off-by: Denys Vlasenko --- networking/httpd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/networking/httpd.c b/networking/httpd.c index 4346141ee..4c014bc71 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -1871,7 +1871,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what) send_headers(HTTP_OK); #if ENABLE_FEATURE_USE_SENDFILE { - off_t offset = range_start; + off_t offset = (range_start < 0) ? 0 : range_start; while (1) { /* sz is rounded down to 64k */ ssize_t sz = MAXINT(ssize_t) - 0xffff; @@ -2486,8 +2486,8 @@ static void handle_incoming_and_exit(const len_and_sockaddr *fromAddr) if (STRNCASECMP(iobuf, "Range:") == 0) { /* We know only bytes=NNN-[MMM] */ char *s = skip_whitespace(iobuf + sizeof("Range:")-1); - if (is_prefixed_with(s, "bytes=")) { - s += sizeof("bytes=")-1; + s = is_prefixed_with(s, "bytes="); + if (s) { range_start = BB_STRTOOFF(s, &s, 10); if (s[0] != '-' || range_start < 0) { range_start = -1; -- cgit v1.2.3 From 67cc582d4289c5de521d11b08307c8ab26ee1e28 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 3 Jan 2021 10:55:39 +0100 Subject: ash: make a strdup copy of $HISTFILE for line editing Otherwise if $HISTFILE is unset or reassigned, bad things can happen. function old new delta ash_main 1210 1218 +8 Signed-off-by: Denys Vlasenko --- shell/ash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/ash.c b/shell/ash.c index f16d7fb6a..ecbfbf091 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -14499,7 +14499,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) if (sflag || minusc == NULL) { #if MAX_HISTORY > 0 && ENABLE_FEATURE_EDITING_SAVEHISTORY - if (iflag) { + if (line_input_state) { const char *hp = lookupvar("HISTFILE"); if (!hp) { hp = lookupvar("HOME"); @@ -14513,7 +14513,7 @@ int ash_main(int argc UNUSED_PARAM, char **argv) } } if (hp) - line_input_state->hist_file = hp; + line_input_state->hist_file = xstrdup(hp); # if ENABLE_FEATURE_SH_HISTFILESIZE hp = lookupvar("HISTFILESIZE"); line_input_state->max_history = size_from_HISTFILESIZE(hp); -- cgit v1.2.3 From 39b71881b8173225c8ef85a308523d98cb590eac Mon Sep 17 00:00:00 2001 From: Bernd Kuhls Date: Sun, 10 Jan 2021 13:20:44 +0100 Subject: update_passwd: fix context variable Commit https://git.busybox.net/busybox/commit/libbb/update_passwd.c?id=2496616b0a8d1c80cd1416b73a4847b59b9f969a changed the variable used from context to seuser but forgot this change resulting in build errors detected by buildroot autobuilders: http://autobuild.buildroot.net/results/b89/b89b7d0f0601bb706e76cea31cf4e43326e5540c//build-end.log libbb/update_passwd.c:51:11: error: 'context' undeclared (first use in this function); did you mean 'ucontext'? freecon(context); Signed-off-by: Bernd Kuhls Signed-off-by: Denys Vlasenko --- libbb/update_passwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libbb/update_passwd.c b/libbb/update_passwd.c index 7b67f30cd..a228075cc 100644 --- a/libbb/update_passwd.c +++ b/libbb/update_passwd.c @@ -48,7 +48,7 @@ static void check_selinux_update_passwd(const char *username) bb_simple_error_msg_and_die("SELinux: access denied"); } if (ENABLE_FEATURE_CLEAN_UP) - freecon(context); + freecon(seuser); } #else # define check_selinux_update_passwd(username) ((void)0) -- cgit v1.2.3 From 89358a7131d3e75c74af834bb117b4fad7914983 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Tue, 2 Feb 2021 13:48:21 +0100 Subject: traceroute: fix option parsing Signed-off-by: Denys Vlasenko --- networking/traceroute.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networking/traceroute.c b/networking/traceroute.c index 3f1a9ab46..29f5e480b 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -896,7 +896,7 @@ traceroute_init(int op, char **argv) op |= getopt32(argv, "^" OPT_STRING - "\0" "-1:x-x" /* minimum 1 arg */ + "\0" "-1" /* minimum 1 arg */ , &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str , &source, &waittime_str, &pausemsecs_str, &first_ttl_str ); -- cgit v1.2.3