summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
Diffstat (limited to 'methods')
-rw-r--r--methods/gpgv.cc12
-rw-r--r--methods/http.cc14
-rw-r--r--methods/https.cc23
-rw-r--r--methods/rred.cc7
4 files changed, 47 insertions, 9 deletions
diff --git a/methods/gpgv.cc b/methods/gpgv.cc
index 2b2aba017..25ba0d063 100644
--- a/methods/gpgv.cc
+++ b/methods/gpgv.cc
@@ -98,8 +98,16 @@ string GPGVMethod::VerifyGetSigners(const char *file, const char *outfile,
// Read a line. Sigh.
while ((c = getc(pipein)) != EOF && c != '\n')
{
- if (bufferoff == buffersize)
- buffer = (char *) realloc(buffer, buffersize *= 2);
+ if (bufferoff == buffersize)
+ {
+ char* newBuffer = (char *) realloc(buffer, buffersize *= 2);
+ if (newBuffer == NULL)
+ {
+ free(buffer);
+ return "Couldn't allocate a buffer big enough for reading";
+ }
+ buffer = newBuffer;
+ }
*(buffer+bufferoff) = c;
bufferoff++;
}
diff --git a/methods/http.cc b/methods/http.cc
index b8ed43cd2..2721b1224 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -716,7 +716,19 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out)
}
}
-
+ // If we ask for uncompressed files servers might respond with content-
+ // negotation which lets us end up with compressed files we do not support,
+ // see 657029, 657560 and co, so if we have no extension on the request
+ // ask for text only. As a sidenote: If there is nothing to negotate servers
+ // seem to be nice and ignore it.
+ if (_config->FindB("Acquire::http::SendAccept", true) == true)
+ {
+ size_t const filepos = Itm->Uri.find_last_of('/');
+ string const file = Itm->Uri.substr(filepos + 1);
+ if (flExtension(file) == file)
+ strcat(Buf,"Accept: text/*\r\n");
+ }
+
string Req = Buf;
// Check for a partial file
diff --git a/methods/https.cc b/methods/https.cc
index 317c8a587..4f2d581d2 100644
--- a/methods/https.cc
+++ b/methods/https.cc
@@ -100,7 +100,6 @@ void HttpsMethod::SetupProxy() /*{{{*/
depth. */
bool HttpsMethod::Fetch(FetchItem *Itm)
{
- stringstream ss;
struct stat SBuf;
struct curl_slist *headers=NULL;
char curl_errorstr[CURL_ERROR_SIZE];
@@ -199,6 +198,7 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
if (_config->FindB("Acquire::https::No-Store",
_config->FindB("Acquire::http::No-Store",false)) == true)
headers = curl_slist_append(headers,"Cache-Control: no-store");
+ stringstream ss;
ioprintf(ss, "Cache-Control: max-age=%u", _config->FindI("Acquire::https::Max-Age",
_config->FindI("Acquire::http::Max-Age",0)));
headers = curl_slist_append(headers, ss.str().c_str());
@@ -242,15 +242,28 @@ bool HttpsMethod::Fetch(FetchItem *Itm)
// error handling
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_errorstr);
+ // If we ask for uncompressed files servers might respond with content-
+ // negotation which lets us end up with compressed files we do not support,
+ // see 657029, 657560 and co, so if we have no extension on the request
+ // ask for text only. As a sidenote: If there is nothing to negotate servers
+ // seem to be nice and ignore it.
+ if (_config->FindB("Acquire::https::SendAccept", _config->FindB("Acquire::http::SendAccept", true)) == true)
+ {
+ size_t const filepos = Itm->Uri.find_last_of('/');
+ string const file = Itm->Uri.substr(filepos + 1);
+ if (flExtension(file) == file)
+ headers = curl_slist_append(headers, "Accept: text/*");
+ }
+
// if we have the file send an if-range query with a range header
if (stat(Itm->DestFile.c_str(),&SBuf) >= 0 && SBuf.st_size > 0)
{
char Buf[1000];
- sprintf(Buf,"Range: bytes=%li-\r\nIf-Range: %s\r\n",
- (long)SBuf.st_size - 1,
- TimeRFC1123(SBuf.st_mtime).c_str());
+ sprintf(Buf, "Range: bytes=%li-", (long) SBuf.st_size - 1);
headers = curl_slist_append(headers, Buf);
- }
+ sprintf(Buf, "If-Range: %s", TimeRFC1123(SBuf.st_mtime).c_str());
+ headers = curl_slist_append(headers, Buf);
+ }
else if(Itm->LastModified > 0)
{
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
diff --git a/methods/rred.cc b/methods/rred.cc
index e37a12ed9..1e352d0e7 100644
--- a/methods/rred.cc
+++ b/methods/rred.cc
@@ -333,7 +333,12 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/
}
if(command_count == command_alloc) {
command_alloc = (command_alloc + 64) * 3 / 2;
- commands = (EdCommand*) realloc(commands, command_alloc * sizeof(EdCommand));
+ EdCommand* newCommands = (EdCommand*) realloc(commands, command_alloc * sizeof(EdCommand));
+ if (newCommands == NULL) {
+ free(commands);
+ return MMAP_FAILED;
+ }
+ commands = newCommands;
}
commands[command_count++] = cmd;
}