aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2009-02-26 11:57:01 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2009-02-26 11:57:01 +0000
commita76f10b544b4ffe4b0aaf41eede1aeb9b13a95e8 (patch)
treea41295eaee4b3f28a6e20df4e592ffacc42ac4ab
parent15c0b725849875c718b168a26e13872e163cde4c (diff)
downloadbusybox-w32-a76f10b544b4ffe4b0aaf41eede1aeb9b13a95e8.tar.gz
busybox-w32-a76f10b544b4ffe4b0aaf41eede1aeb9b13a95e8.tar.bz2
busybox-w32-a76f10b544b4ffe4b0aaf41eede1aeb9b13a95e8.zip
Apply post-1.13.2 fixes, bump version to 1.13.3
-rw-r--r--Makefile2
-rw-r--r--archival/tar.c2
-rw-r--r--archival/unzip.c2
-rw-r--r--editors/awk.c15
-rw-r--r--include/libbb.h8
-rw-r--r--init/init.c22
-rw-r--r--modutils/depmod.c57
-rw-r--r--modutils/modutils-24.c28
-rwxr-xr-xtestsuite/mdev.tests16
-rw-r--r--util-linux/mdev.c5
10 files changed, 100 insertions, 57 deletions
diff --git a/Makefile b/Makefile
index a2b2b015b..4bd5ebc24 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1VERSION = 1 1VERSION = 1
2PATCHLEVEL = 13 2PATCHLEVEL = 13
3SUBLEVEL = 2 3SUBLEVEL = 3
4EXTRAVERSION = 4EXTRAVERSION =
5NAME = Unnamed 5NAME = Unnamed
6 6
diff --git a/archival/tar.c b/archival/tar.c
index deb5c89b0..47cc39c80 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -591,8 +591,6 @@ static NOINLINE int writeTarFile(int tar_fd, int verboseFlag,
591 struct TarBallInfo tbInfo; 591 struct TarBallInfo tbInfo;
592 592
593 tbInfo.hlInfoHead = NULL; 593 tbInfo.hlInfoHead = NULL;
594
595 fchmod(tar_fd, 0644);
596 tbInfo.tarFd = tar_fd; 594 tbInfo.tarFd = tar_fd;
597 tbInfo.verboseFlag = verboseFlag; 595 tbInfo.verboseFlag = verboseFlag;
598 596
diff --git a/archival/unzip.c b/archival/unzip.c
index e468ff451..7b47a8ab8 100644
--- a/archival/unzip.c
+++ b/archival/unzip.c
@@ -140,7 +140,7 @@ struct BUG_cde_header_must_be_16_bytes {
140}; 140};
141 141
142#define FIX_ENDIANNESS_CDE(cde_header) do { \ 142#define FIX_ENDIANNESS_CDE(cde_header) do { \
143 (cde_header).formatted.cds_offset = SWAP_LE16((cde_header).formatted.cds_offset); \ 143 (cde_header).formatted.cds_offset = SWAP_LE32((cde_header).formatted.cds_offset); \
144} while (0) 144} while (0)
145 145
146enum { zip_fd = 3 }; 146enum { zip_fd = 3 };
diff --git a/editors/awk.c b/editors/awk.c
index 1d0792e19..64371f060 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -392,8 +392,12 @@ static const uint16_t PRIMES[] ALIGN2 = { 251, 1021, 4093, 16381, 65521 };
392 392
393 393
394/* Globals. Split in two parts so that first one is addressed 394/* Globals. Split in two parts so that first one is addressed
395 * with (mostly short) negative offsets */ 395 * with (mostly short) negative offsets.
396 * NB: it's unsafe to put members of type "double"
397 * into globals2 (gcc may fail to align them).
398 */
396struct globals { 399struct globals {
400 double t_double;
397 chain beginseq, mainseq, endseq; 401 chain beginseq, mainseq, endseq;
398 chain *seq; 402 chain *seq;
399 node *break_ptr, *continue_ptr; 403 node *break_ptr, *continue_ptr;
@@ -442,16 +446,16 @@ struct globals2 {
442 tsplitter exec_builtin__tspl; 446 tsplitter exec_builtin__tspl;
443 447
444 /* biggest and least used members go last */ 448 /* biggest and least used members go last */
445 double t_double;
446 tsplitter fsplitter, rsplitter; 449 tsplitter fsplitter, rsplitter;
447}; 450};
448#define G1 (ptr_to_globals[-1]) 451#define G1 (ptr_to_globals[-1])
449#define G (*(struct globals2 *)ptr_to_globals) 452#define G (*(struct globals2 *)ptr_to_globals)
450/* For debug. nm --size-sort awk.o | grep -vi ' [tr] ' */ 453/* For debug. nm --size-sort awk.o | grep -vi ' [tr] ' */
451/* char G1size[sizeof(G1)]; - 0x6c */ 454/*char G1size[sizeof(G1)]; - 0x74 */
452/* char Gsize[sizeof(G)]; - 0x1cc */ 455/*char Gsize[sizeof(G)]; - 0x1c4 */
453/* Trying to keep most of members accessible with short offsets: */ 456/* Trying to keep most of members accessible with short offsets: */
454/* char Gofs_seed[offsetof(struct globals2, evaluate__seed)]; - 0x90 */ 457/*char Gofs_seed[offsetof(struct globals2, evaluate__seed)]; - 0x90 */
458#define t_double (G1.t_double )
455#define beginseq (G1.beginseq ) 459#define beginseq (G1.beginseq )
456#define mainseq (G1.mainseq ) 460#define mainseq (G1.mainseq )
457#define endseq (G1.endseq ) 461#define endseq (G1.endseq )
@@ -479,7 +483,6 @@ struct globals2 {
479#define t_info (G.t_info ) 483#define t_info (G.t_info )
480#define t_tclass (G.t_tclass ) 484#define t_tclass (G.t_tclass )
481#define t_string (G.t_string ) 485#define t_string (G.t_string )
482#define t_double (G.t_double )
483#define t_lineno (G.t_lineno ) 486#define t_lineno (G.t_lineno )
484#define t_rollback (G.t_rollback ) 487#define t_rollback (G.t_rollback )
485#define intvar (G.intvar ) 488#define intvar (G.intvar )
diff --git a/include/libbb.h b/include/libbb.h
index 9e0399eee..08fed90a7 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1275,7 +1275,13 @@ enum {
1275 PSSCAN_UTIME = 1 << 13, 1275 PSSCAN_UTIME = 1 << 13,
1276 PSSCAN_TTY = 1 << 14, 1276 PSSCAN_TTY = 1 << 14,
1277 PSSCAN_SMAPS = (1 << 15) * ENABLE_FEATURE_TOPMEM, 1277 PSSCAN_SMAPS = (1 << 15) * ENABLE_FEATURE_TOPMEM,
1278 PSSCAN_ARGVN = (1 << 16) * (ENABLE_PGREP || ENABLE_PKILL || ENABLE_PIDOF), 1278 /* NB: used by find_pid_by_name(). Any applet using it
1279 * needs to be mentioned here. */
1280 PSSCAN_ARGVN = (1 << 16) * (ENABLE_KILLALL
1281 || ENABLE_PGREP || ENABLE_PKILL
1282 || ENABLE_PIDOF
1283 || ENABLE_SESTATUS
1284 ),
1279 USE_SELINUX(PSSCAN_CONTEXT = 1 << 17,) 1285 USE_SELINUX(PSSCAN_CONTEXT = 1 << 17,)
1280 PSSCAN_START_TIME = 1 << 18, 1286 PSSCAN_START_TIME = 1 << 18,
1281 PSSCAN_CPU = 1 << 19, 1287 PSSCAN_CPU = 1 << 19,
diff --git a/init/init.c b/init/init.c
index 10f5ba68d..553650411 100644
--- a/init/init.c
+++ b/init/init.c
@@ -671,15 +671,14 @@ static void new_init_action(uint8_t action_type, const char *command, const char
671 */ 671 */
672static void parse_inittab(void) 672static void parse_inittab(void)
673{ 673{
674#if ENABLE_FEATURE_USE_INITTAB
674 char *token[4]; 675 char *token[4];
675 /* order must correspond to SYSINIT..RESTART constants */ 676 parser_t *parser = config_open2("/etc/inittab", fopen_for_read);
676 static const char actions[] ALIGN1 = 677
677 "sysinit\0""respawn\0""askfirst\0""wait\0""once\0" 678 if (parser == NULL)
678 "ctrlaltdel\0""shutdown\0""restart\0"; 679#endif
679 680 {
680 parser_t *parser = config_open2(INITTAB, fopen_for_read); 681 /* No inittab file -- set up some default behavior */
681 /* No inittab file -- set up some default behavior */
682 if (parser == NULL) {
683 /* Reboot on Ctrl-Alt-Del */ 682 /* Reboot on Ctrl-Alt-Del */
684 new_init_action(CTRLALTDEL, "reboot", ""); 683 new_init_action(CTRLALTDEL, "reboot", "");
685 /* Umount all filesystems on halt/reboot */ 684 /* Umount all filesystems on halt/reboot */
@@ -699,11 +698,17 @@ static void parse_inittab(void)
699 new_init_action(SYSINIT, INIT_SCRIPT, ""); 698 new_init_action(SYSINIT, INIT_SCRIPT, "");
700 return; 699 return;
701 } 700 }
701
702#if ENABLE_FEATURE_USE_INITTAB
702 /* optional_tty:ignored_runlevel:action:command 703 /* optional_tty:ignored_runlevel:action:command
703 * Delims are not to be collapsed and need exactly 4 tokens 704 * Delims are not to be collapsed and need exactly 4 tokens
704 */ 705 */
705 while (config_read(parser, token, 4, 0, "#:", 706 while (config_read(parser, token, 4, 0, "#:",
706 PARSE_NORMAL & ~(PARSE_TRIM | PARSE_COLLAPSE))) { 707 PARSE_NORMAL & ~(PARSE_TRIM | PARSE_COLLAPSE))) {
708 /* order must correspond to SYSINIT..RESTART constants */
709 static const char actions[] ALIGN1 =
710 "sysinit\0""respawn\0""askfirst\0""wait\0""once\0"
711 "ctrlaltdel\0""shutdown\0""restart\0";
707 int action; 712 int action;
708 char *tty = token[0]; 713 char *tty = token[0];
709 714
@@ -727,6 +732,7 @@ static void parse_inittab(void)
727 parser->lineno); 732 parser->lineno);
728 } 733 }
729 config_close(parser); 734 config_close(parser);
735#endif
730} 736}
731 737
732#if ENABLE_FEATURE_USE_INITTAB 738#if ENABLE_FEATURE_USE_INITTAB
diff --git a/modutils/depmod.c b/modutils/depmod.c
index a4474d5e4..7f3e1d8a6 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -33,7 +33,7 @@ typedef struct module_info {
33enum { 33enum {
34 ARG_a = (1<<0), /* All modules, ignore mods in argv */ 34 ARG_a = (1<<0), /* All modules, ignore mods in argv */
35 ARG_A = (1<<1), /* Only emit .ko that are newer than modules.dep file */ 35 ARG_A = (1<<1), /* Only emit .ko that are newer than modules.dep file */
36 ARG_b = (1<<2), /* not /lib/modules/$(uname -r)/ but this base-dir */ 36 ARG_b = (1<<2), /* base directory when modules are in staging area */
37 ARG_e = (1<<3), /* with -F, print unresolved symbols */ 37 ARG_e = (1<<3), /* with -F, print unresolved symbols */
38 ARG_F = (1<<4), /* System.map that contains the symbols */ 38 ARG_F = (1<<4), /* System.map that contains the symbols */
39 ARG_n = (1<<5) /* dry-run, print to stdout only */ 39 ARG_n = (1<<5) /* dry-run, print to stdout only */
@@ -57,7 +57,7 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb,
57 *first = info; 57 *first = info;
58 58
59 info->dnext = info->dprev = info; 59 info->dnext = info->dprev = info;
60 info->name = xstrdup(fname); 60 info->name = xasprintf("/%s", fname);
61 info->modname = filename2modname(fname, NULL); 61 info->modname = filename2modname(fname, NULL);
62 for (ptr = image; ptr < image + len - 10; ptr++) { 62 for (ptr = image; ptr < image + len - 10; ptr++) {
63 if (strncmp(ptr, "depends=", 8) == 0) { 63 if (strncmp(ptr, "depends=", 8) == 0) {
@@ -123,44 +123,61 @@ static void order_dep_list(module_info *modules, module_info *start,
123 } 123 }
124} 124}
125 125
126static void xfreopen_write(const char *file, FILE *f)
127{
128 if (freopen(file, "w", f) == NULL)
129 bb_perror_msg_and_die("can't open '%s'", file);
130}
131
126int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 132int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
127int depmod_main(int argc UNUSED_PARAM, char **argv) 133int depmod_main(int argc UNUSED_PARAM, char **argv)
128{ 134{
129 module_info *modules = NULL, *m, *dep; 135 module_info *modules = NULL, *m, *dep;
130 char *moddir_base = (char *)CONFIG_DEFAULT_MODULES_DIR; 136 const char *moddir_base = "/";
137 char *moddir, *version;
138 struct utsname uts;
131 int tmp; 139 int tmp;
132 140
133 getopt32(argv, "aAb:eF:n", &moddir_base, NULL); 141 getopt32(argv, "aAb:eF:n", &moddir_base, NULL);
134 argv += optind; 142 argv += optind;
135 143
136 /* goto modules location */ 144 /* goto modules location */
145 xchdir(moddir_base);
137 146
138 /* If a version is provided, then that kernel version's module directory 147 /* If a version is provided, then that kernel version's module directory
139 * is used, rather than the current kernel version (as returned by 148 * is used, rather than the current kernel version (as returned by
140 * "uname -r"). */ 149 * "uname -r"). */
141 xchdir(moddir_base); 150 if (*argv && sscanf(*argv, "%d.%d.%d", &tmp, &tmp, &tmp) == 3) {
142 if (*argv && (sscanf(*argv, "%d.%d.%d", &tmp, &tmp, &tmp) == 3)) { 151 version = *argv++;
143 xchdir(*argv++);
144 } else { 152 } else {
145 struct utsname uts;
146 uname(&uts); 153 uname(&uts);
147 xchdir(uts.release); 154 version = uts.release;
148 } 155 }
149 /* If no modules are given on the command-line, -a is on per default. */ 156 moddir = concat_path_file(&CONFIG_DEFAULT_MODULES_DIR[1], version);
150 option_mask32 |= *argv == NULL;
151 157
152 /* Scan modules */ 158 /* Scan modules */
153 moddir_base = xrealloc_getcwd_or_warn(NULL); 159 if (*argv) {
154 do { 160 char *modfile;
155 recursive_action((option_mask32 & ARG_a) ? moddir_base : *argv, 161 struct stat sb;
156 ACTION_RECURSE, parse_module, NULL, &modules, 0); 162 do {
157 } while (!(option_mask32 & ARG_a) && *(++argv)); 163 modfile = concat_path_file(moddir, *argv);
164 xstat(modfile, &sb);
165 parse_module(modfile, &sb, &modules, 0);
166 free(modfile);
167 } while (*(++argv));
168 } else {
169 recursive_action(moddir, ACTION_RECURSE,
170 parse_module, NULL, &modules, 0);
171 }
172
173 /* Prepare for writing out the dep files */
174 xchdir(moddir);
158 if (ENABLE_FEATURE_CLEAN_UP) 175 if (ENABLE_FEATURE_CLEAN_UP)
159 free(moddir_base); 176 free(moddir);
160 177
161 /* Generate dependency and alias files */ 178 /* Generate dependency and alias files */
162 if (!(option_mask32 & ARG_n)) 179 if (!(option_mask32 & ARG_n))
163 freopen(CONFIG_DEFAULT_DEPMOD_FILE, "w", stdout); 180 xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout);
164 for (m = modules; m != NULL; m = m->next) { 181 for (m = modules; m != NULL; m = m->next) {
165 printf("%s:", m->name); 182 printf("%s:", m->name);
166 183
@@ -174,12 +191,12 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
174 dep->dprev->dnext = dep->dnext; 191 dep->dprev->dnext = dep->dnext;
175 dep->dnext = dep->dprev = dep; 192 dep->dnext = dep->dprev = dep;
176 } 193 }
177 puts(""); 194 bb_putchar('\n');
178 } 195 }
179 196
180#if ENABLE_FEATURE_MODUTILS_ALIAS 197#if ENABLE_FEATURE_MODUTILS_ALIAS
181 if (!(option_mask32 & ARG_n)) 198 if (!(option_mask32 & ARG_n))
182 freopen("modules.alias", "w", stdout); 199 xfreopen_write("modules.alias", stdout);
183 for (m = modules; m != NULL; m = m->next) { 200 for (m = modules; m != NULL; m = m->next) {
184 while (m->aliases) { 201 while (m->aliases) {
185 printf("alias %s %s\n", 202 printf("alias %s %s\n",
@@ -190,7 +207,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
190#endif 207#endif
191#if ENABLE_FEATURE_MODUTILS_SYMBOLS 208#if ENABLE_FEATURE_MODUTILS_SYMBOLS
192 if (!(option_mask32 & ARG_n)) 209 if (!(option_mask32 & ARG_n))
193 freopen("modules.symbols", "w", stdout); 210 xfreopen_write("modules.symbols", stdout);
194 for (m = modules; m != NULL; m = m->next) { 211 for (m = modules; m != NULL; m = m->next) {
195 while (m->symbols) { 212 while (m->symbols) {
196 printf("alias symbol:%s %s\n", 213 printf("alias symbol:%s %s\n",
diff --git a/modutils/modutils-24.c b/modutils/modutils-24.c
index c6e7226cd..622ab3abe 100644
--- a/modutils/modutils-24.c
+++ b/modutils/modutils-24.c
@@ -2150,7 +2150,7 @@ static struct obj_section *obj_create_alloced_section(struct obj_file *f,
2150 sec->name = name; 2150 sec->name = name;
2151 sec->idx = newidx; 2151 sec->idx = newidx;
2152 if (size) 2152 if (size)
2153 sec->contents = xmalloc(size); 2153 sec->contents = xzalloc(size);
2154 2154
2155 obj_insert_section_load_order(f, sec); 2155 obj_insert_section_load_order(f, sec);
2156 2156
@@ -2165,7 +2165,7 @@ static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
2165 int newidx = f->header.e_shnum++; 2165 int newidx = f->header.e_shnum++;
2166 struct obj_section *sec; 2166 struct obj_section *sec;
2167 2167
2168 f->sections = xrealloc(f->sections, (newidx + 1) * sizeof(sec)); 2168 f->sections = xrealloc_vector(f->sections, 2, newidx);
2169 f->sections[newidx] = sec = arch_new_section(); 2169 f->sections[newidx] = sec = arch_new_section();
2170 2170
2171 sec->header.sh_type = SHT_PROGBITS; 2171 sec->header.sh_type = SHT_PROGBITS;
@@ -2175,7 +2175,7 @@ static struct obj_section *obj_create_alloced_section_first(struct obj_file *f,
2175 sec->name = name; 2175 sec->name = name;
2176 sec->idx = newidx; 2176 sec->idx = newidx;
2177 if (size) 2177 if (size)
2178 sec->contents = xmalloc(size); 2178 sec->contents = xzalloc(size);
2179 2179
2180 sec->load_next = f->load_order; 2180 sec->load_next = f->load_order;
2181 f->load_order = sec; 2181 f->load_order = sec;
@@ -2571,8 +2571,7 @@ static void new_get_kernel_symbols(void)
2571 /* Collect the modules' symbols. */ 2571 /* Collect the modules' symbols. */
2572 2572
2573 if (nmod) { 2573 if (nmod) {
2574 ext_modules = modules = xmalloc(nmod * sizeof(*modules)); 2574 ext_modules = modules = xzalloc(nmod * sizeof(*modules));
2575 memset(modules, 0, nmod * sizeof(*modules));
2576 for (i = 0, mn = module_names, m = modules; 2575 for (i = 0, mn = module_names, m = modules;
2577 i < nmod; ++i, ++m, mn += strlen(mn) + 1) { 2576 i < nmod; ++i, ++m, mn += strlen(mn) + 1) {
2578 struct new_module_info info; 2577 struct new_module_info info;
@@ -2652,13 +2651,14 @@ static int new_is_kernel_checksummed(void)
2652} 2651}
2653 2652
2654 2653
2655static void new_create_this_module(struct obj_file *f, const char *m_name) 2654static void new_create_this_module(struct obj_file *f, const char *m_name)
2656{ 2655{
2657 struct obj_section *sec; 2656 struct obj_section *sec;
2658 2657
2659 sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long, 2658 sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long,
2660 sizeof(struct new_module)); 2659 sizeof(struct new_module));
2661 memset(sec->contents, 0, sizeof(struct new_module)); 2660 /* done by obj_create_alloced_section_first: */
2661 /*memset(sec->contents, 0, sizeof(struct new_module));*/
2662 2662
2663 obj_add_symbol(f, SPFX "__this_module", -1, 2663 obj_add_symbol(f, SPFX "__this_module", -1,
2664 ELF_ST_INFO(STB_LOCAL, STT_OBJECT), sec->idx, 0, 2664 ELF_ST_INFO(STB_LOCAL, STT_OBJECT), sec->idx, 0,
@@ -2965,9 +2965,9 @@ static void obj_allocate_commons(struct obj_file *f)
2965 if (i == f->header.e_shnum) { 2965 if (i == f->header.e_shnum) {
2966 struct obj_section *sec; 2966 struct obj_section *sec;
2967 2967
2968 f->header.e_shnum++;
2968 f->sections = xrealloc_vector(f->sections, 2, i); 2969 f->sections = xrealloc_vector(f->sections, 2, i);
2969 f->sections[i] = sec = arch_new_section(); 2970 f->sections[i] = sec = arch_new_section();
2970 f->header.e_shnum = i + 1;
2971 2971
2972 sec->header.sh_type = SHT_PROGBITS; 2972 sec->header.sh_type = SHT_PROGBITS;
2973 sec->header.sh_flags = SHF_WRITE | SHF_ALLOC; 2973 sec->header.sh_flags = SHF_WRITE | SHF_ALLOC;
@@ -3006,12 +3006,9 @@ static void obj_allocate_commons(struct obj_file *f)
3006 for (i = 0; i < f->header.e_shnum; ++i) { 3006 for (i = 0; i < f->header.e_shnum; ++i) {
3007 struct obj_section *s = f->sections[i]; 3007 struct obj_section *s = f->sections[i];
3008 if (s->header.sh_type == SHT_NOBITS) { 3008 if (s->header.sh_type == SHT_NOBITS) {
3009 s->contents = NULL;
3009 if (s->header.sh_size != 0) 3010 if (s->header.sh_size != 0)
3010 s->contents = memset(xmalloc(s->header.sh_size), 3011 s->contents = xzalloc(s->header.sh_size);
3011 0, s->header.sh_size);
3012 else
3013 s->contents = NULL;
3014
3015 s->header.sh_type = SHT_PROGBITS; 3012 s->header.sh_type = SHT_PROGBITS;
3016 } 3013 }
3017 } 3014 }
@@ -3275,14 +3272,13 @@ static struct obj_file *obj_load(FILE *fp, int loadprogbits UNUSED_PARAM)
3275 case SHT_SYMTAB: 3272 case SHT_SYMTAB:
3276 case SHT_STRTAB: 3273 case SHT_STRTAB:
3277 case SHT_RELM: 3274 case SHT_RELM:
3275 sec->contents = NULL;
3278 if (sec->header.sh_size > 0) { 3276 if (sec->header.sh_size > 0) {
3279 sec->contents = xmalloc(sec->header.sh_size); 3277 sec->contents = xzalloc(sec->header.sh_size);
3280 fseek(fp, sec->header.sh_offset, SEEK_SET); 3278 fseek(fp, sec->header.sh_offset, SEEK_SET);
3281 if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { 3279 if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) {
3282 bb_perror_msg_and_die("error reading ELF section data"); 3280 bb_perror_msg_and_die("error reading ELF section data");
3283 } 3281 }
3284 } else {
3285 sec->contents = NULL;
3286 } 3282 }
3287 break; 3283 break;
3288 3284
diff --git a/testsuite/mdev.tests b/testsuite/mdev.tests
index 22855791a..90379e668 100755
--- a/testsuite/mdev.tests
+++ b/testsuite/mdev.tests
@@ -111,6 +111,22 @@ brw-r--r-- 1 0 0 8,0 sda
111 111
112# continuing to use directory structure from prev test 112# continuing to use directory structure from prev test
113rm -rf mdev.testdir/dev/* 113rm -rf mdev.testdir/dev/*
114echo "sda 0:0 644 =block/ @echo @echo TEST" >mdev.testdir/etc/mdev.conf
115testing "mdev move and command" \
116 "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
117 ls -lnR mdev.testdir/dev | $FILTER_LS2" \
118"\
119@echo TEST
120mdev.testdir/dev:
121drwxr-xr-x 2 0 0 block
122
123mdev.testdir/dev/block:
124brw-r--r-- 1 0 0 sda
125" \
126 "" ""
127
128# continuing to use directory structure from prev test
129rm -rf mdev.testdir/dev/*
114echo "@8,0 :1 644" >mdev.testdir/etc/mdev.conf 130echo "@8,0 :1 644" >mdev.testdir/etc/mdev.conf
115testing "mdev #maj,min and no explicit uid" \ 131testing "mdev #maj,min and no explicit uid" \
116 "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1; 132 "env - PATH=$PATH ACTION=add DEVPATH=/block/sda chroot mdev.testdir /mdev 2>&1;
diff --git a/util-linux/mdev.c b/util-linux/mdev.c
index 34cabc934..d8b603e2b 100644
--- a/util-linux/mdev.c
+++ b/util-linux/mdev.c
@@ -179,8 +179,9 @@ static void make_device(char *path, int delete)
179 unsigned i, n; 179 unsigned i, n;
180#endif 180#endif
181 char *a = val; 181 char *a = val;
182 s = strchr(val, ' '); 182 s = strchrnul(val, ' ');
183 val = (s && s[1]) ? s+1 : NULL; 183 val = (s[0] && s[1]) ? s+1 : NULL;
184 s[0] = '\0';
184#if ENABLE_FEATURE_MDEV_RENAME_REGEXP 185#if ENABLE_FEATURE_MDEV_RENAME_REGEXP
185 /* substitute %1..9 with off[1..9], if any */ 186 /* substitute %1..9 with off[1..9], if any */
186 n = 0; 187 n = 0;