]> Sergey Matveev's repositories - st.git/commitdiff
avoid potential UB when using isprint()
authorNRK <nrk@disroot.org>
Fri, 18 Mar 2022 10:20:54 +0000 (16:20 +0600)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 18 Mar 2022 11:11:27 +0000 (12:11 +0100)
all the ctype.h functions' argument must be representable as an unsigned
char or as EOF, otherwise the behavior is undefined.

st.c

diff --git a/st.c b/st.c
index c71fa0677ee40d7ba71b5b67fbb70b4386500be8..1307fdf4ab3afee8d16af827b1a04a99152cf1ec 100644 (file)
--- a/st.c
+++ b/st.c
@@ -367,7 +367,7 @@ static const char base64_digits[] = {
 char
 base64dec_getc(const char **src)
 {
-       while (**src && !isprint(**src))
+       while (**src && !isprint((unsigned char)**src))
                (*src)++;
        return **src ? *((*src)++) : '=';  /* emulate padding if string ends */
 }