aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2017-04-08 23:02:48 +0200
committerMattias Andrée <maandree@kth.se>2017-04-08 23:02:48 +0200
commit0804a80954bf9b8c11392d77a4933ec0a4ff635b (patch)
treed19ab7658b07089af643deba41ec73f696925e54 /src/util.c
parentDocument memory requirements, minor style fixes, more use of BUFSIZ, fix warnings, and fix potential buffer overflow (diff)
downloadblind-0804a80954bf9b8c11392d77a4933ec0a4ff635b.tar.gz
blind-0804a80954bf9b8c11392d77a4933ec0a4ff635b.tar.bz2
blind-0804a80954bf9b8c11392d77a4933ec0a4ff635b.tar.xz
Add blind-translate and fix errors
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 6c1bd0a..92b4d20 100644
--- a/src/util.c
+++ b/src/util.c
@@ -157,6 +157,18 @@ pwriteall(int fd, void *buf, size_t n, size_t ptr)
return 0;
}
+int
+writezeroes(int fd, void *buf, size_t bufsize, size_t n)
+{
+ size_t p, m;
+ for (p = 0; p < n; p += m) {
+ m = bufsize < n - p ? bufsize : n - p;
+ if (writeall(fd, buf, m))
+ return -1;
+ }
+ return 0;
+}
+
static inline pid_t
enfork(int status)