|
From 2bed8fd9ab9ad6016e45f91fd2de5de2a6c79fce 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/13] 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 b665000..18cc21d 100644
|
|
--- a/src/usr.sbin/ntpd/ntpd.c
|
|
+++ b/src/usr.sbin/ntpd/ntpd.c
|
|
@@ -600,6 +600,7 @@ writefreq(double d)
|
|
{
|
|
int r;
|
|
static int warnonce = 1;
|
|
+ int off;
|
|
|
|
if (freqfp == NULL)
|
|
return 0;
|
|
@@ -613,8 +614,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.8.1
|
|
|