From 84f88c4e1f04d3d7a2903fc1fd1d4ed3b9e77d07 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Tue, 3 May 2016 12:19:35 +0000 Subject: [PATCH] Really fix the TOCTOU error. --- dhcp6.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dhcp6.c b/dhcp6.c index 391d5c6b..2fc0257b 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -2176,10 +2176,11 @@ dhcp6_readlease(struct interface *ifp, int validate) } else { logger(ifp->ctx, LOG_DEBUG, "%s: reading lease `%s'", ifp->name, state->leasefile); - if (stat(state->leasefile, &st) == -1) + fd = open(state->leasefile, O_RDONLY); + if (fd != -1 && fstat(fd, &st) == -1) { + close(fd); fd = -1; - else - fd = open(state->leasefile, O_RDONLY); + } } if (fd == -1) return -1; -- 2.47.3