Remove ctype usage

This commit is contained in:
Frank Denis
2026-04-05 21:26:55 +02:00
parent 1573e29bf3
commit 9f181dfc25
+2 -7
View File
@@ -1,5 +1,4 @@
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stddef.h>
@@ -11,11 +10,6 @@
#include "private/common.h"
#include "utils.h"
#ifdef __FreeBSD__
/* gcc on FreeBSD can generate a bogus isspace implementation */
# undef isspace
#endif
/* Derived from original code by CodesInChaos */
char *
sodium_bin2hex(char *const hex, const size_t hex_maxlen,
@@ -497,7 +491,8 @@ sodium_ip2bin(unsigned char bin[16], const char *ip,
zone = memchr(ip, '%', (size_t) (end - ip));
if (zone != NULL) {
for (z = zone + 1; z < end; z++) {
if (*z == '%' || isspace((unsigned char) *z)) {
if (!((*z >= '0' && *z <= '9') || (*z >= 'a' && *z <= 'z') ||
(*z >= 'A' && *z <= 'Z') || *z == '-' || *z == '_' || *z == '.')) {
return -1;
}
}