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
951 B

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. From b313da219fdd6392095e617cf5f07158c4da21e3 Mon Sep 17 00:00:00 2001
  2. From: Brent Cook <bcook@openbsd.org>
  3. Date: Mon, 21 Dec 2015 05:53:20 -0600
  4. Subject: [PATCH 12/13] check result of ftello/ftruncate
  5. ---
  6. src/usr.sbin/ntpd/ntpd.c | 7 +++++--
  7. 1 file changed, 5 insertions(+), 2 deletions(-)
  8. diff --git a/src/usr.sbin/ntpd/ntpd.c b/src/usr.sbin/ntpd/ntpd.c
  9. index 99bdecf..35a9797 100644
  10. --- a/src/usr.sbin/ntpd/ntpd.c
  11. +++ b/src/usr.sbin/ntpd/ntpd.c
  12. @@ -592,6 +592,7 @@ writefreq(double d)
  13. {
  14. int r;
  15. static int warnonce = 1;
  16. + int off;
  17. if (freqfp == NULL)
  18. return 0;
  19. @@ -605,8 +606,10 @@ writefreq(double d)
  20. clearerr(freqfp);
  21. return 0;
  22. }
  23. - ftruncate(fileno(freqfp), ftello(freqfp));
  24. - fsync(fileno(freqfp));
  25. + off = ftello(freqfp);
  26. + if (off == -1 || ftruncate(fileno(freqfp), off) == -1)
  27. + log_warnx("can't truncate %s", DRIFTFILE);
  28. + fsync(fileno(freqfp));
  29. return 1;
  30. }
  31. --
  32. 2.10.1