diff options
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r-- | libbb/lineedit.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 720a4951e..249b401b4 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -672,23 +672,20 @@ static char *username_path_completion(char *ud) | |||
672 | */ | 672 | */ |
673 | static NOINLINE unsigned complete_username(const char *ud) | 673 | static NOINLINE unsigned complete_username(const char *ud) |
674 | { | 674 | { |
675 | /* Using _r function to avoid pulling in static buffers */ | 675 | struct passwd *pw; |
676 | char line_buff[256]; | ||
677 | struct passwd pwd; | ||
678 | struct passwd *result; | ||
679 | unsigned userlen; | 676 | unsigned userlen; |
680 | 677 | ||
681 | ud++; /* skip ~ */ | 678 | ud++; /* skip ~ */ |
682 | userlen = strlen(ud); | 679 | userlen = strlen(ud); |
683 | 680 | ||
684 | setpwent(); | 681 | setpwent(); |
685 | while (!getpwent_r(&pwd, line_buff, sizeof(line_buff), &result)) { | 682 | while ((pw = getpwent()) != NULL) { |
686 | /* Null usernames should result in all users as possible completions. */ | 683 | /* Null usernames should result in all users as possible completions. */ |
687 | if (/*!userlen || */ strncmp(ud, pwd.pw_name, userlen) == 0) { | 684 | if (/*!userlen || */ strncmp(ud, pw->pw_name, userlen) == 0) { |
688 | add_match(xasprintf("~%s/", pwd.pw_name)); | 685 | add_match(xasprintf("~%s/", pw->pw_name)); |
689 | } | 686 | } |
690 | } | 687 | } |
691 | endpwent(); | 688 | endpwent(); /* don't keep password file open */ |
692 | 689 | ||
693 | return 1 + userlen; | 690 | return 1 + userlen; |
694 | } | 691 | } |