aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-09-20 13:33:55 +0200
committerMattias Andrée <maandree@operamail.com>2015-09-20 13:33:55 +0200
commit44eb280f853f77a88a801fcbf725c93623e990af (patch)
tree612e37b5717cda9dabe94dada4be5e889a8c8cf1 /src
parentm style (diff)
downloadlibsha2-44eb280f853f77a88a801fcbf725c93623e990af.tar.gz
libsha2-44eb280f853f77a88a801fcbf725c93623e990af.tar.bz2
libsha2-44eb280f853f77a88a801fcbf725c93623e990af.tar.xz
libsha2_sum_fd continues if interrupted
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/libsha2/files.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libsha2/files.c b/src/libsha2/files.c
index 2f4bb72..903c592 100644
--- a/src/libsha2/files.c
+++ b/src/libsha2/files.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <sys/stat.h>
#include <alloca.h>
+#include <errno.h>
@@ -54,8 +55,14 @@ int libsha2_sum_fd(int fd, libsha2_algorithm_t algorithm, char* restrict hashsum
for (;;)
{
got = read(fd, chunk, blksize);
- if (got < 0) return -1;
- if (got == 0) break;
+ if (got < 0)
+ {
+ if (errno == EINTR)
+ continue;
+ return -1;
+ }
+ if (got == 0)
+ break;
libsha2_update(&state, chunk, (size_t)got);
}