summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarak A. Pearlmutter <barak+git@cs.nuim.ie>2012-04-18 11:47:19 +0100
committerAndrej Shadura <andrewsh@debian.org>2019-02-24 08:48:52 +0100
commit2a18896e2de85f4f388084754c6dc765b1c4eeed (patch)
tree27686892e9e1c39b05f2a9bf9587d61f658fc22b
parent790b77e16d6f09da6fba5457079b250a2600c847 (diff)
guard write
Guard write call, avoid ignored-return-value warning. (This is not a false positive: a very subtle attack would consist of filling up the filesystem so much that only a partial PID is written, causing the wrong PID to be signaled later.) (Note that, technically speaking, if only some of the buffer is written we should retry the rest in a loop. But in this case, that seems exceedingly unlikely.) Gbp-Pq: Name 0006-guard-write.patch
-rw-r--r--tayga.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tayga.c b/tayga.c
index 3886831..5027d0a 100644
--- a/tayga.c
+++ b/tayga.c
@@ -439,7 +439,10 @@ int main(int argc, char **argv)
if (pidfile) {
snprintf(addrbuf, sizeof(addrbuf), "%ld\n", (long)getpid());
- write(pidfd, addrbuf, strlen(addrbuf));
+ if (write(pidfd, addrbuf, strlen(addrbuf)) != strlen(addrbuf)) {
+ slog(LOG_CRIT, "Error, unable to write PID file.\n");
+ exit(1);
+ }
close(pidfd);
}