From 350d66fbbd6634c09f146dc7d5bd57e737dfd0fb Mon Sep 17 00:00:00 2001 From: whali3n51 Date: Wed, 18 Sep 2024 22:48:23 +0800 Subject: [PATCH] fix a bug of out-of-bounds reading in the domlsd() function in the ls.c --- src/ls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ls.c b/src/ls.c index 63a74a10..ba7d0db0 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1051,8 +1051,8 @@ void domlsd(const char *base) if (*base != 0 && chdir(base) != 0) { if (*base++ == '-') { - while (!isspace((unsigned char) *base++)); - while (isspace((unsigned char) *base++)); + while (*base!=0 && !isspace((unsigned char) *base++)); + while (*base!=0 && isspace((unsigned char) *base++)); if (*base != 0 && chdir(base) != 0) { addreply_noformat(550, MSG_STAT_FAILURE2); return;