Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
950 B

From e8b7619433a6d6e6ff8f106850a3f1d2808653fb Mon Sep 17 00:00:00 2001
From: Brent Cook <bcook@openbsd.org>
Date: Mon, 21 Dec 2015 05:53:20 -0600
Subject: [PATCH 12/12] check result of ftello/ftruncate
---
src/usr.sbin/ntpd/ntpd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
index af8700e..631e4de 100644
--- a/src/usr.sbin/ntpd/ntpd.c
+++ b/src/usr.sbin/ntpd/ntpd.c
@@ -598,6 +598,7 @@ writefreq(double d)
{
int r;
static int warnonce = 1;
+ int off;
if (freqfp == NULL)
return 0;
@@ -611,8 +612,10 @@ writefreq(double d)
clearerr(freqfp);
return 0;
}
- ftruncate(fileno(freqfp), ftello(freqfp));
- fsync(fileno(freqfp));
+ off = ftello(freqfp);
+ if (off == -1 || ftruncate(fileno(freqfp), off) == -1)
+ log_warnx("can't truncate %s", DRIFTFILE);
+ fsync(fileno(freqfp));
return 1;
}
--
2.7.0