diff options
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/shell/hush.c b/shell/hush.c index 40bcafdd9..e6fa3d9a5 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -942,21 +942,11 @@ static int builtin_pwd(char **argv ATTRIBUTE_UNUSED) | |||
942 | /* built-in 'read VAR' handler */ | 942 | /* built-in 'read VAR' handler */ |
943 | static int builtin_read(char **argv) | 943 | static int builtin_read(char **argv) |
944 | { | 944 | { |
945 | char string[BUFSIZ]; | 945 | char *string; |
946 | char *p; | ||
947 | const char *name = argv[1] ? argv[1] : "REPLY"; | 946 | const char *name = argv[1] ? argv[1] : "REPLY"; |
948 | int name_len = strlen(name); | ||
949 | 947 | ||
950 | if (name_len >= sizeof(string) - 2) | 948 | string = xmalloc_reads(STDIN_FILENO, xasprintf("%s=", name)); |
951 | return EXIT_FAILURE; | 949 | return set_local_var(string, 0); |
952 | strcpy(string, name); | ||
953 | p = string + name_len; | ||
954 | *p++ = '='; | ||
955 | *p = '\0'; /* In case stdin has only EOF */ | ||
956 | /* read string. name_len+1 chars are already used by 'name=' */ | ||
957 | fgets(p, sizeof(string) - 1 - name_len, stdin); | ||
958 | chomp(p); | ||
959 | return set_local_var(xstrdup(string), 0); | ||
960 | } | 950 | } |
961 | 951 | ||
962 | /* built-in 'set [VAR=value]' handler */ | 952 | /* built-in 'set [VAR=value]' handler */ |