Skip to content

Commit

Permalink
Large-file support for 64-bit systems
Browse files Browse the repository at this point in the history
Apparently, only a few lines have to be changed in order to support
large(r) files on 64-bit machines.

This commit doesn't (yet) fix the issue on 32-bit machines (it also
doesn't test this explicitly). In comparison to AppImageCommunity#59, however, it uses
types that help get this to work on 32-bit machines as well, as it
doesn't use compiler-dependent types, but types that are known to be
large enough even there.

Closes AppImageCommunity#59.

CC AppImageCommunity#31.

(cherry picked from commit a8e2d68)
  • Loading branch information
TheAssassin authored and NiLuJe committed Jan 17, 2024
1 parent 5281a84 commit 283bdb9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/legacy_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ struct http_file
} handle;

char *buffer;
size_t buffer_len;
size_t buffer_pos;
uint64_t buffer_len;
uint64_t buffer_pos;
int still_running;
};

Expand Down Expand Up @@ -348,9 +348,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 int use_buffer(HTTP_FILE *file, uint64_t want)
{
if((file->buffer_pos - want) <= 0){
if(file->buffer_pos <= want){
/* trash the buffer */
if(file->buffer){
free(file->buffer);
Expand Down Expand Up @@ -517,7 +517,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;
uint64_t seen_location = 0;

{ /* read status line */
char *p;
Expand Down Expand Up @@ -588,8 +588,8 @@ 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;
sscanf(p, "bytes " OFF_T_PF "-" OFF_T_PF "/", (intmax_t *) &from, (intmax_t *) &to);
uint64_t from, to;
sscanf(p, "bytes " OFF_T_PF "-" OFF_T_PF "/", &from, &to);
if (from <= to) {
rf->block_left = to + 1 - from;
rf->offset = from;
Expand Down

0 comments on commit 283bdb9

Please sign in to comment.