summaryrefslogtreecommitdiffstats
path: root/src/util/util.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2012-04-02 17:22:16 -0400
committerStephen Gallagher <sgallagh@redhat.com>2012-04-20 10:55:14 -0400
commite3c99ae355408933b03357220f3db09423bd40dd (patch)
tree2d95838be337f5acb0393b0ed8073f2d61f16c6a /src/util/util.c
parentf34a9f4bd791d9ba7b4bb1df5011e68eb9f6d485 (diff)
downloadsssd-e3c99ae355408933b03357220f3db09423bd40dd.tar.gz
sssd-e3c99ae355408933b03357220f3db09423bd40dd.tar.xz
sssd-e3c99ae355408933b03357220f3db09423bd40dd.zip
sss_atomic_io: Do not fail reads with EPIPE if there is not enough data to read
Also adds a unit test for sss_atomic_io()
Diffstat (limited to 'src/util/util.c')
-rw-r--r--src/util/util.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/util/util.c b/src/util/util.c
index 8e20ab714..3a6c5d270 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -639,7 +639,8 @@ ssize_t sss_atomic_io(int fd, void *buf, size_t n, bool do_read)
}
return -1;
case 0:
- errno = EPIPE;
+ /* read returns 0 on end-of-file */
+ errno = do_read ? 0 : EPIPE;
return pos;
default:
pos += (size_t) res;