1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:57:45 +00:00

tar: Prevent file buffering from reading uninitialized data

Regressed in 91fa10a0ab.
This commit is contained in:
Tim Schumacher 2022-03-05 12:55:45 +01:00 committed by Andreas Kling
parent 7c32400431
commit e2d71823d3

View file

@ -100,8 +100,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
int fd = TRY(Core::System::open(absolute_path, O_CREAT | O_WRONLY, header.mode()));
Array<u8, buffer_size> buffer;
while (file_stream.read(buffer) > 0)
TRY(Core::System::write(fd, buffer.span()));
size_t bytes_read;
while ((bytes_read = file_stream.read(buffer)) > 0)
TRY(Core::System::write(fd, buffer.span().slice(0, bytes_read)));
TRY(Core::System::close(fd));
break;