mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-06 12:20:07 +00:00
BUG/MINOR: chunk: Fix function chunk_strcmp and chunk_strcasecmp match a substring.
They could match different strings as equal if the chunk was shorter than the string. Those functions are currently only used for SSL's certificate DN entry extract.
This commit is contained in:
parent
afb768340c
commit
78bd4038d7
@ -207,8 +207,10 @@ int chunk_strcmp(const struct chunk *chk, const char *str)
|
||||
int diff = 0;
|
||||
|
||||
do {
|
||||
if (--len < 0)
|
||||
if (--len < 0) {
|
||||
diff = (unsigned char)0 - (unsigned char)*str;
|
||||
break;
|
||||
}
|
||||
diff = (unsigned char)*(s1++) - (unsigned char)*(str++);
|
||||
} while (!diff);
|
||||
return diff;
|
||||
@ -225,8 +227,10 @@ int chunk_strcasecmp(const struct chunk *chk, const char *str)
|
||||
int diff = 0;
|
||||
|
||||
do {
|
||||
if (--len < 0)
|
||||
if (--len < 0) {
|
||||
diff = (unsigned char)0 - (unsigned char)*str;
|
||||
break;
|
||||
}
|
||||
diff = (unsigned char)*s1 - (unsigned char)*str;
|
||||
if (unlikely(diff)) {
|
||||
unsigned int l = (unsigned char)*s1;
|
||||
|
Loading…
Reference in New Issue
Block a user