From 24b5a81456ab0baedc0d1e9941f33e502e83b6a5 Mon Sep 17 00:00:00 2001 From: Michael Santos Date: Thu, 22 Jun 2023 07:15:51 -0400 Subject: [PATCH] Replace ctype usage The ctype functions are error prone. The argument is an int which must be in the range of an unsigned char and is interpreted based on the locale: These functions check whether c, which must have the value of an unsigned char or EOF, falls into a certain character class according to the specified locale. The functions without the "_l" suffix perform the check based on the current locale. --- src/xmppipe.h | 3 +-- src/xmppipe_fmt.c | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xmppipe.h b/src/xmppipe.h index e88079b..10c5120 100644 --- a/src/xmppipe.h +++ b/src/xmppipe.h @@ -12,7 +12,6 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include #include #include #include @@ -27,7 +26,7 @@ #include "strtonum.h" #endif -#define XMPPIPE_VERSION "0.14.8" +#define XMPPIPE_VERSION "0.14.9" #define XMPPIPE_RESOURCE "xmppipe" #define XMPPIPE_STREQ(a, b) (strcmp((a), (b)) == 0) diff --git a/src/xmppipe_fmt.c b/src/xmppipe_fmt.c index 4b4bf4a..a1b250e 100644 --- a/src/xmppipe_fmt.c +++ b/src/xmppipe_fmt.c @@ -21,8 +21,9 @@ int xmppipe_fmt_init(void) { int i = 0; for (i = 0; i < 256; i++) - rfc3986[i] = isalnum(i) || i == '~' || i == '-' || i == '.' || i == '_' || - i == '@' || i == '/' + rfc3986[i] = (i >= '0' && i <= '9') || (i >= 'a' && i <= 'z') || + (i >= 'A' && i <= 'Z') || i == '~' || i == '-' || + i == '.' || i == '_' || i == '@' || i == '/' ? i : 0;