1
0
mirror of https://github.com/openSUSE/libsolv.git synced 2026-02-05 12:45:46 +01:00

tarhead: add a line size limit to catch broken entries

Also write back the allocated line length.
This commit is contained in:
Michael Schroeder
2025-08-05 12:03:15 +02:00
parent f8a299cd63
commit 56f5ca0d86

View File

@@ -12,6 +12,8 @@
#include "util.h"
#include "tarhead.h"
#define MAX_LINE_SIZE 0x1000000
static long long parsenum(unsigned char *p, int cnt)
{
long long x = 0;
@@ -232,7 +234,14 @@ size_t tarhead_gets(struct tarhead *th, char **linep , size_t *allocsizep)
size_t fsize = lsize - size;
if (fsize < 2)
{
if (lsize >= MAX_LINE_SIZE)
{
th->eof = 1;
return 0;
}
line = *linep = solv_realloc(line, lsize += 1024);
if (allocsizep)
*allocsizep = lsize;
fsize = lsize - size;
}
for (i = th->off; i < th->end && fsize > 1;)