aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-10-08 08:31:11 +0100
committerRon Yorston <rmy@pobox.com>2018-10-08 08:31:11 +0100
commiteee3722fd32c8c0929cfbacdbe0b6524e1fd645c (patch)
treec9026160e56f204c42029c705d1d16cecd515244
parent25a1bcec7637e0f0c75d3ae6c09eb78fdb6f0a75 (diff)
parent349d72c19ced4fae64e8fdd5792b37e78ac2f616 (diff)
downloadbusybox-w32-eee3722fd32c8c0929cfbacdbe0b6524e1fd645c.tar.gz
busybox-w32-eee3722fd32c8c0929cfbacdbe0b6524e1fd645c.tar.bz2
busybox-w32-eee3722fd32c8c0929cfbacdbe0b6524e1fd645c.zip
Merge branch 'busybox' into merge
-rw-r--r--.gitignore6
-rw-r--r--archival/unzip.c57
-rw-r--r--coreutils/ls.c4
-rw-r--r--docs/mdev.txt6
-rw-r--r--e2fsprogs/tune2fs.c17
-rw-r--r--editors/sed.c29
-rw-r--r--include/libbb.h20
-rw-r--r--init/init.c9
-rw-r--r--libbb/lineedit.c2
-rw-r--r--libbb/printable_string.c7
-rw-r--r--libbb/time.c14
-rw-r--r--libbb/unicode.c2
-rw-r--r--networking/ifupdown.c16
-rw-r--r--networking/ntpd.c11
-rw-r--r--networking/udhcp/d6_dhcpc.c8
-rw-r--r--networking/udhcp/dhcpc.c8
-rwxr-xr-xtestsuite/head.tests41
-rw-r--r--testsuite/head/head-n-works4
-rw-r--r--testsuite/head/head-works4
-rw-r--r--util-linux/fdisk_gpt.c2
-rw-r--r--util-linux/mkfs_ext2.c17
-rw-r--r--util-linux/mkfs_reiser.c16
-rw-r--r--util-linux/mkfs_vfat.c13
23 files changed, 185 insertions, 128 deletions
diff --git a/.gitignore b/.gitignore
index eeb5c2182..517e750c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -52,3 +52,9 @@ cscope.files
52cscope.in.out 52cscope.in.out
53cscope.out 53cscope.out
54cscope.po.out 54cscope.po.out
55
56#
57# ctags output
58#
59tags
60TAGS
diff --git a/archival/unzip.c b/archival/unzip.c
index a9b7dc10f..473cbe2ec 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -156,15 +156,15 @@ typedef union {
156#define FIX_ENDIANNESS_CDF(cdf) \ 156#define FIX_ENDIANNESS_CDF(cdf) \
157do { if (BB_BIG_ENDIAN) { \ 157do { if (BB_BIG_ENDIAN) { \
158 (cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \ 158 (cdf).fmt.version_made_by = SWAP_LE16((cdf).fmt.version_made_by); \
159 (cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed); \ 159 (cdf).fmt.version_needed = SWAP_LE16((cdf).fmt.version_needed ); \
160 (cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \ 160 (cdf).fmt.method = SWAP_LE16((cdf).fmt.method ); \
161 (cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \ 161 (cdf).fmt.modtime = SWAP_LE16((cdf).fmt.modtime ); \
162 (cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \ 162 (cdf).fmt.moddate = SWAP_LE16((cdf).fmt.moddate ); \
163 (cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \ 163 (cdf).fmt.crc32 = SWAP_LE32((cdf).fmt.crc32 ); \
164 (cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \ 164 (cdf).fmt.cmpsize = SWAP_LE32((cdf).fmt.cmpsize ); \
165 (cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \ 165 (cdf).fmt.ucmpsize = SWAP_LE32((cdf).fmt.ucmpsize ); \
166 (cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len); \ 166 (cdf).fmt.filename_len = SWAP_LE16((cdf).fmt.filename_len ); \
167 (cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \ 167 (cdf).fmt.extra_len = SWAP_LE16((cdf).fmt.extra_len ); \
168 (cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \ 168 (cdf).fmt.file_comment_length = SWAP_LE16((cdf).fmt.file_comment_length); \
169 (cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \ 169 (cdf).fmt.external_attributes = SWAP_LE32((cdf).fmt.external_attributes); \
170}} while (0) 170}} while (0)
@@ -459,7 +459,9 @@ static int get_lstat_mode(const char *dst_fn)
459 struct stat stat_buf; 459 struct stat stat_buf;
460 if (lstat(dst_fn, &stat_buf) == -1) { 460 if (lstat(dst_fn, &stat_buf) == -1) {
461 if (errno != ENOENT) { 461 if (errno != ENOENT) {
462 bb_perror_msg_and_die("can't stat '%s'", dst_fn); 462 bb_perror_msg_and_die("can't stat '%s'",
463 dst_fn
464 );
463 } 465 }
464 /* File does not exist */ 466 /* File does not exist */
465 return -1; 467 return -1;
@@ -637,7 +639,9 @@ int unzip_main(int argc, char **argv)
637 break; 639 break;
638 if (++i > 2) { 640 if (++i > 2) {
639 *ext = '\0'; 641 *ext = '\0';
640 bb_error_msg_and_die("can't open %s[.zip]", src_fn); 642 bb_error_msg_and_die("can't open %s[.zip]",
643 src_fn
644 );
641 } 645 }
642 strcpy(ext, extn[i - 1]); 646 strcpy(ext, extn[i - 1]);
643 } 647 }
@@ -649,8 +653,11 @@ int unzip_main(int argc, char **argv)
649 xchdir(base_dir); 653 xchdir(base_dir);
650 654
651 if (quiet <= 1) { /* not -qq */ 655 if (quiet <= 1) { /* not -qq */
652 if (quiet == 0) 656 if (quiet == 0) {
653 printf("Archive: %s\n", src_fn); 657 printf("Archive: %s\n",
658 printable_string(src_fn)
659 );
660 }
654 if (opts & OPT_l) { 661 if (opts & OPT_l) {
655 puts(verbose ? 662 puts(verbose ?
656 " Length Method Size Cmpr Date Time CRC-32 Name\n" 663 " Length Method Size Cmpr Date Time CRC-32 Name\n"
@@ -834,7 +841,8 @@ int unzip_main(int argc, char **argv)
834 printf( "%9u " "%s " "%s\n", 841 printf( "%9u " "%s " "%s\n",
835 (unsigned)zip.fmt.ucmpsize, 842 (unsigned)zip.fmt.ucmpsize,
836 dtbuf, 843 dtbuf,
837 dst_fn); 844 printable_string(dst_fn)
845 );
838 } else { 846 } else {
839 char method6[7]; 847 char method6[7];
840 unsigned long percents; 848 unsigned long percents;
@@ -863,7 +871,8 @@ int unzip_main(int argc, char **argv)
863 (unsigned)percents, 871 (unsigned)percents,
864 dtbuf, 872 dtbuf,
865 zip.fmt.crc32, 873 zip.fmt.crc32,
866 dst_fn); 874 printable_string(dst_fn)
875 );
867 total_size += zip.fmt.cmpsize; 876 total_size += zip.fmt.cmpsize;
868 } 877 }
869 total_usize += zip.fmt.ucmpsize; 878 total_usize += zip.fmt.ucmpsize;
@@ -889,7 +898,7 @@ int unzip_main(int argc, char **argv)
889 mode = get_lstat_mode(dst_fn); 898 mode = get_lstat_mode(dst_fn);
890 if (mode == -1) { /* ENOENT */ 899 if (mode == -1) { /* ENOENT */
891 if (!quiet) { 900 if (!quiet) {
892 printf(" creating: %s\n", dst_fn); 901 printf(" creating: %s\n", printable_string(dst_fn));
893 } 902 }
894 unzip_create_leading_dirs(dst_fn); 903 unzip_create_leading_dirs(dst_fn);
895 if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) { 904 if (bb_make_directory(dst_fn, dir_mode, FILEUTILS_IGNORE_CHMOD_ERR)) {
@@ -898,7 +907,9 @@ int unzip_main(int argc, char **argv)
898 } else { 907 } else {
899 if (!S_ISDIR(mode)) { 908 if (!S_ISDIR(mode)) {
900 bb_error_msg_and_die("'%s' exists but is not a %s", 909 bb_error_msg_and_die("'%s' exists but is not a %s",
901 dst_fn, "directory"); 910 printable_string(dst_fn),
911 "directory"
912 );
902 } 913 }
903 } 914 }
904 goto skip_cmpsize; 915 goto skip_cmpsize;
@@ -917,12 +928,16 @@ int unzip_main(int argc, char **argv)
917 if (!S_ISREG(mode)) { 928 if (!S_ISREG(mode)) {
918 fishy: 929 fishy:
919 bb_error_msg_and_die("'%s' exists but is not a %s", 930 bb_error_msg_and_die("'%s' exists but is not a %s",
920 dst_fn, "regular file"); 931 printable_string(dst_fn),
932 "regular file"
933 );
921 } 934 }
922 if (overwrite == O_ALWAYS) { 935 if (overwrite == O_ALWAYS) {
923 goto do_open_and_extract; 936 goto do_open_and_extract;
924 } 937 }
925 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ", dst_fn); 938 printf("replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ",
939 printable_string(dst_fn)
940 );
926 my_fgets80(key_buf); 941 my_fgets80(key_buf);
927 /* User input could take a long time. Is it still a regular file? */ 942 /* User input could take a long time. Is it still a regular file? */
928 mode = get_lstat_mode(dst_fn); 943 mode = get_lstat_mode(dst_fn);
@@ -952,7 +967,9 @@ int unzip_main(int argc, char **argv)
952 if (!quiet) { 967 if (!quiet) {
953 printf(/* zip.fmt.method == 0 968 printf(/* zip.fmt.method == 0
954 ? " extracting: %s\n" 969 ? " extracting: %s\n"
955 : */ " inflating: %s\n", dst_fn); 970 : */ " inflating: %s\n",
971 printable_string(dst_fn)
972 );
956 } 973 }
957#if ENABLE_FEATURE_UNZIP_CDF 974#if ENABLE_FEATURE_UNZIP_CDF
958 if (S_ISLNK(file_mode)) { 975 if (S_ISLNK(file_mode)) {
diff --git a/coreutils/ls.c b/coreutils/ls.c
index 9daa15470..fb4f998be 100644
--- a/coreutils/ls.c
+++ b/coreutils/ls.c
@@ -421,7 +421,7 @@ static unsigned calc_name_len(const char *name)
421 uni_stat_t uni_stat; 421 uni_stat_t uni_stat;
422 422
423 // TODO: quote tab as \t, etc, if -Q 423 // TODO: quote tab as \t, etc, if -Q
424 name = printable_string(&uni_stat, name); 424 name = printable_string2(&uni_stat, name);
425 425
426 if (!(option_mask32 & OPT_Q)) { 426 if (!(option_mask32 & OPT_Q)) {
427 return uni_stat.unicode_width; 427 return uni_stat.unicode_width;
@@ -450,7 +450,7 @@ static unsigned print_name(const char *name)
450 uni_stat_t uni_stat; 450 uni_stat_t uni_stat;
451 451
452 // TODO: quote tab as \t, etc, if -Q 452 // TODO: quote tab as \t, etc, if -Q
453 name = printable_string(&uni_stat, name); 453 name = printable_string2(&uni_stat, name);
454 454
455 if (!(option_mask32 & OPT_Q)) { 455 if (!(option_mask32 & OPT_Q)) {
456 fputs(name, stdout); 456 fputs(name, stdout);
diff --git a/docs/mdev.txt b/docs/mdev.txt
index b24025f7b..b13a0bb93 100644
--- a/docs/mdev.txt
+++ b/docs/mdev.txt
@@ -60,9 +60,9 @@ or
60For example: 60For example:
61 hd[a-z][0-9]* 0:3 660 61 hd[a-z][0-9]* 0:3 660
62 62
63The config file parsing stops at the first matching line. If no line is 63The config file parsing stops at the first matching line unless this line
64matched, then the default of 0:0 660 is used. To set your own default, simply 64starts with "-". If no line is matched, then the default of 0:0 660 is used.
65create your own total match like so: 65To set your own default, simply create your own total match like so:
66 66
67 .* 1:1 777 67 .* 1:1 777
68 68
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c
index a1caf011c..f7fcd88bf 100644
--- a/e2fsprogs/tune2fs.c
+++ b/e2fsprogs/tune2fs.c
@@ -39,23 +39,6 @@
39#include <linux/fs.h> 39#include <linux/fs.h>
40#include "bb_e2fs_defs.h" 40#include "bb_e2fs_defs.h"
41 41
42// storage helpers
43char BUG_wrong_field_size(void);
44#define STORE_LE(field, value) \
45do { \
46 if (sizeof(field) == 4) \
47 field = SWAP_LE32(value); \
48 else if (sizeof(field) == 2) \
49 field = SWAP_LE16(value); \
50 else if (sizeof(field) == 1) \
51 field = (value); \
52 else \
53 BUG_wrong_field_size(); \
54} while (0)
55
56#define FETCH_LE32(field) \
57 (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size())
58
59enum { 42enum {
60 OPT_L = 1 << 0, // label 43 OPT_L = 1 << 0, // label
61 OPT_c = 1 << 1, // max mount count 44 OPT_c = 1 << 1, // max mount count
diff --git a/editors/sed.c b/editors/sed.c
index bf8a11613..fd56e0e7f 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -186,18 +186,23 @@ static void sed_free_and_close_stuff(void)
186 if (sed_cmd->sw_file) 186 if (sed_cmd->sw_file)
187 fclose(sed_cmd->sw_file); 187 fclose(sed_cmd->sw_file);
188 188
189 if (sed_cmd->beg_match) { 189 /* Used to free regexps, but now there is code
190 regfree(sed_cmd->beg_match); 190 * in get_address() which can reuse a regexp
191 free(sed_cmd->beg_match); 191 * for constructs as /regexp/cmd1;//cmd2
192 } 192 * leading to double-frees here:
193 if (sed_cmd->end_match) { 193 */
194 regfree(sed_cmd->end_match); 194 //if (sed_cmd->beg_match) {
195 free(sed_cmd->end_match); 195 // regfree(sed_cmd->beg_match);
196 } 196 // free(sed_cmd->beg_match);
197 if (sed_cmd->sub_match) { 197 //}
198 regfree(sed_cmd->sub_match); 198 //if (sed_cmd->end_match) {
199 free(sed_cmd->sub_match); 199 // regfree(sed_cmd->end_match);
200 } 200 // free(sed_cmd->end_match);
201 //}
202 //if (sed_cmd->sub_match) {
203 // regfree(sed_cmd->sub_match);
204 // free(sed_cmd->sub_match);
205 //}
201 free(sed_cmd->string); 206 free(sed_cmd->string);
202 free(sed_cmd); 207 free(sed_cmd);
203 sed_cmd = sed_cmd_next; 208 sed_cmd = sed_cmd_next;
diff --git a/include/libbb.h b/include/libbb.h
index 0d09fef66..0a333dca8 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -874,7 +874,8 @@ typedef struct uni_stat_t {
874} uni_stat_t; 874} uni_stat_t;
875/* Returns a string with unprintable chars replaced by '?' or 875/* Returns a string with unprintable chars replaced by '?' or
876 * SUBST_WCHAR. This function is unicode-aware. */ 876 * SUBST_WCHAR. This function is unicode-aware. */
877const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str); 877const char* FAST_FUNC printable_string(const char *str);
878const char* FAST_FUNC printable_string2(uni_stat_t *stats, const char *str);
878/* Prints unprintable char ch as ^C or M-c to file 879/* Prints unprintable char ch as ^C or M-c to file
879 * (M-c is used only if ch is ORed with PRINTABLE_META), 880 * (M-c is used only if ch is ORed with PRINTABLE_META),
880 * else it is printed as-is (except for ch = 0x9b) */ 881 * else it is printed as-is (except for ch = 0x9b) */
@@ -2194,6 +2195,23 @@ extern const char bb_default_login_shell[] ALIGN1;
2194# define FB_0 "/dev/fb0" 2195# define FB_0 "/dev/fb0"
2195#endif 2196#endif
2196 2197
2198// storage helpers for mk*fs utilities
2199char BUG_wrong_field_size(void);
2200#define STORE_LE(field, value) \
2201do { \
2202 if (sizeof(field) == 4) \
2203 field = SWAP_LE32((uint32_t)(value)); \
2204 else if (sizeof(field) == 2) \
2205 field = SWAP_LE16((uint16_t)(value)); \
2206 else if (sizeof(field) == 1) \
2207 field = (uint8_t)(value); \
2208 else \
2209 BUG_wrong_field_size(); \
2210} while (0)
2211
2212#define FETCH_LE32(field) \
2213 (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size())
2214
2197 2215
2198#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) 2216#define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0])))
2199#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) 2217#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
diff --git a/init/init.c b/init/init.c
index 6439e2bcd..fde35f6b6 100644
--- a/init/init.c
+++ b/init/init.c
@@ -752,8 +752,13 @@ static void pause_and_low_level_reboot(unsigned magic)
752 reboot(magic); 752 reboot(magic);
753 _exit(EXIT_SUCCESS); 753 _exit(EXIT_SUCCESS);
754 } 754 }
755 while (1) 755 /* Used to have "while (1) sleep(1)" here.
756 sleep(1); 756 * However, in containers reboot() call is ignored, and with that loop
757 * we would eternally sleep here - not what we want.
758 */
759 waitpid(pid, NULL, 0);
760 sleep(1); /* paranoia */
761 _exit(EXIT_SUCCESS);
757} 762}
758 763
759static void run_shutdown_and_kill_processes(void) 764static void run_shutdown_and_kill_processes(void)
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 6ecf01765..19b579782 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1139,7 +1139,7 @@ static void showfiles(void)
1139 ); 1139 );
1140 } 1140 }
1141 if (ENABLE_UNICODE_SUPPORT) 1141 if (ENABLE_UNICODE_SUPPORT)
1142 puts(printable_string(NULL, matches[n])); 1142 puts(printable_string(matches[n]));
1143 else 1143 else
1144 puts(matches[n]); 1144 puts(matches[n]);
1145 } 1145 }
diff --git a/libbb/printable_string.c b/libbb/printable_string.c
index e638a178e..2e8895a4f 100644
--- a/libbb/printable_string.c
+++ b/libbb/printable_string.c
@@ -9,7 +9,7 @@
9#include "libbb.h" 9#include "libbb.h"
10#include "unicode.h" 10#include "unicode.h"
11 11
12const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str) 12const char* FAST_FUNC printable_string2(uni_stat_t *stats, const char *str)
13{ 13{
14 char *dst; 14 char *dst;
15 const char *s; 15 const char *s;
@@ -55,3 +55,8 @@ const char* FAST_FUNC printable_string(uni_stat_t *stats, const char *str)
55#endif 55#endif
56 return auto_string(dst); 56 return auto_string(dst);
57} 57}
58
59const char* FAST_FUNC printable_string(const char *str)
60{
61 return printable_string2(NULL, str);
62}
diff --git a/libbb/time.c b/libbb/time.c
index 82e6cb172..f9b8da0b3 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -184,6 +184,7 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
184 ptm->tm_year -= 1900; /* Adjust years */ 184 ptm->tm_year -= 1900; /* Adjust years */
185 ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */ 185 ptm->tm_mon -= 1; /* Adjust month from 1-12 to 0-11 */
186 } else { 186 } else {
187 err:
187 bb_error_msg_and_die(bb_msg_invalid_date, date_str); 188 bb_error_msg_and_die(bb_msg_invalid_date, date_str);
188 } 189 }
189 ptm->tm_sec = 0; /* assume zero if [.SS] is not given */ 190 ptm->tm_sec = 0; /* assume zero if [.SS] is not given */
@@ -194,6 +195,19 @@ void FAST_FUNC parse_datestr(const char *date_str, struct tm *ptm)
194 end = '\0'; 195 end = '\0';
195 /* else end != NUL and we error out */ 196 /* else end != NUL and we error out */
196 } 197 }
198 /* Users were confused by "date -s 20180923"
199 * working (not in the way they were expecting).
200 * It was interpreted as MMDDhhmm, and not bothered by
201 * "month #20" in the least. Prevent such cases:
202 */
203 if (ptm->tm_sec > 60 /* allow "23:60" leap second */
204 || ptm->tm_min > 59
205 || ptm->tm_hour > 23
206 || ptm->tm_mday > 31
207 || ptm->tm_mon > 11 /* month# is 0..11, not 1..12 */
208 ) {
209 goto err;
210 }
197 } 211 }
198 if (end != '\0') { 212 if (end != '\0') {
199 bb_error_msg_and_die(bb_msg_invalid_date, date_str); 213 bb_error_msg_and_die(bb_msg_invalid_date, date_str);
diff --git a/libbb/unicode.c b/libbb/unicode.c
index d378175a4..89d42179b 100644
--- a/libbb/unicode.c
+++ b/libbb/unicode.c
@@ -996,7 +996,7 @@ size_t FAST_FUNC unicode_strlen(const char *string)
996size_t FAST_FUNC unicode_strwidth(const char *string) 996size_t FAST_FUNC unicode_strwidth(const char *string)
997{ 997{
998 uni_stat_t uni_stat; 998 uni_stat_t uni_stat;
999 printable_string(&uni_stat, string); 999 printable_string2(&uni_stat, string);
1000 return uni_stat.unicode_width; 1000 return uni_stat.unicode_width;
1001} 1001}
1002 1002
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 5481134e5..80fce87a6 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -1022,6 +1022,22 @@ static struct interfaces_file_t *read_interfaces(const char *filename, struct in
1022 currently_processing = NONE; 1022 currently_processing = NONE;
1023 } else if (strcmp(first_word, "source") == 0) { 1023 } else if (strcmp(first_word, "source") == 0) {
1024 read_interfaces(next_word(&rest_of_line), defn); 1024 read_interfaces(next_word(&rest_of_line), defn);
1025 } else if (is_prefixed_with(first_word, "source-dir")) {
1026 const char *dirpath;
1027 DIR *dir;
1028 struct dirent *entry;
1029
1030 dirpath = next_word(&rest_of_line);
1031 dir = xopendir(dirpath);
1032 while ((entry = readdir(dir)) != NULL) {
1033 char *path;
1034 if (entry->d_name[0] == '.')
1035 continue;
1036 path = concat_path_file(dirpath, entry->d_name);
1037 read_interfaces(path, defn);
1038 free(path);
1039 }
1040 closedir(dir);
1025 } else { 1041 } else {
1026 switch (currently_processing) { 1042 switch (currently_processing) {
1027 case IFACE: 1043 case IFACE:
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 991c518f6..1ebdc34c3 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -1116,20 +1116,25 @@ fit(peer_t *p, double rd)
1116{ 1116{
1117 if ((p->reachable_bits & (p->reachable_bits-1)) == 0) { 1117 if ((p->reachable_bits & (p->reachable_bits-1)) == 0) {
1118 /* One or zero bits in reachable_bits */ 1118 /* One or zero bits in reachable_bits */
1119 VERB4 bb_error_msg("peer %s unfit for selection: unreachable", p->p_dotted); 1119 VERB4 bb_error_msg("peer %s unfit for selection: "
1120 "unreachable", p->p_dotted);
1120 return 0; 1121 return 0;
1121 } 1122 }
1122#if 0 /* we filter out such packets earlier */ 1123#if 0 /* we filter out such packets earlier */
1123 if ((p->lastpkt_status & LI_ALARM) == LI_ALARM 1124 if ((p->lastpkt_status & LI_ALARM) == LI_ALARM
1124 || p->lastpkt_stratum >= MAXSTRAT 1125 || p->lastpkt_stratum >= MAXSTRAT
1125 ) { 1126 ) {
1126 VERB4 bb_error_msg("peer %s unfit for selection: bad status/stratum", p->p_dotted); 1127 VERB4 bb_error_msg("peer %s unfit for selection: "
1128 "bad status/stratum", p->p_dotted);
1127 return 0; 1129 return 0;
1128 } 1130 }
1129#endif 1131#endif
1130 /* rd is root_distance(p) */ 1132 /* rd is root_distance(p) */
1131 if (rd > MAXDIST + FREQ_TOLERANCE * (1 << G.poll_exp)) { 1133 if (rd > MAXDIST + FREQ_TOLERANCE * (1 << G.poll_exp)) {
1132 VERB4 bb_error_msg("peer %s unfit for selection: root distance too high", p->p_dotted); 1134 VERB3 bb_error_msg("peer %s unfit for selection: "
1135 "root distance %f too high, jitter:%f",
1136 p->p_dotted, rd, p->filter_jitter
1137 );
1133 return 0; 1138 return 0;
1134 } 1139 }
1135//TODO 1140//TODO
diff --git a/networking/udhcp/d6_dhcpc.c b/networking/udhcp/d6_dhcpc.c
index ed2255ef3..66e4b6c6a 100644
--- a/networking/udhcp/d6_dhcpc.c
+++ b/networking/udhcp/d6_dhcpc.c
@@ -1405,7 +1405,7 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1405 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ 1405 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
1406 case_RENEW_REQUESTED: 1406 case_RENEW_REQUESTED:
1407 case RENEWING: 1407 case RENEWING:
1408 if (timeout > 60) { 1408 if (timeout >= 60) {
1409 /* send an unicast renew request */ 1409 /* send an unicast renew request */
1410 /* Sometimes observed to fail (EADDRNOTAVAIL) to bind 1410 /* Sometimes observed to fail (EADDRNOTAVAIL) to bind
1411 * a new UDP socket for sending inside send_renew. 1411 * a new UDP socket for sending inside send_renew.
@@ -1465,11 +1465,9 @@ int udhcpc6_main(int argc UNUSED_PARAM, char **argv)
1465 * For the second case, must make sure timeout 1465 * For the second case, must make sure timeout
1466 * is not too big, or else we can send 1466 * is not too big, or else we can send
1467 * futile renew requests for hours. 1467 * futile renew requests for hours.
1468 * (Ab)use -A TIMEOUT value (usually 20 sec)
1469 * as a cap on the timeout.
1470 */ 1468 */
1471 if (timeout > tryagain_timeout) 1469 if (timeout > 60)
1472 timeout = tryagain_timeout; 1470 timeout = 60;
1473 goto case_RENEW_REQUESTED; 1471 goto case_RENEW_REQUESTED;
1474 } 1472 }
1475 /* Start things over */ 1473 /* Start things over */
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 0310663e0..ab3e5a463 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1519,7 +1519,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1519 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */ 1519 case RENEW_REQUESTED: /* manual (SIGUSR1) renew */
1520 case_RENEW_REQUESTED: 1520 case_RENEW_REQUESTED:
1521 case RENEWING: 1521 case RENEWING:
1522 if (timeout > 60) { 1522 if (timeout >= 60) {
1523 /* send an unicast renew request */ 1523 /* send an unicast renew request */
1524 /* Sometimes observed to fail (EADDRNOTAVAIL) to bind 1524 /* Sometimes observed to fail (EADDRNOTAVAIL) to bind
1525 * a new UDP socket for sending inside send_renew. 1525 * a new UDP socket for sending inside send_renew.
@@ -1592,11 +1592,9 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
1592 * For the second case, must make sure timeout 1592 * For the second case, must make sure timeout
1593 * is not too big, or else we can send 1593 * is not too big, or else we can send
1594 * futile renew requests for hours. 1594 * futile renew requests for hours.
1595 * (Ab)use -A TIMEOUT value (usually 20 sec)
1596 * as a cap on the timeout.
1597 */ 1595 */
1598 if (timeout > tryagain_timeout) 1596 if (timeout > 60)
1599 timeout = tryagain_timeout; 1597 timeout = 60;
1600 goto case_RENEW_REQUESTED; 1598 goto case_RENEW_REQUESTED;
1601 } 1599 }
1602 /* Start things over */ 1600 /* Start things over */
diff --git a/testsuite/head.tests b/testsuite/head.tests
new file mode 100755
index 000000000..50660d267
--- /dev/null
+++ b/testsuite/head.tests
@@ -0,0 +1,41 @@
1#!/bin/sh
2# Copyright 2018 Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
3# Licensed under GPLv2 or later, see file LICENSE in this source tree.
4
5. ./testing.sh
6
7# testing "test name" "command" "expected result" "file input" "stdin"
8
9cat <<EOF > head.input
10line 1
11line 2
12line 3
13line 4
14line 5
15line 6
16line 7
17line 8
18line 9
19line 10
20line 11
21line 12
22EOF
23
24testing "head (without args)" \
25 "head head.input" \
26 "line 1\nline 2\nline 3\nline 4\nline 5\nline 6\nline 7\nline 8\nline 9\nline 10\n" \
27 "" ""
28
29testing "head -n <positive number>" \
30 "head -n 2 head.input" \
31 "line 1\nline 2\n" \
32 "" ""
33
34testing "head -n <negative number>" \
35 "head -n -9 head.input" \
36 "line 1\nline 2\nline 3\n" \
37 "" ""
38
39rm head.input
40
41exit $FAILCOUNT
diff --git a/testsuite/head/head-n-works b/testsuite/head/head-n-works
deleted file mode 100644
index db4325556..000000000
--- a/testsuite/head/head-n-works
+++ /dev/null
@@ -1,4 +0,0 @@
1[ -n "$d" ] || d=..
2head -n 2 "$d/README" > logfile.gnu
3busybox head -n 2 "$d/README" > logfile.bb
4cmp logfile.gnu logfile.bb
diff --git a/testsuite/head/head-works b/testsuite/head/head-works
deleted file mode 100644
index 56ad3e36b..000000000
--- a/testsuite/head/head-works
+++ /dev/null
@@ -1,4 +0,0 @@
1[ -n "$d" ] || d=..
2head "$d/README" > logfile.gnu
3busybox head "$d/README" > logfile.bb
4cmp logfile.gnu logfile.bb
diff --git a/util-linux/fdisk_gpt.c b/util-linux/fdisk_gpt.c
index cdb90627d..dbe889f7c 100644
--- a/util-linux/fdisk_gpt.c
+++ b/util-linux/fdisk_gpt.c
@@ -87,7 +87,7 @@ gpt_print_wide36(uint16_t *s)
87 } 87 }
88 wc[i] = 0; 88 wc[i] = 0;
89 if (wcstombs(buf, wc, sizeof(buf)) <= sizeof(buf)-1) 89 if (wcstombs(buf, wc, sizeof(buf)) <= sizeof(buf)-1)
90 fputs(printable_string(NULL, buf), stdout); 90 fputs(printable_string(buf), stdout);
91#else 91#else
92 char buf[37]; 92 char buf[37];
93 int i = 0; 93 int i = 0;
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index f524bc239..bda168f1e 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -78,23 +78,6 @@
78#define EXT2_FLAGS_SIGNED_HASH 0x0001 78#define EXT2_FLAGS_SIGNED_HASH 0x0001
79#define EXT2_FLAGS_UNSIGNED_HASH 0x0002 79#define EXT2_FLAGS_UNSIGNED_HASH 0x0002
80 80
81// storage helpers
82char BUG_wrong_field_size(void);
83#define STORE_LE(field, value) \
84do { \
85 if (sizeof(field) == 4) \
86 field = SWAP_LE32((uint32_t)(value)); \
87 else if (sizeof(field) == 2) \
88 field = SWAP_LE16((uint16_t)(value)); \
89 else if (sizeof(field) == 1) \
90 field = (uint8_t)(value); \
91 else \
92 BUG_wrong_field_size(); \
93} while (0)
94
95#define FETCH_LE32(field) \
96 (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size())
97
98// All fields are little-endian 81// All fields are little-endian
99struct ext2_dir { 82struct ext2_dir {
100 uint32_t inode1; 83 uint32_t inode1;
diff --git a/util-linux/mkfs_reiser.c b/util-linux/mkfs_reiser.c
index 390aef86c..b4c8dda6f 100644
--- a/util-linux/mkfs_reiser.c
+++ b/util-linux/mkfs_reiser.c
@@ -28,22 +28,6 @@
28#include "libbb.h" 28#include "libbb.h"
29#include <linux/fs.h> 29#include <linux/fs.h>
30 30
31char BUG_wrong_field_size(void);
32#define STORE_LE(field, value) \
33do { \
34 if (sizeof(field) == 4) \
35 field = SWAP_LE32(value); \
36 else if (sizeof(field) == 2) \
37 field = SWAP_LE16(value); \
38 else if (sizeof(field) == 1) \
39 field = (value); \
40 else \
41 BUG_wrong_field_size(); \
42} while (0)
43
44#define FETCH_LE32(field) \
45 (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size())
46
47struct journal_params { 31struct journal_params {
48 uint32_t jp_journal_1st_block; /* where does journal start from on its device */ 32 uint32_t jp_journal_1st_block; /* where does journal start from on its device */
49 uint32_t jp_journal_dev; /* journal device st_rdev */ 33 uint32_t jp_journal_dev; /* journal device st_rdev */
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c
index 92f0e3b1a..6a6dc652f 100644
--- a/util-linux/mkfs_vfat.c
+++ b/util-linux/mkfs_vfat.c
@@ -206,19 +206,6 @@ static const char boot_code[] ALIGN1 =
206#define MARK_CLUSTER(cluster, value) \ 206#define MARK_CLUSTER(cluster, value) \
207 ((uint32_t *)fat)[cluster] = SWAP_LE32(value) 207 ((uint32_t *)fat)[cluster] = SWAP_LE32(value)
208 208
209void BUG_unsupported_field_size(void);
210#define STORE_LE(field, value) \
211do { \
212 if (sizeof(field) == 4) \
213 field = SWAP_LE32((uint32_t)(value)); \
214 else if (sizeof(field) == 2) \
215 field = SWAP_LE16((uint16_t)(value)); \
216 else if (sizeof(field) == 1) \
217 field = (uint8_t)(value); \
218 else \
219 BUG_unsupported_field_size(); \
220} while (0)
221
222/* compat: 209/* compat:
223 * mkdosfs 2.11 (12 Mar 2005) 210 * mkdosfs 2.11 (12 Mar 2005)
224 * Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] 211 * Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file]