Skip to content
Snippets Groups Projects
Commit 860d6c53 authored by Pekka Enberg's avatar Pekka Enberg
Browse files

cpio: Fix zero-length files


If c_filesize is zero, bail out immediately from parse_one(). Otherwise
the rdbuf()->pubsetbuf() call will wreak havoc on the stream position
and cause the next header to have corrupt CPIO magic.

Found by streaming openjdk rpm2cpio output to OSv.

Reviewed-by: default avatarGlauber Costa <glommer@cloudius-systems.com>
Cc: Benoît Canet <benoit@irqsave.net>
Signed-off-by: default avatarPekka Enberg <penberg@cloudius-systems.com>
parent 5b26ed0c
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,9 @@ bool cpio_in::parse_one(istream& is, cpio_in& out)
return false;
}
auto filesize = convert(h.c_filesize);
if (!filesize) {
return true;
}
auto aligned_filesize = align_up(filesize, 4u);
auto file_slice = io::restrict(is, 0, filesize);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment