From 06cc3dfa592853cdb8ba36ec0be610dbe9bb8012 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sat, 29 Oct 2016 10:32:41 -0400 Subject: [PATCH] [core] check fcntl O_APPEND succeeds w/ mkstemp() --- src/chunk.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/chunk.c b/src/chunk.c index 82dab6e0..fd431a22 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -481,8 +481,12 @@ static chunk *chunkqueue_get_append_tempfile(chunkqueue *cq) { return NULL; } + if (0 != fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_APPEND)) { + close(fd); + buffer_free(template); + return NULL; + } fd_close_on_exec(fd); - (void)fcntl(fd, F_SETFL, fcntl(fd, F_GETFL, 0) | O_APPEND); c = chunkqueue_get_unused_chunk(cq); c->type = FILE_CHUNK;