aboutsummaryrefslogtreecommitdiff
path: root/miscutils/bc.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2019-01-01 02:19:02 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2019-01-01 02:19:02 +0100
commit51b510a480b99d480bcf6919b8bae16eb1c61718 (patch)
tree3f6832a1c7ffe27449125e5f7d843ff6313bac24 /miscutils/bc.c
parent8797adc1c6e84789c261ee24afe5a1cbfaddba6b (diff)
downloadbusybox-w32-51b510a480b99d480bcf6919b8bae16eb1c61718.tar.gz
busybox-w32-51b510a480b99d480bcf6919b8bae16eb1c61718.tar.bz2
busybox-w32-51b510a480b99d480bcf6919b8bae16eb1c61718.zip
bc: in xc_read_line(), check ^C on NUL input bytes too
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/bc.c')
-rw-r--r--miscutils/bc.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/miscutils/bc.c b/miscutils/bc.c
index febf51cfd..23b3521d4 100644
--- a/miscutils/bc.c
+++ b/miscutils/bc.c
@@ -2509,7 +2509,7 @@ static void xc_read_line(BcVec *vec, FILE *fp)
2509 i = 0; 2509 i = 0;
2510 for (;;) { 2510 for (;;) {
2511 char c = line_buf[i++]; 2511 char c = line_buf[i++];
2512 if (!c) break; 2512 if (c == '\0') break;
2513 if (bad_input_byte(c)) goto again; 2513 if (bad_input_byte(c)) goto again;
2514 } 2514 }
2515 bc_vec_string(vec, n, line_buf); 2515 bc_vec_string(vec, n, line_buf);
@@ -2522,14 +2522,16 @@ static void xc_read_line(BcVec *vec, FILE *fp)
2522 bool bad_chars = 0; 2522 bool bad_chars = 0;
2523 2523
2524 do { 2524 do {
2525 get_char:
2525#if ENABLE_FEATURE_BC_INTERACTIVE 2526#if ENABLE_FEATURE_BC_INTERACTIVE
2526 if (G_interrupt) { 2527 if (G_interrupt) {
2527 // ^C was pressed: ignore entire line, get another one 2528 // ^C was pressed: ignore entire line, get another one
2528 bc_vec_pop_all(vec); 2529 goto again;
2529 goto intr;
2530 } 2530 }
2531#endif 2531#endif
2532 do c = fgetc(fp); while (c == '\0'); 2532 c = fgetc(fp);
2533 if (c == '\0')
2534 goto get_char;
2533 if (c == EOF) { 2535 if (c == EOF) {
2534 if (ferror(fp)) 2536 if (ferror(fp))
2535 bb_perror_msg_and_die("input error"); 2537 bb_perror_msg_and_die("input error");