summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-02-14 13:02:15 +0100
committerRichard Levitte <levitte@openssl.org>2016-02-14 19:31:55 +0100
commit18295f0c2db084fe00d935d8506d6e964f652d21 (patch)
tree81e661fc1e2052c698b5daee8aae711e574bc0e4 /test
parentef8ca6bd544e4baea67f9a193ae896b8629944d0 (diff)
downloadopenssl-new-18295f0c2db084fe00d935d8506d6e964f652d21.tar.gz
Make sure to use unsigned char for is*() functions
On some platforms, the implementation is such that a signed char triggers a warning when used with is*() functions. On others, the behavior is outright buggy when presented with a char that happens to get promoted to a negative integer. The safest thing is to cast the char that's used to an unsigned char. Reviewed-by: Andy Polyakov <appro@openssl.org>
Diffstat (limited to 'test')
-rw-r--r--test/danetest.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/test/danetest.c b/test/danetest.c
index 01f77313ea..9b7ac1d98d 100644
--- a/test/danetest.c
+++ b/test/danetest.c
@@ -65,6 +65,8 @@
#include "../e_os.h"
+#define _UC(c) ((unsigned char)(c))
+
static const char *progname;
/*
@@ -229,7 +231,7 @@ static char *read_to_eol(FILE *f)
}
/* Trim trailing whitespace */
- while (n > 0 && isspace(buf[n-1]))
+ while (n > 0 && isspace(_UC(buf[n-1])))
buf[--n] = '\0';
return buf;
@@ -252,9 +254,9 @@ static ossl_ssize_t hexdecode(const char *in, void *result)
for (byte = 0; *in; ++in) {
char c;
- if (isspace(*in))
+ if (isspace(_UC(*in)))
continue;
- c = tolower(*in);
+ c = tolower(_UC(*in));
if ('0' <= c && c <= '9') {
byte |= c - '0';
} else if ('a' <= c && c <= 'f') {
@@ -291,11 +293,11 @@ static ossl_ssize_t checked_uint8(const char *in, void *out)
e = restore_errno();
if (((v == LONG_MIN || v == LONG_MAX) && e == ERANGE) ||
- endp == cp || !isspace(*endp) ||
+ endp == cp || !isspace(_UC(*endp)) ||
v != (*(uint8_t *)result = (uint8_t) v)) {
return -1;
}
- for (cp = endp; isspace(*cp); ++cp)
+ for (cp = endp; isspace(_UC(*cp)); ++cp)
continue;
return cp - in;
}
@@ -351,7 +353,7 @@ static int tlsa_import_rr(SSL *ssl, const char *rrdata)
static int allws(const char *cp)
{
while (*cp)
- if (!isspace(*cp++))
+ if (!isspace(_UC(*cp++)))
return 0;
return 1;
}