From aa5d024b25446d4be10bbe17948c7039a6e74334 Mon Sep 17 00:00:00 2001 From: TNE Date: Thu, 25 Mar 2021 10:25:31 +0100 Subject: [PATCH] Apply diff from #31 --- src/legacy_http.c | 16 ++++++++-------- src/zsclient.cpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/legacy_http.c b/src/legacy_http.c index fb215fb..019665d 100644 --- a/src/legacy_http.c +++ b/src/legacy_http.c @@ -74,8 +74,8 @@ struct http_file } handle; char *buffer; - size_t buffer_len; - size_t buffer_pos; + off_t buffer_len; + off_t buffer_pos; int still_running; }; @@ -340,9 +340,9 @@ static int fill_buffer(HTTP_FILE *file, size_t want, CURLM* multi_handle) * * Removes `want` bytes from the front of the buffer. */ -static int use_buffer(HTTP_FILE *file, int want) +static off_t use_buffer(HTTP_FILE *file, int want) { - if((file->buffer_pos - want) <= 0){ + if(file->buffer_pos <= want){ /* trash the buffer */ if(file->buffer){ free(file->buffer); @@ -365,7 +365,7 @@ static int use_buffer(HTTP_FILE *file, int want) */ size_t http_fread(void *ptr, size_t size, size_t nmemb, HTTP_FILE *file, struct range_fetch *rf) { - size_t want; + off_t want; want = nmemb * size; fill_buffer(file, want, rf->multi_handle); @@ -509,7 +509,7 @@ static void buflwr(char *s) { int range_fetch_read_http_headers(struct range_fetch *rf) { char buf[512]; int status; - int seen_location = 0; + uint seen_location = 0; { /* read status line */ char *p; @@ -571,7 +571,7 @@ int range_fetch_read_http_headers(struct range_fetch *rf) { p += 2; buflwr(buf); { /* Remove the trailing \r\n from the value */ - int len = strcspn(p, "\r\n"); + uint len = strcspn(p, "\r\n"); p[len] = 0; } /* buf is the header name (lower-cased), p the value */ @@ -580,7 +580,7 @@ int range_fetch_read_http_headers(struct range_fetch *rf) { if (status == 206 && !strcmp(buf, "content-range")) { /* Okay, we're getting a non-MIME block from the remote. Get the * range and set our state appropriately */ - int from, to; + off_t from, to; sscanf(p, "bytes " OFF_T_PF "-" OFF_T_PF "/", &from, &to); if (from <= to) { rf->block_left = to + 1 - from; diff --git a/src/zsclient.cpp b/src/zsclient.cpp index 6c75a37..272c2ac 100644 --- a/src/zsclient.cpp +++ b/src/zsclient.cpp @@ -275,8 +275,8 @@ namespace zsync2 { // if interested in headers only, download 1 kiB chunks until end of zsync header is found if (headersOnly && zSyncFileStoredLocallyAlready) { - static const auto chunkSize = 1024; - unsigned long currentChunk = 0; + static const off_t chunkSize = 1024; + off_t currentChunk = 0; // download a chunk at a time while (true) {