Skip to content

Commit 75fa17b

Browse files
committed
zchunk: support skipping of optional elements
1 parent 4c28f90 commit 75fa17b

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

ext/solv_zchunk.c

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,10 +300,28 @@ solv_zchunk_open(FILE *fp, unsigned int streamid)
300300
#endif
301301
if ((p = getuint(p, zck->hdr_end, &zck->flags)) == 0)
302302
return open_error(zck);
303-
if ((zck->flags & ~(1)) != 0)
303+
if ((zck->flags & ~(3)) != 0)
304304
return open_error(zck);
305305
if ((p = getuint(p, zck->hdr_end, &zck->comp)) == 0 || (zck->comp != 0 && zck->comp != 2))
306306
return open_error(zck); /* only uncompressed + zstd supported */
307+
/* skip all optional elements if present */
308+
if ((zck->flags & 2) != 0)
309+
{
310+
unsigned int nopt, lopt;
311+
if ((p = getuint(p, zck->hdr_end, &nopt)) == 0)
312+
return open_error(zck);
313+
for (; nopt != 0; nopt--)
314+
{
315+
if ((p = getuint(p, zck->hdr_end, &lopt)) == 0)
316+
return open_error(zck);
317+
if ((p = getuint(p, zck->hdr_end, &lopt)) == 0)
318+
return open_error(zck);
319+
if (p + lopt > zck->hdr_end)
320+
return open_error(zck);
321+
p += lopt;
322+
}
323+
}
324+
307325
preface_size = p - (zck->hdr + lead_size);
308326

309327
/* parse index: index size, index chksum type, num chunks, chunk data */

0 commit comments

Comments
 (0)