Skip to content

Commit

Permalink
Handle short reads from timestamp file
Browse files Browse the repository at this point in the history
  • Loading branch information
daglem committed Aug 22, 2022
1 parent 32eedc2 commit 1c80b19
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libfaketime.c
Original file line number Diff line number Diff line change
Expand Up @@ -3142,9 +3142,13 @@ int read_config_file()
(faketimerc = open(filename, O_RDONLY)) != -1 ||
(faketimerc = open("/etc/faketimerc", O_RDONLY)) != -1)
{
ssize_t length = read(faketimerc, user_faked_time, sizeof(user_faked_time) - 1);
ssize_t bytes;
ssize_t length = 0;
while ((bytes = read(faketimerc, user_faked_time + length, sizeof(user_faked_time) - 1 - length)) > 0) {
length += bytes;
}
close(faketimerc);
if (length < 0) {
if (bytes < 0) {
length = 0;
}
user_faked_time[length] = 0;
Expand Down

0 comments on commit 1c80b19

Please sign in to comment.