nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 30bafc70ccb2c8f154135a65e7519680d601d2f2
parent b38f0cbaf42206e47b04fbd0d19b7b4b9c684750
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Mon, 24 May 2021 11:00:29 +0200

tweaks: prevent two more size_t subtractions from going negative

This fully fixes https://savannah.gnu.org/bugs/?60658.

Found by compiling with -fsanitize=undefined.

Diffstat:
Msrc/chars.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/chars.c b/src/chars.c @@ -498,7 +498,7 @@ char *revstrstr(const char *haystack, const char *needle, size_t tail_len = strlen(pointer); if (tail_len < needle_len) - pointer += tail_len - needle_len; + pointer -= (needle_len - tail_len); while (pointer >= haystack) { if (strncmp(pointer, needle, needle_len) == 0) @@ -518,7 +518,7 @@ char *revstrcasestr(const char *haystack, const char *needle, size_t tail_len = strlen(pointer); if (tail_len < needle_len) - pointer += tail_len - needle_len; + pointer -= (needle_len - tail_len); while (pointer >= haystack) { if (strncasecmp(pointer, needle, needle_len) == 0)