Introduction
Introduction Statistics Contact Development Disclaimer Help
fix some undefined behaviour with ctype functions - bmf - bmf (Bayesian Mail Fi…
git clone git://git.codemadness.org/bmf
Log
Files
Refs
README
LICENSE
---
commit 20a0f52d5b478e240450fd72fa3bbd3ab5c58c48
parent f368a24da9457e4d269ca281bbc07f0eef08751e
Author: Hiltjo Posthuma <[email protected]>
Date: Thu, 25 Oct 2018 12:41:39 +0200
fix some undefined behaviour with ctype functions
Diffstat:
M lex.c | 31 ++++++++++++++++-------------…
1 file changed, 16 insertions(+), 15 deletions(-)
---
diff --git a/lex.c b/lex.c
@@ -188,19 +188,13 @@ is_whitespace(int c)
}
static inline bool_t
-is_base64char(c)
-{
- return (isalnum(c) || (c == '/' || c == '+'));
-}
-
-static inline bool_t
-is_wordmidchar(c)
+is_wordmidchar(int c)
{
return (isalnum(c) || c == '$' || c == '\'' || c == '.' || c == '-');
}
static inline bool_t
-is_wordendchar(c)
+is_wordendchar(int c)
{
return (isalnum(c) || c == '$');
}
@@ -228,10 +222,11 @@ is_htmltag(cpchar p, uint len, uint * ptoklen)
return false;
}
/* check if is_word() will have a longer match */
- if (is_wordendchar(p[minlen])) {
+ if (is_wordendchar((unsigned char)p[minlen])) {
return false;
}
- if (is_wordmidchar(p[minlen]) && is_wordendchar(p[minlen + 1])) {
+ if (is_wordmidchar((unsigned char)p[minlen]) &&
+ is_wordendchar((unsigned char)p[minlen + 1])) {
return false;
}
*ptoklen = strlen(g_htmltags[hi]);
@@ -256,11 +251,17 @@ is_htmlcomment(cpchar p, uint len, uint * ptoklen)
}
static inline bool_t
+is_base64char(int c)
+{
+ return (isalnum(c) || (c == '/' || c == '+'));
+}
+
+static inline bool_t
is_base64(cpchar p, uint len, uint * ptoklen)
{
*ptoklen = 0;
while (len > 0) {
- if (*p != '\n' && *p != '\r' && !is_base64char(*p)) {
+ if (*p != '\n' && *p != '\r' && !is_base64char((unsigned char)…
return false;
}
p++;
@@ -305,7 +306,7 @@ is_ipaddr(cpchar p, uint len, uint * ptoklen)
noctets = 0;
while (len > 0 && noctets < 4) {
ndigits = 0;
- while (len > 0 && isdigit(*p)) {
+ while (len > 0 && isdigit((unsigned char)*p)) {
ndigits++;
p++;
len--;
@@ -336,21 +337,21 @@ is_word(cpchar p, uint len, uint * ptoklen)
if (len < 3) {
return false;
}
- if (!(isalpha(*p) || *p == '$')) {
+ if (!(isalpha((unsigned char)*p) || *p == '$')) {
return false;
}
*ptoklen = 1;
p++;
len--;
while (len > 0) {
- if (!is_wordmidchar(*p)) {
+ if (!is_wordmidchar((unsigned char)*p)) {
break;
}
(*ptoklen)++;
p++;
len--;
}
- while (*ptoklen >= 3 && !is_wordendchar(*(p - 1))) {
+ while (*ptoklen >= 3 && !is_wordendchar((unsigned char)*(p - 1))) {
(*ptoklen)--;
p--;
len++;
You are viewing proxied material from codemadness.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.