diff options
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/lineedit.c | 19 | ||||
-rw-r--r-- | libbb/procps.c | 2 | ||||
-rw-r--r-- | libbb/xfuncs.c | 12 |
3 files changed, 18 insertions, 15 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index b25386bc0..b05319a9d 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -518,8 +518,8 @@ static void exe_n_cwd_tab_completion(char *command, int type) | |||
518 | 518 | ||
519 | for (i = 0; i < npaths; i++) { | 519 | for (i = 0; i < npaths; i++) { |
520 | dir = opendir(paths[i]); | 520 | dir = opendir(paths[i]); |
521 | if (!dir) /* Don't print an error */ | 521 | if (!dir) |
522 | continue; | 522 | continue; /* don't print an error */ |
523 | 523 | ||
524 | while ((next = readdir(dir)) != NULL) { | 524 | while ((next = readdir(dir)) != NULL) { |
525 | int len1; | 525 | int len1; |
@@ -529,18 +529,21 @@ static void exe_n_cwd_tab_completion(char *command, int type) | |||
529 | if (strncmp(str_found, pfind, strlen(pfind))) | 529 | if (strncmp(str_found, pfind, strlen(pfind))) |
530 | continue; | 530 | continue; |
531 | /* not see .name without .match */ | 531 | /* not see .name without .match */ |
532 | if (*str_found == '.' && *pfind == 0) { | 532 | if (*str_found == '.' && *pfind == '\0') { |
533 | if (NOT_LONE_CHAR(paths[i], '/') || str_found[1]) | 533 | if (NOT_LONE_CHAR(paths[i], '/') || str_found[1]) |
534 | continue; | 534 | continue; |
535 | str_found = ""; /* only "/" */ | 535 | str_found = ""; /* only "/" */ |
536 | } | 536 | } |
537 | found = concat_path_file(paths[i], str_found); | 537 | found = concat_path_file(paths[i], str_found); |
538 | /* hmm, remover in progress? */ | 538 | /* hmm, remove in progress? */ |
539 | if (lstat(found, &st) < 0) | 539 | /* NB: stat() first so that we see is it a directory; |
540 | * but if that fails, use lstat() so that | ||
541 | * we still match dangling links */ | ||
542 | if (stat(found, &st) && lstat(found, &st)) | ||
540 | goto cont; | 543 | goto cont; |
541 | /* find with dirs? */ | 544 | /* find with dirs? */ |
542 | if (paths[i] != dirbuf) | 545 | if (paths[i] != dirbuf) |
543 | strcpy(found, next->d_name); /* only name */ | 546 | strcpy(found, next->d_name); /* only name */ |
544 | 547 | ||
545 | len1 = strlen(found); | 548 | len1 = strlen(found); |
546 | found = xrealloc(found, len1 + 2); | 549 | found = xrealloc(found, len1 + 2); |
@@ -548,7 +551,7 @@ static void exe_n_cwd_tab_completion(char *command, int type) | |||
548 | found[len1+1] = '\0'; | 551 | found[len1+1] = '\0'; |
549 | 552 | ||
550 | if (S_ISDIR(st.st_mode)) { | 553 | if (S_ISDIR(st.st_mode)) { |
551 | /* name is directory */ | 554 | /* name is a directory */ |
552 | if (found[len1-1] != '/') { | 555 | if (found[len1-1] != '/') { |
553 | found[len1] = '/'; | 556 | found[len1] = '/'; |
554 | } | 557 | } |
@@ -566,7 +569,7 @@ static void exe_n_cwd_tab_completion(char *command, int type) | |||
566 | closedir(dir); | 569 | closedir(dir); |
567 | } | 570 | } |
568 | if (paths != path1) { | 571 | if (paths != path1) { |
569 | free(paths[0]); /* allocated memory only in first member */ | 572 | free(paths[0]); /* allocated memory is only in first member */ |
570 | free(paths); | 573 | free(paths); |
571 | } | 574 | } |
572 | #undef dirbuf | 575 | #undef dirbuf |
diff --git a/libbb/procps.c b/libbb/procps.c index f67f7dcde..8946917a2 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -258,7 +258,7 @@ procps_status_t *procps_scan(procps_status_t* sp, int flags) | |||
258 | &sp->start_time, | 258 | &sp->start_time, |
259 | &vsz, | 259 | &vsz, |
260 | &rss); | 260 | &rss); |
261 | if (n != 10) | 261 | if (n != 11) |
262 | break; | 262 | break; |
263 | /* vsz is in bytes and we want kb */ | 263 | /* vsz is in bytes and we want kb */ |
264 | sp->vsz = vsz >> 10; | 264 | sp->vsz = vsz >> 10; |
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c index ca7f94173..84b9f922b 100644 --- a/libbb/xfuncs.c +++ b/libbb/xfuncs.c | |||
@@ -704,7 +704,7 @@ int get_terminal_width_height(int fd, int *width, int *height) | |||
704 | return ret; | 704 | return ret; |
705 | } | 705 | } |
706 | 706 | ||
707 | void ioctl_or_perror_and_die(int fd, int request, void *argp, const char *fmt,...) | 707 | void ioctl_or_perror_and_die(int fd, unsigned request, void *argp, const char *fmt,...) |
708 | { | 708 | { |
709 | va_list p; | 709 | va_list p; |
710 | 710 | ||
@@ -717,7 +717,7 @@ void ioctl_or_perror_and_die(int fd, int request, void *argp, const char *fmt,.. | |||
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | int ioctl_or_perror(int fd, int request, void *argp, const char *fmt,...) | 720 | int ioctl_or_perror(int fd, unsigned request, void *argp, const char *fmt,...) |
721 | { | 721 | { |
722 | va_list p; | 722 | va_list p; |
723 | int ret = ioctl(fd, request, argp); | 723 | int ret = ioctl(fd, request, argp); |
@@ -731,7 +731,7 @@ int ioctl_or_perror(int fd, int request, void *argp, const char *fmt,...) | |||
731 | } | 731 | } |
732 | 732 | ||
733 | #if ENABLE_IOCTL_HEX2STR_ERROR | 733 | #if ENABLE_IOCTL_HEX2STR_ERROR |
734 | int bb_ioctl_or_warn(int fd, int request, void *argp, const char *ioctl_name) | 734 | int bb_ioctl_or_warn(int fd, unsigned request, void *argp, const char *ioctl_name) |
735 | { | 735 | { |
736 | int ret; | 736 | int ret; |
737 | 737 | ||
@@ -740,13 +740,13 @@ int bb_ioctl_or_warn(int fd, int request, void *argp, const char *ioctl_name) | |||
740 | bb_simple_perror_msg(ioctl_name); | 740 | bb_simple_perror_msg(ioctl_name); |
741 | return ret; | 741 | return ret; |
742 | } | 742 | } |
743 | void bb_xioctl(int fd, int request, void *argp, const char *ioctl_name) | 743 | void bb_xioctl(int fd, unsigned request, void *argp, const char *ioctl_name) |
744 | { | 744 | { |
745 | if (ioctl(fd, request, argp) < 0) | 745 | if (ioctl(fd, request, argp) < 0) |
746 | bb_simple_perror_msg_and_die(ioctl_name); | 746 | bb_simple_perror_msg_and_die(ioctl_name); |
747 | } | 747 | } |
748 | #else | 748 | #else |
749 | int bb_ioctl_or_warn(int fd, int request, void *argp) | 749 | int bb_ioctl_or_warn(int fd, unsigned request, void *argp) |
750 | { | 750 | { |
751 | int ret; | 751 | int ret; |
752 | 752 | ||
@@ -755,7 +755,7 @@ int bb_ioctl_or_warn(int fd, int request, void *argp) | |||
755 | bb_perror_msg("ioctl %#x failed", request); | 755 | bb_perror_msg("ioctl %#x failed", request); |
756 | return ret; | 756 | return ret; |
757 | } | 757 | } |
758 | void bb_xioctl(int fd, int request, void *argp) | 758 | void bb_xioctl(int fd, unsigned request, void *argp) |
759 | { | 759 | { |
760 | if (ioctl(fd, request, argp) < 0) | 760 | if (ioctl(fd, request, argp) < 0) |
761 | bb_perror_msg_and_die("ioctl %#x failed", request); | 761 | bb_perror_msg_and_die("ioctl %#x failed", request); |