mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-26 14:07:05 +03:00
Fix off-by-one error in search routines which caused crashes with
(invalid) host names ending in a '.'. svn path=/trunk/netsurf/; revision=2618
This commit is contained in:
parent
d44108433e
commit
217e59aebe
@ -2056,13 +2056,13 @@ int urldb_search_match_string(const struct host_part *a,
|
|||||||
return strcasecmp(a->part, b);
|
return strcasecmp(a->part, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
end = b + strlen(b);
|
end = b + strlen(b) + 1;
|
||||||
|
|
||||||
while (b < end && a && a != &db_root) {
|
while (b < end && a && a != &db_root) {
|
||||||
dot = strchr(b, '.');
|
dot = strchr(b, '.');
|
||||||
if (!dot) {
|
if (!dot) {
|
||||||
/* last segment */
|
/* last segment */
|
||||||
dot = end;
|
dot = end - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compare strings (length limited) */
|
/* Compare strings (length limited) */
|
||||||
@ -2119,13 +2119,13 @@ int urldb_search_match_prefix(const struct host_part *a,
|
|||||||
return strncasecmp(a->part, b, strlen(b));
|
return strncasecmp(a->part, b, strlen(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
end = b + strlen(b);
|
end = b + strlen(b) + 1;
|
||||||
|
|
||||||
while (b < end && a && a != &db_root) {
|
while (b < end && a && a != &db_root) {
|
||||||
dot = strchr(b, '.');
|
dot = strchr(b, '.');
|
||||||
if (!dot) {
|
if (!dot) {
|
||||||
/* last segment */
|
/* last segment */
|
||||||
dot = end;
|
dot = end - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compare strings (length limited) */
|
/* Compare strings (length limited) */
|
||||||
@ -2134,7 +2134,7 @@ int urldb_search_match_prefix(const struct host_part *a,
|
|||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* The strings matched */
|
/* The strings matched */
|
||||||
if (dot < end) {
|
if (dot < end - 1) {
|
||||||
/* Consider segment lengths only in the case
|
/* Consider segment lengths only in the case
|
||||||
* where the prefix contains segments */
|
* where the prefix contains segments */
|
||||||
plen = strlen(a->part);
|
plen = strlen(a->part);
|
||||||
|
Loading…
Reference in New Issue
Block a user