diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-06 18:11:47 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-06 18:11:47 +0100 |
commit | e1b1b7926975c3cd4313be0019212b1cf68fa529 (patch) | |
tree | 31f9227004013462e899d383c1e7a0910f7157aa /networking | |
parent | 33f7c8f200b6c3f7163dc89723ab67462688dccd (diff) | |
download | busybox-w32-e1b1b7926975c3cd4313be0019212b1cf68fa529.tar.gz busybox-w32-e1b1b7926975c3cd4313be0019212b1cf68fa529.tar.bz2 busybox-w32-e1b1b7926975c3cd4313be0019212b1cf68fa529.zip |
use gmtime_r() instead of gmtime()
This avoids pulling in gmtime's static buffer:
function old new delta
svlogd_main 1401 1412 +11
send_headers 668 678 +10
gmtime 21 - -21
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/0 up/down: 21/-21) Total: 0 bytes
text data bss dec hex filename
920221 555 5804 926580 e2374 busybox_old
920221 555 5740 926516 e2334 busybox_unstripped
^^^^
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r-- | networking/httpd.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/networking/httpd.c b/networking/httpd.c index 74196a4f1..9439e206c 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
@@ -1046,6 +1046,7 @@ static void send_headers(int responseNum) | |||
1046 | /* Fixed size 29-byte string. Example: Sun, 06 Nov 1994 08:49:37 GMT */ | 1046 | /* Fixed size 29-byte string. Example: Sun, 06 Nov 1994 08:49:37 GMT */ |
1047 | char date_str[40]; /* using a bit larger buffer to paranoia reasons */ | 1047 | char date_str[40]; /* using a bit larger buffer to paranoia reasons */ |
1048 | 1048 | ||
1049 | struct tm tm; | ||
1049 | const char *responseString = ""; | 1050 | const char *responseString = ""; |
1050 | const char *infoString = NULL; | 1051 | const char *infoString = NULL; |
1051 | #if ENABLE_FEATURE_HTTPD_ERROR_PAGES | 1052 | #if ENABLE_FEATURE_HTTPD_ERROR_PAGES |
@@ -1074,7 +1075,8 @@ static void send_headers(int responseNum) | |||
1074 | * always fit into those kbytes. | 1075 | * always fit into those kbytes. |
1075 | */ | 1076 | */ |
1076 | 1077 | ||
1077 | strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime(&timer)); | 1078 | strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&timer, &tm)); |
1079 | /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ | ||
1078 | len = sprintf(iobuf, | 1080 | len = sprintf(iobuf, |
1079 | "HTTP/1.0 %d %s\r\n" | 1081 | "HTTP/1.0 %d %s\r\n" |
1080 | "Content-type: %s\r\n" | 1082 | "Content-type: %s\r\n" |
@@ -1128,7 +1130,7 @@ static void send_headers(int responseNum) | |||
1128 | #endif | 1130 | #endif |
1129 | 1131 | ||
1130 | if (file_size != -1) { /* file */ | 1132 | if (file_size != -1) { /* file */ |
1131 | strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime(&last_mod)); | 1133 | strftime(date_str, sizeof(date_str), RFC1123FMT, gmtime_r(&last_mod, &tm)); |
1132 | #if ENABLE_FEATURE_HTTPD_RANGES | 1134 | #if ENABLE_FEATURE_HTTPD_RANGES |
1133 | if (responseNum == HTTP_PARTIAL_CONTENT) { | 1135 | if (responseNum == HTTP_PARTIAL_CONTENT) { |
1134 | len += sprintf(iobuf + len, | 1136 | len += sprintf(iobuf + len, |