]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
src: use u8_tolower everywhere
authorPhilippe Antoine <contact@catenacyber.fr>
Mon, 28 Feb 2022 07:32:42 +0000 (08:32 +0100)
committerVictor Julien <vjulien@oisf.net>
Wed, 2 Mar 2022 07:17:17 +0000 (08:17 +0100)
Ticket: 4516

Instead of basic to_lower to get the cast to avoid warning
about integer

Sames goes for u8_toupper

13 files changed:
src/counters.c
src/detect-fileext.c
src/detect-ssh-hassh-server.c
src/detect-ssh-hassh.c
src/detect-tls-cert-fingerprint.c
src/detect-tls-cert-serial.c
src/detect-tls-ja3-hash.c
src/detect-tls-ja3s-hash.c
src/feature.c
src/util-classification-config.c
src/util-decode-mime.c
src/util-reference-config.c
src/util-spm.c

index 30602a260d1644c3966529e3905d436eefc2f3ae..810b6c76de250a17c04547bd08d52c42f6f028c3 100644 (file)
@@ -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;
index 2856bfda4c33076c4c7509647240a8693df07868..2ddd55ccc85f210465c53d7e927edbfcff9bf0f1 100644 (file)
@@ -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;
index 6ba9255d2c25c2d5b356d5ff382d7ed85f8d037c..34aaecdb1dfa094ace671f800798d211de6a00b4 100644 (file)
@@ -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]);
             }
         }
 
index c3f3fac702ae84cff335c5143d6e73833d634302..12404e29912ea0e4ebfbce74b4f37621e4e54bd8 100644 (file)
@@ -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]);
             }
         }
 
index 98275454f9b8e4bc50a10d72dfadf7c1ec137771..56e424cb390687938d1ce761c1a57dfec7e2de71 100644 (file)
@@ -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;
             }
         }
index 782dd133bf65cbe7a3fd80b548bb2fe4221e37f3..d7096bdf60eb0a2f4aa37f715eeab865a6c2300f 100644 (file)
@@ -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;
             }
         }
index 52ff3cf9162f950c3fb5c7557eb341481cff07f8..4f15dd661e358bcb93c5410e2b8d73a31555639d 100644 (file)
@@ -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;
             }
         }
index ef2450f4d735454591c973073fd96432c2fb6abf..4c63fff0cc5d570080d8e398b469efb13d8eaa96 100644 (file)
@@ -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;
             }
         }
index 00806b62afae90bfd53d981f0aa9c0edf646642f..a6ea9bc9d32537440e60cb84e7cc94a4d7aa176e 100644 (file)
@@ -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);
 }
index 11866fe629d7404ef8b724595b2072169bb42660..ff4f906ec154a0bbbf9683b6b656af1cebb44fef 100644 (file)
@@ -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 };
index 83e6c6b8f502f67a7b02269ec7b6f414a2cd1339..3acfd21352ebe0b31ac002cebda2186bf49aa4c9 100644 (file)
@@ -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++;
                     }
 
index 4e69742c048b455dc52472a4e7caec0efbc49482..f04f6a0f91cc9a967a37d8a0c9d0d94f6663c10e 100644 (file)
@@ -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;
 
index 1cdbdd6848d655509e26e4fb08de00a18b512cf4..3d2048e6cb24f5d9a81491c044c05174dfb8bceb 100644 (file)
@@ -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);