From: Philippe Antoine Date: Mon, 28 Feb 2022 07:32:42 +0000 (+0100) Subject: src: use u8_tolower everywhere X-Git-Tag: suricata-7.0.0-beta1~840 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eb189e805ad38ed600f280f13bcd5963ac7cf88d;p=thirdparty%2Fsuricata.git src: use u8_tolower everywhere Ticket: 4516 Instead of basic to_lower to get the cast to avoid warning about integer Sames goes for u8_toupper --- diff --git a/src/counters.c b/src/counters.c index 30602a260d..810b6c76de 100644 --- a/src/counters.c +++ b/src/counters.c @@ -1024,7 +1024,7 @@ static uint32_t CountersIdHashFunc(HashTable *ht, void *data, uint16_t datalen) int len = strlen(t->string); for (int i = 0; i < len; i++) - hash += tolower((unsigned char)t->string[i]); + hash += u8_tolower((unsigned char)t->string[i]); hash = hash % ht->array_size; return hash; diff --git a/src/detect-fileext.c b/src/detect-fileext.c index 2856bfda4c..2ddd55ccc8 100644 --- a/src/detect-fileext.c +++ b/src/detect-fileext.c @@ -154,7 +154,7 @@ static DetectFileextData *DetectFileextParse (DetectEngineCtx *de_ctx, const cha } uint16_t u; for (u = 0; u < fileext->len; u++) - fileext->ext[u] = tolower(fileext->ext[u]); + fileext->ext[u] = u8_tolower(fileext->ext[u]); if (negate) { fileext->flags |= DETECT_CONTENT_NEGATED; diff --git a/src/detect-ssh-hassh-server.c b/src/detect-ssh-hassh-server.c index 6ba9255d2c..34aaecdb1d 100644 --- a/src/detect-ssh-hassh-server.c +++ b/src/detect-ssh-hassh-server.c @@ -173,7 +173,7 @@ static void DetectSshHasshServerHashSetupCallback(const DetectEngineCtx *de_ctx, for (u = 0; u < cd->content_len; u++) { if (isupper(cd->content[u])) { - cd->content[u] = tolower(cd->content[u]); + cd->content[u] = u8_tolower(cd->content[u]); } } diff --git a/src/detect-ssh-hassh.c b/src/detect-ssh-hassh.c index c3f3fac702..12404e2991 100644 --- a/src/detect-ssh-hassh.c +++ b/src/detect-ssh-hassh.c @@ -175,7 +175,7 @@ static void DetectSshHasshHashSetupCallback(const DetectEngineCtx *de_ctx, for (u = 0; u < cd->content_len; u++) { if (isupper(cd->content[u])) { - cd->content[u] = tolower(cd->content[u]); + cd->content[u] = u8_tolower(cd->content[u]); } } diff --git a/src/detect-tls-cert-fingerprint.c b/src/detect-tls-cert-fingerprint.c index 98275454f9..56e424cb39 100644 --- a/src/detect-tls-cert-fingerprint.c +++ b/src/detect-tls-cert-fingerprint.c @@ -211,7 +211,7 @@ static void DetectTlsFingerprintSetupCallback(const DetectEngineCtx *de_ctx, for (u = 0; u < cd->content_len; u++) { if (isupper(cd->content[u])) { - cd->content[u] = tolower(cd->content[u]); + cd->content[u] = u8_tolower(cd->content[u]); changed = true; } } diff --git a/src/detect-tls-cert-serial.c b/src/detect-tls-cert-serial.c index 782dd133bf..d7096bdf60 100644 --- a/src/detect-tls-cert-serial.c +++ b/src/detect-tls-cert-serial.c @@ -201,7 +201,7 @@ static void DetectTlsSerialSetupCallback(const DetectEngineCtx *de_ctx, for (u = 0; u < cd->content_len; u++) { if (islower(cd->content[u])) { - cd->content[u] = toupper(cd->content[u]); + cd->content[u] = u8_toupper(cd->content[u]); changed = true; } } diff --git a/src/detect-tls-ja3-hash.c b/src/detect-tls-ja3-hash.c index 52ff3cf916..4f15dd661e 100644 --- a/src/detect-tls-ja3-hash.c +++ b/src/detect-tls-ja3-hash.c @@ -207,7 +207,7 @@ static void DetectTlsJa3HashSetupCallback(const DetectEngineCtx *de_ctx, for (u = 0; u < cd->content_len; u++) { if (isupper(cd->content[u])) { - cd->content[u] = tolower(cd->content[u]); + cd->content[u] = u8_tolower(cd->content[u]); changed = true; } } diff --git a/src/detect-tls-ja3s-hash.c b/src/detect-tls-ja3s-hash.c index ef2450f4d7..4c63fff0cc 100644 --- a/src/detect-tls-ja3s-hash.c +++ b/src/detect-tls-ja3s-hash.c @@ -205,7 +205,7 @@ static void DetectTlsJa3SHashSetupCallback(const DetectEngineCtx *de_ctx, for (u = 0; u < cd->content_len; u++) { if (isupper(cd->content[u])) { - cd->content[u] = tolower(cd->content[u]); + cd->content[u] = u8_tolower(cd->content[u]); changed = true; } } diff --git a/src/feature.c b/src/feature.c index 00806b62af..a6ea9bc9d3 100644 --- a/src/feature.c +++ b/src/feature.c @@ -43,7 +43,7 @@ static uint32_t FeatureHashFunc(HashListTable *ht, void *data, int len = strlen(f->feature); for (int i = 0; i < len; i++) - hash += tolower((unsigned char)f->feature[i]); + hash += u8_tolower((unsigned char)f->feature[i]); return (hash % ht->array_size); } diff --git a/src/util-classification-config.c b/src/util-classification-config.c index 11866fe629..ff4f906ec1 100644 --- a/src/util-classification-config.c +++ b/src/util-classification-config.c @@ -220,7 +220,7 @@ static char *SCClassConfStringToLowercase(const char *str) temp_str = new_str; while (*temp_str != '\0') { - *temp_str = tolower((unsigned char)*temp_str); + *temp_str = u8_tolower((unsigned char)*temp_str); temp_str++; } @@ -453,7 +453,7 @@ uint32_t SCClassConfClasstypeHashFunc(HashTable *ht, void *data, uint16_t datale int len = strlen(ct->classtype); for (i = 0; i < len; i++) - hash += tolower((unsigned char)(ct->classtype)[i]); + hash += u8_tolower((unsigned char)(ct->classtype)[i]); hash = hash % ht->array_size; @@ -560,7 +560,7 @@ SCClassConfClasstype *SCClassConfGetClasstype(const char *ct_name, char name[strlen(ct_name) + 1]; size_t s; for (s = 0; s < strlen(ct_name); s++) - name[s] = tolower((unsigned char)ct_name[s]); + name[s] = u8_tolower((unsigned char)ct_name[s]); name[s] = '\0'; SCClassConfClasstype ct_lookup = {0, 0, name, NULL }; diff --git a/src/util-decode-mime.c b/src/util-decode-mime.c index 83e6c6b8f5..3acfd21352 100644 --- a/src/util-decode-mime.c +++ b/src/util-decode-mime.c @@ -447,7 +447,7 @@ static MimeDecField * MimeDecFillField(MimeDecEntity *entity, uint8_t *name, /* convert to lowercase and store */ uint32_t u; for (u = 0; u < nlen; u++) - name[u] = tolower(name[u]); + name[u] = u8_tolower(name[u]); field->name = (uint8_t *)name; field->name_len = nlen; @@ -1068,7 +1068,7 @@ static int FindUrlStrings(const uint8_t *line, uint32_t len, tempUrlLen = 0; for (i = 0; i < tokLen && tok[i] != 0; i++) { /* url is all lowercase */ - tempUrl[tempUrlLen] = tolower(tok[i]); + tempUrl[tempUrlLen] = u8_tolower(tok[i]); tempUrlLen++; } diff --git a/src/util-reference-config.c b/src/util-reference-config.c index 4e69742c04..f04f6a0f91 100644 --- a/src/util-reference-config.c +++ b/src/util-reference-config.c @@ -211,7 +211,7 @@ static char *SCRConfStringToLowercase(const char *str) temp_str = new_str; while (*temp_str != '\0') { - *temp_str = tolower((unsigned char)*temp_str); + *temp_str = u8_tolower((unsigned char)*temp_str); temp_str++; } @@ -423,7 +423,7 @@ uint32_t SCRConfReferenceHashFunc(HashTable *ht, void *data, uint16_t datalen) int len = strlen(ref->system); for (i = 0; i < len; i++) - hash += tolower((unsigned char)ref->system[i]); + hash += u8_tolower((unsigned char)ref->system[i]); hash = hash % ht->array_size; diff --git a/src/util-spm.c b/src/util-spm.c index 1cdbdd6848..3d2048e6cb 100644 --- a/src/util-spm.c +++ b/src/util-spm.c @@ -2655,7 +2655,7 @@ static int SpmSearchTest02(void) { d.nocase = 1; uint16_t j; for (j = 0; j < haystack_len; j++) { - haystack[j] = toupper(haystack[j]); + haystack[j] = u8_toupper(haystack[j]); } if (SpmTestSearch(&d, matcher) == 0) { printf(" test %" PRIu32 ": fail (case-insensitive)\n", i);