From a7cabf16c6c579586b3b490556857dfdcda89ae5 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Sun, 16 Dec 2018 01:11:58 +0000 Subject: [PATCH] Convert char to unsigned char before using islower/toupper. Failure to do so is undefined behaviour for any negative char values. --- src/microcode/findprim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/microcode/findprim.c b/src/microcode/findprim.c index f85f5e232..93eb3c162 100644 --- a/src/microcode/findprim.c +++ b/src/microcode/findprim.c @@ -1206,8 +1206,8 @@ strcmp_ci (const char * s1, const char * s2) while ((length--) > 0) { - int c1 = (*s1++); - int c2 = (*s2++); + int c1 = ((unsigned char) (*s1++)); + int c2 = ((unsigned char) (*s2++)); if (islower (c1)) c1 = (toupper (c1)); if (islower (c2)) c2 = (toupper (c2)); if (c1 < c2) return (-1); -- 2.25.1