summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/compat.c16
-rw-r--r--common/compat.h3
-rw-r--r--common/mock.c4
-rw-r--r--common/url.c4
-rw-r--r--trust/extract-jks.c2
-rw-r--r--trust/extract-openssl.c2
6 files changed, 25 insertions, 6 deletions
diff --git a/common/compat.c b/common/compat.c
index 1e17230..2e559c7 100644
--- a/common/compat.c
+++ b/common/compat.c
@@ -953,3 +953,19 @@ fdwalk (int (* cb) (void *data, int fd),
#endif /* HAVE_FDWALK */
#endif /* OS_UNIX */
+
+int
+p11_ascii_tolower (int c)
+{
+ if (c >= 'A' && c <= 'Z')
+ return 'a' + (c - 'A');
+ return c;
+}
+
+int
+p11_ascii_toupper (int c)
+{
+ if (c >= 'a' && c <= 'z')
+ return 'A' + (c - 'a');
+ return c;
+}
diff --git a/common/compat.h b/common/compat.h
index a9d2fe1..96a731d 100644
--- a/common/compat.h
+++ b/common/compat.h
@@ -340,4 +340,7 @@ int fdwalk (int (* cb) (void *data, int fd),
#endif
+int p11_ascii_tolower (int c);
+int p11_ascii_toupper (int c);
+
#endif /* __COMPAT_H__ */
diff --git a/common/mock.c b/common/mock.c
index 8bd617d..d3c015f 100644
--- a/common/mock.c
+++ b/common/mock.c
@@ -2024,7 +2024,7 @@ mock_C_EncryptUpdate (CK_SESSION_HANDLE session,
}
for (i = 0; i < part_len; ++i)
- encrypted_part[i] = toupper (part[i]);
+ encrypted_part[i] = p11_ascii_toupper (part[i]);
*encrypted_part_len = part_len;
return CKR_OK;
}
@@ -2220,7 +2220,7 @@ mock_C_DecryptUpdate (CK_SESSION_HANDLE session,
}
for (i = 0; i < encrypted_part_len; ++i)
- part[i] = tolower (encrypted_part[i]);
+ part[i] = p11_ascii_tolower (encrypted_part[i]);
*part_len = encrypted_part_len;
return CKR_OK;
}
diff --git a/common/url.c b/common/url.c
index 884c584..344d971 100644
--- a/common/url.c
+++ b/common/url.c
@@ -75,8 +75,8 @@ p11_url_decode (const char *value,
free (result);
return NULL;
}
- a = strchr (HEX_CHARS, tolower (value[0]));
- b = strchr (HEX_CHARS, tolower (value[1]));
+ a = strchr (HEX_CHARS, p11_ascii_tolower (value[0]));
+ b = strchr (HEX_CHARS, p11_ascii_tolower (value[1]));
if (!a || !b) {
free (result);
return NULL;
diff --git a/trust/extract-jks.c b/trust/extract-jks.c
index 1ba37c1..e1f1340 100644
--- a/trust/extract-jks.c
+++ b/trust/extract-jks.c
@@ -159,7 +159,7 @@ convert_alias (const char *input,
for (i = 0; i < length; i++) {
ch = input[i];
if (!isspace (ch) && (ch & 0x80) == 0) {
- ch = tolower (ch);
+ ch = p11_ascii_tolower (ch);
p11_buffer_add (buf, &ch, 1);
}
}
diff --git a/trust/extract-openssl.c b/trust/extract-openssl.c
index 5f72076..0a56d3f 100644
--- a/trust/extract-openssl.c
+++ b/trust/extract-openssl.c
@@ -395,7 +395,7 @@ p11_openssl_canon_string (char *str,
/* If there has been a space, then add one */
if (sp)
*out++ = ' ';
- *out++ = (*in & 0x80) ? *in : tolower (*in);
+ *out++ = (*in & 0x80) ? *in : p11_ascii_tolower (*in);
sp = false;
nsp = true;
/* If there has been a non-space, then note we should get one */