From: MAntoniak <47522782+MAntoniak@users.noreply.github.com> Date: Sun, 20 Feb 2022 14:16:07 +0000 (+0100) Subject: checkprefix: remove strlen calls X-Git-Tag: curl-7_82_0~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fff7feb826fd912dd59e582b6e5f175e9bf4ba5;p=thirdparty%2Fcurl.git checkprefix: remove strlen calls Closes #8481 --- diff --git a/lib/strcase.h b/lib/strcase.h index bbd6cd85dd..b628656b97 100644 --- a/lib/strcase.h +++ b/lib/strcase.h @@ -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); diff --git a/lib/tftp.c b/lib/tftp.c index d2d8025654..7f2c88b71e 100644 --- a/lib/tftp.c +++ b/lib/tftp.c @@ -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);