Ensure that neither the current fetch host nor the referrer is an IP address before attempting to domain match them.

svn path=/trunk/netsurf/; revision=6466
This commit is contained in:
John Mark Bell 2009-02-13 10:49:35 +00:00
parent 7ff747e1e6
commit 79c0981402
1 changed files with 15 additions and 3 deletions

View File

@ -2704,6 +2704,18 @@ bool urldb_set_cookie(const char *header, const char *url,
/* Domain match host names */ /* Domain match host names */
if (strcasecmp(host, rhost) != 0) { if (strcasecmp(host, rhost) != 0) {
const char *hptr;
const char *rptr;
const char *dot;
/* Ensure neither host nor rhost are IP addresses */
if (url_host_is_ip_address(host) ||
url_host_is_ip_address(rhost)) {
/* IP address, so no partial match */
free(rhost);
goto error;
}
/* Not exact match, so try the following: /* Not exact match, so try the following:
* *
* 1) Find the longest common suffix of host and rhost * 1) Find the longest common suffix of host and rhost
@ -2720,9 +2732,9 @@ bool urldb_set_cookie(const char *header, const char *url,
* It does, however, model the real world rather * It does, however, model the real world rather
* more accurately. * more accurately.
*/ */
const char *hptr = host + strlen(host) - 1;
const char *rptr = rhost + strlen(rhost) - 1; hptr = host + strlen(host) - 1;
const char *dot; rptr = rhost + strlen(rhost) - 1;
/* 1 */ /* 1 */
while (hptr >= host && rptr >= rhost) { while (hptr >= host && rptr >= rhost) {