]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Consistently check strcspn return value (#2166)
authorJoshua Rogers <MegaManSec@users.noreply.github.com>
Sat, 6 Sep 2025 07:04:21 +0000 (07:04 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Sun, 7 Sep 2025 02:29:45 +0000 (14:29 +1200)
src/format/Format.cc
src/format/Token.cc
src/http/Message.cc
src/tools.cc

index 486da88c3293f3d010f7323b905bbbb96dc14990..1dd26e7346d4add019708bc186b2d43c882141a0 100644 (file)
@@ -294,7 +294,7 @@ log_quoted_string(const char *str, char *out)
     char *p = out;
 
     while (*str) {
-        int l = strcspn(str, "\"\\\r\n\t");
+        const auto l = strcspn(str, "\"\\\r\n\t");
         memcpy(p, str, l);
         str += l;
         p += l;
index 3b1da3e5bc4ba6ee3110a5e99e2f0f48620f894d..0b569c2430573755eb83a2b3fcfc0c198f450376 100644 (file)
@@ -354,9 +354,7 @@ Format::Token::parse(const char *def, Quoting *quoting)
 {
     const char *cur = def;
 
-    int l;
-
-    l = strcspn(cur, "%");
+    auto l = strcspn(cur, "%");
 
     if (l > 0) {
         char *cp;
index 7c575eb2496ba3a4f0bcba75bd94850c71ec714f..bd40c89497819ea930882a3e99c2de1c052af163 100644 (file)
@@ -41,7 +41,7 @@ Http::Message::putCc(const HttpHdrCc &otherCc)
 static int
 httpMsgIsolateStart(const char **parse_start, const char **blk_start, const char **blk_end)
 {
-    int slen = strcspn(*parse_start, "\r\n");
+    const auto slen = strcspn(*parse_start, "\r\n");
 
     if (!(*parse_start)[slen])  /* no CRLF found */
         return 0;
index cbc74d05c9ecc588a145f5f2b0588e17a68ff5b1..0b1c73c4f48d1d0629d01228056a62ddab122ffa 100644 (file)
@@ -1087,7 +1087,7 @@ strwordquote(MemBuf * mb, const char *str)
     }
 
     while (*str) {
-        int l = strcspn(str, "\"\\\n\r");
+        const auto l = strcspn(str, "\"\\\n\r");
         mb->append(str, l);
         str += l;