ctype(3) functions need there arguments to be unsigned char

This commit is contained in:
Gerhard Rieger 2022-04-08 10:54:00 +02:00
parent 893d031cc2
commit 5edcb9b308
7 changed files with 11 additions and 8 deletions

View file

@ -37,6 +37,9 @@ Corrections:
or have trailing garbage.
Test: INTEGER_GARBAGE
ctype(3) functions need there arguments to be unsigned char.
Thanks to Taylor R Campbell for sending a patch.
Porting:
OpenSSL, at least 1.1 on Ubuntu, crashed with SIGSEGV under certain
conditions: client connection to server with certificate with empty

View file

@ -357,7 +357,7 @@ void msg2(
syslp = bufp;
*bufp++ = "DINWEF"[level];
#if 0 /* only for debugging socat */
if (handler) bufp[-1] = tolower(bufp[-1]); /* for debugging, low chars indicate messages from signal handlers */
if (handler) bufp[-1] = tolower((unsigned char)bufp[-1]); /* for debugging, low chars indicate messages from signal handlers */
#endif
*bufp++ = ' ';
strncpy(bufp, text, BUFLEN-(bufp-buff)-1);

View file

@ -745,7 +745,7 @@ int xiosetenv(const char *varname, const char *value, int overwrite, const char
progname = diag_get_string('p');
envname[0] = '\0'; strncat(envname, progname, XIO_ENVNAMELEN-1);
l = strlen(envname);
for (i = 0; i < l; ++i) envname[i] = toupper(envname[i]);
for (i = 0; i < l; ++i) envname[i] = toupper((unsigned char)envname[i]);
strncat(envname+l, "_", XIO_ENVNAMELEN-l-1);
l += 1;
strncat(envname+l, varname, XIO_ENVNAMELEN-l-1);
@ -771,7 +771,7 @@ int xiosetenv2(const char *varname, const char *varname2, const char *value,
l += 1;
strncat(envname+l, varname2, XIO_ENVNAMELEN-l-1);
l += strlen(envname+l);
for (i = 0; i < l; ++i) envname[i] = toupper(envname[i]);
for (i = 0; i < l; ++i) envname[i] = toupper((unsigned char)envname[i]);
return _xiosetenv(envname, value, overwrite, sep);
# undef XIO_ENVNAMELEN
}
@ -799,7 +799,7 @@ int xiosetenv3(const char *varname, const char *varname2, const char *varname3,
l += 1;
strncat(envname+l, varname3, XIO_ENVNAMELEN-l-1);
l += strlen(envname+l);
for (i = 0; i < l; ++i) envname[i] = toupper(envname[i]);
for (i = 0; i < l; ++i) envname[i] = toupper((unsigned char)envname[i]);
return _xiosetenv(envname, value, overwrite, sep);
# undef XIO_ENVNAMELEN
}

View file

@ -97,7 +97,7 @@ static size_t sanitize_char(char c, char *o, int style) {
int hn; /* high nibble */
int ln; /* low nibble */
int n; /* written chars */
if (isprint(c)) {
if (isprint((unsigned char)c)) {
*o = c;
return 1;
}

View file

@ -404,7 +404,7 @@ int vsnprintf_r(char *str, size_t size, const char *format, va_list ap) {
do {
fsize = 10*fsize+(c-'0');
c = *format++;
} while (c && isdigit(c));
} while (c && isdigit((unsigned char)c));
break;
}
if (c == '\0') { break; }

View file

@ -1507,7 +1507,7 @@ static int openssl_delete_cert_info(void) {
progname = diag_get_string('p');
envprefix[0] = '\0'; strncat(envprefix, progname, XIO_ENVNAMELEN-1);
l = strlen(envprefix);
for (i = 0; i < l; ++i) envprefix[i] = toupper(envprefix[i]);
for (i = 0; i < l; ++i) envprefix[i] = toupper((unsigned char)envprefix[i]);
strncat(envprefix+l, "_OPENSSL_", XIO_ENVNAMELEN-l-1);
#if HAVE_VAR_ENVIRON

View file

@ -1524,7 +1524,7 @@ int retropt_socket_pf(struct opt *opts, int *pf) {
char *pfname;
if (retropt_string(opts, OPT_PROTOCOL_FAMILY, &pfname) >= 0) {
if (isdigit(pfname[0])) {
if (isdigit((unsigned char)pfname[0])) {
*pf = strtoul(pfname, NULL /*!*/, 0);
#if WITH_IP4
} else if (!strcasecmp("inet", pfname) ||