if(littlelen > biglen)
return FALSE;
- return (bool)strequal(little, bigone+biglen-littlelen);
+ return (bool)Curl_raw_equal(little, bigone+biglen-littlelen);
}
/*
/* AUTH is missing */
}
- if(strnequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
- strnequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
- strnequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
+ if(Curl_raw_nequal(path, DICT_MATCH, sizeof(DICT_MATCH)-1) ||
+ Curl_raw_nequal(path, DICT_MATCH2, sizeof(DICT_MATCH2)-1) ||
+ Curl_raw_nequal(path, DICT_MATCH3, sizeof(DICT_MATCH3)-1)) {
word = strchr(path, ':');
if(word) {
if(result)
return result;
}
- else if(strnequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
- strnequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
- strnequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
+ else if(Curl_raw_nequal(path, DICT_DEFINE, sizeof(DICT_DEFINE)-1) ||
+ Curl_raw_nequal(path, DICT_DEFINE2, sizeof(DICT_DEFINE2)-1) ||
+ Curl_raw_nequal(path, DICT_DEFINE3, sizeof(DICT_DEFINE3)-1)) {
word = strchr(path, ':');
if(word) {
dlen -= ftpc->file?strlen(ftpc->file):0;
if((dlen == (int)strlen(ftpc->prevpath)) &&
- curl_strnequal(path, ftpc->prevpath, dlen)) {
+ strnequal(path, ftpc->prevpath, dlen)) {
infof(data, "Request has same path as previous transfer\n");
ftpc->cwddone = TRUE;
}
size_t thislen = strlen(thisheader);
for(head = data->set.headers; head; head=head->next) {
- if(strnequal(head->data, thisheader, thislen))
+ if(Curl_raw_nequal(head->data, thisheader, thislen))
return head->data;
}
return NULL;
const char *start;
const char *end;
- if(!strnequal(headerline, header, hlen))
+ if(!Curl_raw_nequal(headerline, header, hlen))
return FALSE; /* doesn't start with header */
/* pass the header */
/* find the content string in the rest of the line */
for(;len>=clen;len--, start++) {
- if(strnequal(start, content, clen))
+ if(Curl_raw_nequal(start, content, clen))
return TRUE; /* match! */
}
if(conn->allocptr.host &&
/* a Host: header was sent already, don't pass on any custom Host:
header as that will produce *two* in the same request! */
- curl_strnequal("Host:", headers->data, 5))
+ checkprefix("Host:", headers->data))
;
else if(conn->data->set.httpreq == HTTPREQ_POST_FORM &&
/* this header (extended by formdata.c) is sent later */
- curl_strnequal("Content-Type:", headers->data,
- strlen("Content-Type:")))
+ checkprefix("Content-Type:", headers->data))
;
else {
CURLcode result = add_bufferf(req_buffer, "%s\r\n", headers->data);
{
int i;
for(i = 0; i < (int)sizeof(level_names)/(int)sizeof(level_names[0]); i++)
- if(curl_strnequal(level_names[i].name, name, strlen(name)))
+ if(checkprefix(name, level_names[i].name))
return level_names[i].level;
return (enum protection_level)-1;
}
/*
* Support some of the "FTP" commands
*/
- if(curl_strnequal(sshc->quote_item->data, "PWD", 3)) {
+ if(curl_strequal("pwd", sshc->quote_item->data)) {
/* output debug output if that is requested */
if(data->set.verbose) {
char tmp[PATH_MAX+1];
/* The last #include file should be: */
#include "memdebug.h"
-static bool safe_strequal(char* str1, char* str2);
-
static bool safe_strequal(char* str1, char* str2)
{
if(str1 && str2)
if(!check->sessionid)
/* not session ID means blank entry */
continue;
- if(curl_strequal(conn->host.name, check->name) &&
+ if(Curl_raw_equal(conn->host.name, check->name) &&
(conn->remote_port == check->remote_port) &&
Curl_ssl_config_matches(&conn->ssl_config, &check->ssl_config)) {
/* yes, we have a session ID! */
return (my_toupper(*first) == my_toupper(*second));
}
+int Curl_raw_nequal(const char *first, const char *second, size_t max)
+{
+ while(*first && *second && max) {
+ if(my_toupper(*first) != my_toupper(*second)) {
+ break;
+ }
+ max--;
+ first++;
+ second++;
+ }
+ if(0 == max)
+ return 1; /* they are equal this far */
+
+ return my_toupper(*first) == my_toupper(*second);
+}
+
#ifndef HAVE_STRLCAT
/*
* The strlcat() function appends the NUL-terminated string src to the end
#define strequal(a,b) curl_strequal(a,b)
#define strnequal(a,b,c) curl_strnequal(a,b,c)
-/* checkprefix() is a shorter version of the above, used when the first
- argument is zero-byte terminated */
-#define checkprefix(a,b) strnequal(a,b,strlen(a))
-
/*
* Curl_raw_equal() is for doing "raw" case insensitive strings. This is meant
* to be locale independent and only compare strings we know are safe for
* The function is capable of comparing a-z case insensitively even for non-ascii.
*/
int Curl_raw_equal(const char *first, const char *second);
+int Curl_raw_nequal(const char *first, const char *second, size_t max);
+
+/* checkprefix() is a shorter version of the above, used when the first
+ argument is zero-byte terminated */
+#define checkprefix(a,b) Curl_raw_nequal(a,b,strlen(a))
#ifndef HAVE_STRLCAT
#define strlcat(x,y,z) Curl_strlcat(x,y,z)
if(!no_proxy)
no_proxy=curl_getenv("NO_PROXY");
- if(!no_proxy || !strequal("*", no_proxy)) {
+ if(!no_proxy || !Curl_raw_equal("*", no_proxy)) {
/* NO_PROXY wasn't specified or it wasn't just an asterisk */
char *nope;