aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcorvid <corvid@lavabit.com>2009-02-01 14:45:45 -0300
committercorvid <corvid@lavabit.com>2009-02-01 14:45:45 -0300
commit0f8d3658489e2d68f8624df8465cbbc69fdf2327 (patch)
tree0b2c5312f80bff1a3b287e8b5a2b0e312f3257fa /src
parent465a0dd21ef1f06c18c5b29b4e704d20c0d09c63 (diff)
Fixed a SEGFAULT bug on redirections without Location
Diffstat (limited to 'src')
-rw-r--r--src/cache.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/cache.c b/src/cache.c
index f1d4cbf5..8d01c40e 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -642,7 +642,6 @@ static void Cache_parse_header(CacheEntry_t *entry)
#ifndef DISABLE_COOKIES
Dlist *Cookies;
#endif
- DilloUrl *location_url;
Dlist *warnings;
void *data;
int i;
@@ -660,26 +659,28 @@ static void Cache_parse_header(CacheEntry_t *entry)
}
if (header[9] == '3' && header[10] == '0') {
/* 30x: URL redirection */
- entry->Flags |= CA_Redirect;
- if (header[11] == '1')
- entry->Flags |= CA_ForceRedirect; /* 301 Moved Permanently */
- else if (header[11] == '2')
- entry->Flags |= CA_TempRedirect; /* 302 Temporary Redirect */
+ if ((location_str = Cache_parse_field(header, "Location"))) {
+ DilloUrl *location_url;
+
+ entry->Flags |= CA_Redirect;
+ if (header[11] == '1')
+ entry->Flags |= CA_ForceRedirect; /* 301 Moved Permanently */
+ else if (header[11] == '2')
+ entry->Flags |= CA_TempRedirect; /* 302 Temporary Redirect */
- location_str = Cache_parse_field(header, "Location");
- location_url = a_Url_new(location_str, URL_STR_(entry->Url));
- if (URL_FLAGS(location_url) & (URL_Post + URL_Get) &&
- dStrcasecmp(URL_SCHEME(location_url), "dpi") == 0 &&
- dStrcasecmp(URL_SCHEME(entry->Url), "dpi") != 0) {
- /* Forbid dpi GET and POST from non dpi-generated urls */
- MSG("Redirection Denied! '%s' -> '%s'\n",
- URL_STR(entry->Url), URL_STR(location_url));
- a_Url_free(location_url);
- } else {
- entry->Location = location_url;
+ location_url = a_Url_new(location_str, URL_STR_(entry->Url));
+ if (URL_FLAGS(location_url) & (URL_Post + URL_Get) &&
+ dStrcasecmp(URL_SCHEME(location_url), "dpi") == 0 &&
+ dStrcasecmp(URL_SCHEME(entry->Url), "dpi") != 0) {
+ /* Forbid dpi GET and POST from non dpi-generated urls */
+ MSG("Redirection Denied! '%s' -> '%s'\n",
+ URL_STR(entry->Url), URL_STR(location_url));
+ a_Url_free(location_url);
+ } else {
+ entry->Location = location_url;
+ }
+ dFree(location_str);
}
- dFree(location_str);
-
} else if (strncmp(header + 9, "401", 3) == 0) {
entry->Auth =
Cache_parse_multiple_fields(header, "WWW-Authenticate");