diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-30 08:04:05 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-30 08:04:05 +0000 |
| commit | dc757aa16ce53d9784fa3953b0c3762dfa8ccda9 (patch) | |
| tree | 2eee7a83dcbd38fcfbcdbec8b5d52f4baff3326f | |
| parent | f7d07b1723c15ee818f0c1f5cce96c55274024a6 (diff) | |
| download | busybox-w32-dc757aa16ce53d9784fa3953b0c3762dfa8ccda9.tar.gz busybox-w32-dc757aa16ce53d9784fa3953b0c3762dfa8ccda9.tar.bz2 busybox-w32-dc757aa16ce53d9784fa3953b0c3762dfa8ccda9.zip | |
introduce and use bb_basename()
function old new delta
bb_basename - 26 +26
sv_main 1226 1225 -1
passwd_main 1985 1983 -2
showdirs 482 478 -4
sendCgi 1811 1807 -4
make_device 1354 1350 -4
handleIncoming 2443 2439 -4
func_name 82 78 -4
service_name 2292 2285 -7
main 909 901 -8
cmp_main 555 547 -8
test_main 434 422 -12
act 228 216 -12
find_pair 180 164 -16
rmmod_main 298 280 -18
find_pid_by_name 156 134 -22
modprobe_main 1606 1576 -30
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 0/16 up/down: 26/-156) Total: -130 bytes
text data bss dec hex filename
734933 3028 14400 752361 b7ae9 busybox_old
734801 3028 14400 752229 b7a65 busybox_unstripped
| -rw-r--r-- | applets/applets.c | 6 | ||||
| -rw-r--r-- | coreutils/ls.c | 14 | ||||
| -rw-r--r-- | coreutils/test.c | 5 | ||||
| -rw-r--r-- | debianutils/run_parts.c | 5 | ||||
| -rw-r--r-- | findutils/find.c | 19 | ||||
| -rw-r--r-- | include/libbb.h | 1 | ||||
| -rw-r--r-- | libbb/Kbuild | 1 | ||||
| -rw-r--r-- | libbb/find_pid_by_name.c | 8 | ||||
| -rw-r--r-- | libbb/lineedit.c | 2 | ||||
| -rw-r--r-- | miscutils/devfsd.c | 16 | ||||
| -rw-r--r-- | modutils/modprobe.c | 21 | ||||
| -rw-r--r-- | modutils/rmmod.c | 7 | ||||
| -rw-r--r-- | networking/httpd.c | 4 | ||||
| -rw-r--r-- | util-linux/mdev.c | 4 |
14 files changed, 40 insertions, 73 deletions
diff --git a/applets/applets.c b/applets/applets.c index 57c972f79..89dea3e6a 100644 --- a/applets/applets.c +++ b/applets/applets.c | |||
| @@ -639,8 +639,6 @@ int *const bb_errno __attribute__ ((section (".data"))); | |||
| 639 | 639 | ||
| 640 | int main(int argc, char **argv) | 640 | int main(int argc, char **argv) |
| 641 | { | 641 | { |
| 642 | const char *s; | ||
| 643 | |||
| 644 | #ifdef __GLIBC__ | 642 | #ifdef __GLIBC__ |
| 645 | (*(int **)&bb_errno) = __errno_location(); | 643 | (*(int **)&bb_errno) = __errno_location(); |
| 646 | #endif | 644 | #endif |
| @@ -655,9 +653,7 @@ int main(int argc, char **argv) | |||
| 655 | applet_name = argv[0]; | 653 | applet_name = argv[0]; |
| 656 | if (applet_name[0] == '-') | 654 | if (applet_name[0] == '-') |
| 657 | applet_name++; | 655 | applet_name++; |
| 658 | s = strrchr(applet_name, '/'); | 656 | applet_name = bb_basename(applet_name); |
| 659 | if (s) | ||
| 660 | applet_name = s + 1; | ||
| 661 | 657 | ||
| 662 | parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */ | 658 | parse_config_file(); /* ...maybe, if FEATURE_SUID_CONFIG */ |
| 663 | 659 | ||
diff --git a/coreutils/ls.c b/coreutils/ls.c index e2ed3ee1f..a5bd0e304 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c | |||
| @@ -132,8 +132,8 @@ enum { show_color = 0 }; | |||
| 132 | * a directory entry and its stat info are stored here | 132 | * a directory entry and its stat info are stored here |
| 133 | */ | 133 | */ |
| 134 | struct dnode { /* the basic node */ | 134 | struct dnode { /* the basic node */ |
| 135 | char *name; /* the dir entry name */ | 135 | const char *name; /* the dir entry name */ |
| 136 | char *fullname; /* the dir entry name */ | 136 | const char *fullname; /* the dir entry name */ |
| 137 | int allocated; | 137 | int allocated; |
| 138 | struct stat dstat; /* the file stat info */ | 138 | struct stat dstat; /* the file stat info */ |
| 139 | USE_SELINUX(security_context_t sid;) | 139 | USE_SELINUX(security_context_t sid;) |
| @@ -159,7 +159,7 @@ enum { | |||
| 159 | 159 | ||
| 160 | static int status = EXIT_SUCCESS; | 160 | static int status = EXIT_SUCCESS; |
| 161 | 161 | ||
| 162 | static struct dnode *my_stat(char *fullname, char *name, int force_follow) | 162 | static struct dnode *my_stat(const char *fullname, const char *name, int force_follow) |
| 163 | { | 163 | { |
| 164 | struct stat dstat; | 164 | struct stat dstat; |
| 165 | struct dnode *cur; | 165 | struct dnode *cur; |
| @@ -241,7 +241,7 @@ static int count_dirs(struct dnode **dn, int nfiles, int notsubdirs) | |||
| 241 | return 0; | 241 | return 0; |
| 242 | dirs = 0; | 242 | dirs = 0; |
| 243 | for (i = 0; i < nfiles; i++) { | 243 | for (i = 0; i < nfiles; i++) { |
| 244 | char *name; | 244 | const char *name; |
| 245 | if (!S_ISDIR(dn[i]->dstat.st_mode)) | 245 | if (!S_ISDIR(dn[i]->dstat.st_mode)) |
| 246 | continue; | 246 | continue; |
| 247 | name = dn[i]->name; | 247 | name = dn[i]->name; |
| @@ -288,7 +288,7 @@ static void dfree(struct dnode **dnp, int nfiles) | |||
| 288 | for (i = 0; i < nfiles; i++) { | 288 | for (i = 0; i < nfiles; i++) { |
| 289 | struct dnode *cur = dnp[i]; | 289 | struct dnode *cur = dnp[i]; |
| 290 | if (cur->allocated) | 290 | if (cur->allocated) |
| 291 | free(cur->fullname); /* free the filename */ | 291 | free((char*)cur->fullname); /* free the filename */ |
| 292 | free(cur); /* free the dnode */ | 292 | free(cur); /* free the dnode */ |
| 293 | } | 293 | } |
| 294 | free(dnp); /* free the array holding the dnode pointers */ | 294 | free(dnp); /* free the array holding the dnode pointers */ |
| @@ -320,7 +320,7 @@ static struct dnode **splitdnarray(struct dnode **dn, int nfiles, int which) | |||
| 320 | /* copy the entrys into the file or dir array */ | 320 | /* copy the entrys into the file or dir array */ |
| 321 | for (d = i = 0; i < nfiles; i++) { | 321 | for (d = i = 0; i < nfiles; i++) { |
| 322 | if (S_ISDIR(dn[i]->dstat.st_mode)) { | 322 | if (S_ISDIR(dn[i]->dstat.st_mode)) { |
| 323 | char *name; | 323 | const char *name; |
| 324 | if (!(which & (SPLIT_DIR|SPLIT_SUBDIR))) | 324 | if (!(which & (SPLIT_DIR|SPLIT_SUBDIR))) |
| 325 | continue; | 325 | continue; |
| 326 | name = dn[i]->name; | 326 | name = dn[i]->name; |
| @@ -513,7 +513,7 @@ static struct dnode **list_dir(const char *path) | |||
| 513 | continue; | 513 | continue; |
| 514 | } | 514 | } |
| 515 | fullname = concat_path_file(path, entry->d_name); | 515 | fullname = concat_path_file(path, entry->d_name); |
| 516 | cur = my_stat(fullname, strrchr(fullname, '/') + 1, 0); | 516 | cur = my_stat(fullname, bb_basename(fullname), 0); |
| 517 | if (!cur) { | 517 | if (!cur) { |
| 518 | free(fullname); | 518 | free(fullname); |
| 519 | continue; | 519 | continue; |
diff --git a/coreutils/test.c b/coreutils/test.c index 7b87a42f9..82d2664a8 100644 --- a/coreutils/test.c +++ b/coreutils/test.c | |||
| @@ -181,11 +181,10 @@ static void initialize_group_array(void); | |||
| 181 | int test_main(int argc, char **argv) | 181 | int test_main(int argc, char **argv) |
| 182 | { | 182 | { |
| 183 | int res; | 183 | int res; |
| 184 | char *arg0; | 184 | const char *arg0; |
| 185 | bool _off; | 185 | bool _off; |
| 186 | 186 | ||
| 187 | arg0 = strrchr(argv[0], '/'); | 187 | arg0 = bb_basename(argv[0]); |
| 188 | if (!arg0++) arg0 = argv[0]; | ||
| 189 | if (arg0[0] == '[') { | 188 | if (arg0[0] == '[') { |
| 190 | --argc; | 189 | --argc; |
| 191 | if (!arg0[1]) { /* "[" ? */ | 190 | if (!arg0[1]) { /* "[" ? */ |
diff --git a/debianutils/run_parts.c b/debianutils/run_parts.c index cb4a4e4c7..42170bcb8 100644 --- a/debianutils/run_parts.c +++ b/debianutils/run_parts.c | |||
| @@ -60,10 +60,7 @@ struct globals { | |||
| 60 | */ | 60 | */ |
| 61 | static bool invalid_name(const char *c) | 61 | static bool invalid_name(const char *c) |
| 62 | { | 62 | { |
| 63 | const char *base_name = strrchr(c, '/'); | 63 | c = bb_basename(c); |
| 64 | |||
| 65 | if (base_name) | ||
| 66 | c = base_name + 1; | ||
| 67 | 64 | ||
| 68 | while (*c && (isalnum(*c) || *c == '_' || *c == '-')) | 65 | while (*c && (isalnum(*c) || *c == '_' || *c == '-')) |
| 69 | c++; | 66 | c++; |
diff --git a/findutils/find.c b/findutils/find.c index aa2244141..07cae971e 100644 --- a/findutils/find.c +++ b/findutils/find.c | |||
| @@ -180,18 +180,13 @@ static int exec_actions(action ***appp, const char *fileName, struct stat *statb | |||
| 180 | 180 | ||
| 181 | ACTF(name) | 181 | ACTF(name) |
| 182 | { | 182 | { |
| 183 | const char *tmp = strrchr(fileName, '/'); | 183 | const char *tmp = bb_basename(fileName); |
| 184 | if (tmp == NULL) | 184 | if (tmp != fileName && !*tmp) { /* "foo/bar/". Oh no... go back to 'b' */ |
| 185 | tmp = fileName; | 185 | tmp--; |
| 186 | else { | 186 | while (tmp != fileName && *--tmp != '/') |
| 187 | tmp++; | 187 | continue; |
| 188 | if (!*tmp) { /* "foo/bar/". Oh no... go back to 'b' */ | 188 | if (*tmp == '/') |
| 189 | tmp--; | 189 | tmp++; |
| 190 | while (tmp != fileName && *--tmp != '/') | ||
| 191 | continue; | ||
| 192 | if (*tmp == '/') | ||
| 193 | tmp++; | ||
| 194 | } | ||
| 195 | } | 190 | } |
| 196 | return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0; | 191 | return fnmatch(ap->pattern, tmp, FNM_PERIOD) == 0; |
| 197 | } | 192 | } |
diff --git a/include/libbb.h b/include/libbb.h index e80e76403..6a699a7e6 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
| @@ -736,6 +736,7 @@ extern int bb_parse_mode(const char* s, mode_t* theMode); | |||
| 736 | 736 | ||
| 737 | char *concat_path_file(const char *path, const char *filename); | 737 | char *concat_path_file(const char *path, const char *filename); |
| 738 | char *concat_subpath_file(const char *path, const char *filename); | 738 | char *concat_subpath_file(const char *path, const char *filename); |
| 739 | const char *bb_basename(const char *name); | ||
| 739 | /* NB: can violate const-ness (similarly to strchr) */ | 740 | /* NB: can violate const-ness (similarly to strchr) */ |
| 740 | char *last_char_is(const char *s, int c); | 741 | char *last_char_is(const char *s, int c); |
| 741 | 742 | ||
diff --git a/libbb/Kbuild b/libbb/Kbuild index 693f6092c..ecd50a616 100644 --- a/libbb/Kbuild +++ b/libbb/Kbuild | |||
| @@ -8,6 +8,7 @@ lib-y:= | |||
| 8 | 8 | ||
| 9 | lib-y += ask_confirmation.o | 9 | lib-y += ask_confirmation.o |
| 10 | lib-y += bb_askpass.o | 10 | lib-y += bb_askpass.o |
| 11 | lib-y += bb_basename.o | ||
| 11 | lib-y += bb_do_delay.o | 12 | lib-y += bb_do_delay.o |
| 12 | lib-y += bb_pwd.o | 13 | lib-y += bb_pwd.o |
| 13 | lib-y += bb_strtonum.o | 14 | lib-y += bb_strtonum.o |
diff --git a/libbb/find_pid_by_name.c b/libbb/find_pid_by_name.c index cfc5b3468..1fafec83a 100644 --- a/libbb/find_pid_by_name.c +++ b/libbb/find_pid_by_name.c | |||
| @@ -38,14 +38,6 @@ execXXX("/proc/self/exe", applet_name, params....) | |||
| 38 | and therefore comm field contains "exe". | 38 | and therefore comm field contains "exe". |
| 39 | */ | 39 | */ |
| 40 | 40 | ||
| 41 | static const char *bb_basename(const char *name) | ||
| 42 | { | ||
| 43 | const char *cp = strrchr(name, '/'); | ||
| 44 | if (cp) | ||
| 45 | return cp + 1; | ||
| 46 | return name; | ||
| 47 | } | ||
| 48 | |||
| 49 | /* find_pid_by_name() | 41 | /* find_pid_by_name() |
| 50 | * | 42 | * |
| 51 | * Modified by Vladimir Oleynik for use with libbb/procps.c | 43 | * Modified by Vladimir Oleynik for use with libbb/procps.c |
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 1f2e6a54e..62f8949d6 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
| @@ -1156,7 +1156,7 @@ static void parse_prompt(const char *prmt_ptr) | |||
| 1156 | #endif | 1156 | #endif |
| 1157 | case 'W': | 1157 | case 'W': |
| 1158 | pbuf = pwd_buf; | 1158 | pbuf = pwd_buf; |
| 1159 | cp = strrchr(pbuf,'/'); | 1159 | cp = strrchr(pbuf, '/'); |
| 1160 | if (cp != NULL && cp != pbuf) | 1160 | if (cp != NULL && cp != pbuf) |
| 1161 | pbuf += (cp-pbuf) + 1; | 1161 | pbuf += (cp-pbuf) + 1; |
| 1162 | break; | 1162 | break; |
diff --git a/miscutils/devfsd.c b/miscutils/devfsd.c index dfb616abe..9daf4e1cc 100644 --- a/miscutils/devfsd.c +++ b/miscutils/devfsd.c | |||
| @@ -240,8 +240,8 @@ static void do_ioctl_and_die(int fd, int request, unsigned long event_mask_flag) | |||
| 240 | static void fork_and_execute(int die, char *arg0, char **arg); | 240 | static void fork_and_execute(int die, char *arg0, char **arg); |
| 241 | static int get_uid_gid(int, const char *); | 241 | static int get_uid_gid(int, const char *); |
| 242 | static void safe_memcpy(char * dest, const char * src, int len); | 242 | static void safe_memcpy(char * dest, const char * src, int len); |
| 243 | static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, char *ptr); | 243 | static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, const char *ptr); |
| 244 | static unsigned int scan_dev_name(const char *d, unsigned int n, char *ptr); | 244 | static unsigned int scan_dev_name(const char *d, unsigned int n, const char *ptr); |
| 245 | 245 | ||
| 246 | /* Structs and vars */ | 246 | /* Structs and vars */ |
| 247 | static struct config_entry_struct *first_config = NULL; | 247 | static struct config_entry_struct *first_config = NULL; |
| @@ -369,7 +369,7 @@ static void safe_memcpy(char *dest, const char *src, int len) | |||
| 369 | dest[len] = '\0'; | 369 | dest[len] = '\0'; |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, char *ptr) | 372 | static unsigned int scan_dev_name_common(const char *d, unsigned int n, int addendum, const char *ptr) |
| 373 | { | 373 | { |
| 374 | if (d[n - 4] == 'd' && d[n - 3] == 'i' && d[n - 2] == 's' && d[n - 1] == 'c') | 374 | if (d[n - 4] == 'd' && d[n - 3] == 'i' && d[n - 2] == 's' && d[n - 1] == 'c') |
| 375 | return 2 + addendum; | 375 | return 2 + addendum; |
| @@ -382,7 +382,7 @@ static unsigned int scan_dev_name_common(const char *d, unsigned int n, int adde | |||
| 382 | return 0; | 382 | return 0; |
| 383 | } | 383 | } |
| 384 | 384 | ||
| 385 | static unsigned int scan_dev_name(const char *d, unsigned int n, char *ptr) | 385 | static unsigned int scan_dev_name(const char *d, unsigned int n, const char *ptr) |
| 386 | { | 386 | { |
| 387 | if (d[0] == 's' && d[1] == 'c' && d[2] == 's' && d[3] == 'i' && d[4] == '/') { | 387 | if (d[0] == 's' && d[1] == 'c' && d[2] == 's' && d[3] == 'i' && d[4] == '/') { |
| 388 | if (d[n - 7] == 'g' && d[n - 6] == 'e' && d[n - 5] == 'n' | 388 | if (d[n - 7] == 'g' && d[n - 6] == 'e' && d[n - 5] == 'n' |
| @@ -926,7 +926,7 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int | |||
| 926 | int ret; | 926 | int ret; |
| 927 | const char *compat_name = NULL; | 927 | const char *compat_name = NULL; |
| 928 | const char *dest_name = info->devname; | 928 | const char *dest_name = info->devname; |
| 929 | char *ptr=NULL; | 929 | const char *ptr; |
| 930 | char compat_buf[STRING_LENGTH], dest_buf[STRING_LENGTH]; | 930 | char compat_buf[STRING_LENGTH], dest_buf[STRING_LENGTH]; |
| 931 | int mode, host, bus, target, lun; | 931 | int mode, host, bus, target, lun; |
| 932 | unsigned int i; | 932 | unsigned int i; |
| @@ -954,7 +954,7 @@ static void action_compat(const struct devfsd_notify_struct *info, unsigned int | |||
| 954 | break; | 954 | break; |
| 955 | case AC_MKNEWCOMPAT: | 955 | case AC_MKNEWCOMPAT: |
| 956 | case AC_RMNEWCOMPAT: | 956 | case AC_RMNEWCOMPAT: |
| 957 | ptr = strrchr(info->devname, '/') + 1; | 957 | ptr = bb_basename(info->devname); |
| 958 | i = scan_dev_name(info->devname, info->namelen, ptr); | 958 | i = scan_dev_name(info->devname, info->namelen, ptr); |
| 959 | 959 | ||
| 960 | /* nothing found */ | 960 | /* nothing found */ |
| @@ -1460,7 +1460,7 @@ const char *get_old_name(const char *devname, unsigned int namelen, | |||
| 1460 | */ | 1460 | */ |
| 1461 | { | 1461 | { |
| 1462 | const char *compat_name = NULL; | 1462 | const char *compat_name = NULL; |
| 1463 | char *ptr; | 1463 | const char *ptr; |
| 1464 | struct translate_struct *trans; | 1464 | struct translate_struct *trans; |
| 1465 | unsigned int i; | 1465 | unsigned int i; |
| 1466 | char mode; | 1466 | char mode; |
| @@ -1497,7 +1497,7 @@ const char *get_old_name(const char *devname, unsigned int namelen, | |||
| 1497 | } | 1497 | } |
| 1498 | } | 1498 | } |
| 1499 | 1499 | ||
| 1500 | ptr = (strrchr(devname, '/') + 1); | 1500 | ptr = bb_basename(devname); |
| 1501 | i = scan_dev_name(devname, namelen, ptr); | 1501 | i = scan_dev_name(devname, namelen, ptr); |
| 1502 | 1502 | ||
| 1503 | if (i > 0 && i < 13) | 1503 | if (i > 0 && i < 13) |
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index dbed4ea0f..3861dd1e3 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
| @@ -376,18 +376,13 @@ static struct dep_t *build_dep(void) | |||
| 376 | 376 | ||
| 377 | if (col) { | 377 | if (col) { |
| 378 | /* This line is a dep description */ | 378 | /* This line is a dep description */ |
| 379 | char *mods; | 379 | const char *mods; |
| 380 | char *modpath; | 380 | char *modpath; |
| 381 | char *mod; | 381 | char *mod; |
| 382 | 382 | ||
| 383 | /* Find the beginning of the module file name */ | 383 | /* Find the beginning of the module file name */ |
| 384 | *col = 0; | 384 | *col = 0; |
| 385 | mods = strrchr(buffer, '/'); | 385 | mods = bb_basename(buffer); |
| 386 | |||
| 387 | if (!mods) | ||
| 388 | mods = buffer; /* no path for this module */ | ||
| 389 | else | ||
| 390 | mods++; /* there was a path for this module... */ | ||
| 391 | 386 | ||
| 392 | /* find the path of the module */ | 387 | /* find the path of the module */ |
| 393 | modpath = strchr(buffer, '/'); /* ... and this is the path */ | 388 | modpath = strchr(buffer, '/'); /* ... and this is the path */ |
| @@ -433,7 +428,7 @@ static struct dep_t *build_dep(void) | |||
| 433 | /* p points to the first dependable module; if NULL, no dependable module */ | 428 | /* p points to the first dependable module; if NULL, no dependable module */ |
| 434 | if (p && *p) { | 429 | if (p && *p) { |
| 435 | char *end = &buffer[l-1]; | 430 | char *end = &buffer[l-1]; |
| 436 | char *deps; | 431 | const char *deps; |
| 437 | char *dep; | 432 | char *dep; |
| 438 | char *next; | 433 | char *next; |
| 439 | int ext = 0; | 434 | int ext = 0; |
| @@ -451,15 +446,11 @@ static struct dep_t *build_dep(void) | |||
| 451 | next = end; | 446 | next = end; |
| 452 | 447 | ||
| 453 | /* find the beginning of the module file name */ | 448 | /* find the beginning of the module file name */ |
| 454 | deps = strrchr(p, '/'); | 449 | deps = bb_basename(p); |
| 455 | 450 | if (deps == p) { | |
| 456 | if (!deps || (deps < p)) { | ||
| 457 | deps = p; | ||
| 458 | |||
| 459 | while (isblank(*deps)) | 451 | while (isblank(*deps)) |
| 460 | deps++; | 452 | deps++; |
| 461 | } else | 453 | } |
| 462 | deps++; | ||
| 463 | 454 | ||
| 464 | /* find the end of the module name in the file name */ | 455 | /* find the end of the module name in the file name */ |
| 465 | if (ENABLE_FEATURE_2_6_MODULES | 456 | if (ENABLE_FEATURE_2_6_MODULES |
diff --git a/modutils/rmmod.c b/modutils/rmmod.c index f78f96ccc..13f5ec20b 100644 --- a/modutils/rmmod.c +++ b/modutils/rmmod.c | |||
| @@ -81,12 +81,7 @@ int rmmod_main(int argc, char **argv) | |||
| 81 | 81 | ||
| 82 | for (n = optind; n < argc; n++) { | 82 | for (n = optind; n < argc; n++) { |
| 83 | if (ENABLE_FEATURE_2_6_MODULES) { | 83 | if (ENABLE_FEATURE_2_6_MODULES) { |
| 84 | const char *afterslash; | 84 | filename2modname(misc_buf, bb_basename(argv[n])); |
| 85 | |||
| 86 | afterslash = strrchr(argv[n], '/'); | ||
| 87 | if (!afterslash) afterslash = argv[n]; | ||
| 88 | else afterslash++; | ||
| 89 | filename2modname(misc_buf, afterslash); | ||
| 90 | } | 85 | } |
| 91 | 86 | ||
| 92 | if (syscall(__NR_delete_module, ENABLE_FEATURE_2_6_MODULES ? misc_buf : argv[n], flags)) { | 87 | if (syscall(__NR_delete_module, ENABLE_FEATURE_2_6_MODULES ? misc_buf : argv[n], flags)) { |
diff --git a/networking/httpd.c b/networking/httpd.c index 383a00635..8c5e29fa8 100644 --- a/networking/httpd.c +++ b/networking/httpd.c | |||
| @@ -1125,7 +1125,7 @@ static int sendCgi(const char *url, | |||
| 1125 | setenv1("HTTP_REFERER", referer); | 1125 | setenv1("HTTP_REFERER", referer); |
| 1126 | 1126 | ||
| 1127 | /* set execve argp[0] without path */ | 1127 | /* set execve argp[0] without path */ |
| 1128 | argp[0] = strrchr(purl, '/') + 1; | 1128 | argp[0] = (char*)bb_basename(purl); |
| 1129 | /* but script argp[0] must have absolute path and chdiring to this */ | 1129 | /* but script argp[0] must have absolute path and chdiring to this */ |
| 1130 | script = strrchr(fullpath, '/'); | 1130 | script = strrchr(fullpath, '/'); |
| 1131 | if (!script) | 1131 | if (!script) |
| @@ -1713,7 +1713,7 @@ static void handleIncoming(void) | |||
| 1713 | if (alarm_signaled) | 1713 | if (alarm_signaled) |
| 1714 | break; | 1714 | break; |
| 1715 | 1715 | ||
| 1716 | if (strcmp(strrchr(url, '/') + 1, httpd_conf) == 0 || ip_allowed == 0) { | 1716 | if (strcmp(bb_basename(url), httpd_conf) == 0 || ip_allowed == 0) { |
| 1717 | /* protect listing [/path]/httpd_conf or IP deny */ | 1717 | /* protect listing [/path]/httpd_conf or IP deny */ |
| 1718 | #if ENABLE_FEATURE_HTTPD_CGI | 1718 | #if ENABLE_FEATURE_HTTPD_CGI |
| 1719 | FORBIDDEN: /* protect listing /cgi-bin */ | 1719 | FORBIDDEN: /* protect listing /cgi-bin */ |
diff --git a/util-linux/mdev.c b/util-linux/mdev.c index 22005aaee..17e5e88c6 100644 --- a/util-linux/mdev.c +++ b/util-linux/mdev.c | |||
| @@ -24,7 +24,7 @@ struct globals { | |||
| 24 | /* mknod in /dev based on a path like "/sys/block/hda/hda1" */ | 24 | /* mknod in /dev based on a path like "/sys/block/hda/hda1" */ |
| 25 | static void make_device(char *path, int delete) | 25 | static void make_device(char *path, int delete) |
| 26 | { | 26 | { |
| 27 | char *device_name; | 27 | const char *device_name; |
| 28 | int major, minor, type, len; | 28 | int major, minor, type, len; |
| 29 | int mode = 0660; | 29 | int mode = 0660; |
| 30 | uid_t uid = 0; | 30 | uid_t uid = 0; |
| @@ -46,7 +46,7 @@ static void make_device(char *path, int delete) | |||
| 46 | 46 | ||
| 47 | /* Determine device name, type, major and minor */ | 47 | /* Determine device name, type, major and minor */ |
| 48 | 48 | ||
| 49 | device_name = strrchr(path, '/') + 1; | 49 | device_name = bb_basename(path); |
| 50 | type = path[5]=='c' ? S_IFCHR : S_IFBLK; | 50 | type = path[5]=='c' ? S_IFCHR : S_IFBLK; |
| 51 | 51 | ||
| 52 | /* If we have a config file, look up permissions for this device */ | 52 | /* If we have a config file, look up permissions for this device */ |
