Skip to content

Commit 2920814

Browse files
committed
Fix afl crash when line finish with \0
1 parent d1ca3d4 commit 2920814

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/shell.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ int shell_loop(env_t *env, int is_a_tty, history_t *history)
6262
check_basic_error(buffer);
6363
continue;
6464
}
65-
if (buffer[buffer_len - 1] == '\n')
66-
buffer[buffer_len - 1] = '\0';
65+
buffer[buffer_len - 1] = '\0';
6766
U_DEBUG("Buffer [%lu] [%s]\n", buffer_len, buffer);
6867
visitor(buffer, env, history);
6968
}

src/tokeniser.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ token_t get_next_token(ast_ctx_t *ctx)
5050
char *start;
5151
int found_token = 0;
5252

53-
while (isblank(*ctx->str))
53+
while (*ctx->str != '\0' && isblank(*ctx->str))
5454
ctx->str++;
5555
for (size_t i = 0; i < TOKENS_LIST_SZ; i++) {
5656
if (u_strncmp(ctx->str, TOKENS_LIST[i].str, TOKENS_LIST[i].sz) == 0) {

0 commit comments

Comments
 (0)