mirror of
https://github.com/Cesarus85/ringfall-mjolnir-vr.git
synced 2026-10-17 12:00:26 +02:00
Fail a download whose chunk size is not a number
read_body took strtoull's answer for a chunk's size line, and 0, the last chunk's size, is also what it answers for a line that is not a number. A broken or cut response then ended as a complete download, cut short (the update's zip then failed its check, or an update check's JSON failed to parse). A size line without a hexadecimal number is now an error.
This commit is contained in:
1 parent
73dc01d09a
commit
2b89960b0a
1 file changed
+9
-1
@@ -340,11 +340,19 @@ static int read_body(struct connection *connection, struct download *download, i
|
||||
for (;;)
|
||||
{
|
||||
char line[128];
|
||||
char *after;
|
||||
unsigned long long remaining;
|
||||
|
||||
if (!connection_read_line(connection, line, sizeof(line)))
|
||||
return 0;
|
||||
remaining = strtoull(line, NULL, 16);
|
||||
/* (a size in hexadecimal, perhaps with extensions after a ";": a
|
||||
line without one is no chunk, and not the last) */
|
||||
remaining = strtoull(line, &after, 16);
|
||||
if (after == line || (*after && *after != ';' && *after != ' ' && *after != '\t' &&
|
||||
*after != '\r' && *after != '\n'))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!remaining)
|
||||
return 1;
|
||||
while (remaining)
|
||||
|
||||
Reference in new issue
Block a user