]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
checkprefix: remove strlen calls
authorMAntoniak <47522782+MAntoniak@users.noreply.github.com>
Sun, 20 Feb 2022 14:16:07 +0000 (15:16 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 21 Feb 2022 07:18:59 +0000 (08:18 +0100)
Closes #8481

lib/strcase.h
lib/tftp.c

index bbd6cd85dd4fb7debd5926526ebf9661f5f80e6b..b628656b977ec1c533d0b9a8428fa05a8520e5ce 100644 (file)
@@ -41,8 +41,8 @@ int Curl_strncasecompare(const char *first, const char *second, size_t max);
 char Curl_raw_toupper(char in);
 
 /* checkprefix() is a shorter version of the above, used when the first
-   argument is zero-byte terminated */
-#define checkprefix(a,b)    curl_strnequal(a,b,strlen(a))
+   argument is the string literal */
+#define checkprefix(a,b)    curl_strnequal(b, STRCONST(a))
 
 void Curl_strntoupper(char *dest, const char *src, size_t n);
 void Curl_strntolower(char *dest, const char *src, size_t n);
index d2d8025654344f8b97bc4967330982bc77ca9477..7f2c88b71e338590ecd940cc898adc470ac51ca8 100644 (file)
@@ -327,7 +327,7 @@ static CURLcode tftp_parse_option_ack(struct tftp_state_data *state,
 
     infof(data, "got option=(%s) value=(%s)", option, value);
 
-    if(checkprefix(option, TFTP_OPTION_BLKSIZE)) {
+    if(checkprefix(TFTP_OPTION_BLKSIZE, option)) {
       long blksize;
 
       blksize = strtol(value, NULL, 10);
@@ -359,7 +359,7 @@ static CURLcode tftp_parse_option_ack(struct tftp_state_data *state,
       infof(data, "%s (%d) %s (%d)", "blksize parsed from OACK",
             state->blksize, "requested", state->requested_blksize);
     }
-    else if(checkprefix(option, TFTP_OPTION_TSIZE)) {
+    else if(checkprefix(TFTP_OPTION_TSIZE, option)) {
       long tsize = 0;
 
       tsize = strtol(value, NULL, 10);