diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-08 15:47:34 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-06-10 10:17:38 -0400 |
commit | 06247775aa9c49ffce72827921eb45e2d04c6aa1 (patch) | |
tree | c3e53abf07faa3c8e161cff30746d54af6a78791 /src/util/backup_file.c | |
parent | e5196fd7da44e4ae04ab8b5d2e7191167762cf0b (diff) | |
download | sssd-06247775aa9c49ffce72827921eb45e2d04c6aa1.tar.gz sssd-06247775aa9c49ffce72827921eb45e2d04c6aa1.tar.xz sssd-06247775aa9c49ffce72827921eb45e2d04c6aa1.zip |
Properly handle read() and write() throughout the SSSD
We need to guarantee at all times that reads and writes complete
successfully. This means that they must be checked for returning
EINTR and EAGAIN, and all writes must be wrapped in a loop to
ensure that they do not truncate their output.
Diffstat (limited to 'src/util/backup_file.c')
-rw-r--r-- | src/util/backup_file.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util/backup_file.c b/src/util/backup_file.c index cf9ddf303..990793278 100644 --- a/src/util/backup_file.c +++ b/src/util/backup_file.c @@ -86,7 +86,7 @@ int backup_file(const char *src_file, int dbglvl) while (1) { num = read(src_fd, buf, BUFFER_SIZE); if (num < 0) { - if (errno == EINTR) continue; + if (errno == EINTR || errno == EAGAIN) continue; ret = errno; DEBUG(dbglvl, ("Error (%d [%s]) reading from source %s\n", ret, strerror(ret), src_file)); @@ -101,7 +101,7 @@ int backup_file(const char *src_file, int dbglvl) errno = 0; num = write(dst_fd, &buf[pos], count); if (num < 0) { - if (errno == EINTR) continue; + if (errno == EINTR || errno == EAGAIN) continue; ret = errno; DEBUG(dbglvl, ("Error (%d [%s]) writing to destination %s\n", ret, strerror(ret), dst_file)); |