mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 23:17:45 +00:00
tar: Prevent file buffering from reading uninitialized data
Regressed in 91fa10a0ab
.
This commit is contained in:
parent
7c32400431
commit
e2d71823d3
1 changed files with 3 additions and 2 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue