]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix monofile truncation.
authorRoy Marples <roy@marples.name>
Sat, 25 Jan 2014 02:31:45 +0000 (02:31 +0000)
committerRoy Marples <roy@marples.name>
Sat, 25 Jan 2014 02:31:45 +0000 (02:31 +0000)
auth.c

diff --git a/auth.c b/auth.c
index b3a583d71bbd871ccd9b163a032bc9be0564249a..cfffe4714e27c8b6a46ec3704f7e503f7e3a1b5c 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -35,6 +35,7 @@
 #include <string.h>
 #include <syslog.h>
 #include <time.h>
+#include <unistd.h>
 
 #include "config.h"
 #include "auth.h"
@@ -327,8 +328,8 @@ get_next_rdm_monotonic(void)
        }
 
        rdm++;
-       fseek(fp, 0, SEEK_SET);
-       if (ftruncate(fileno(fp)) == -1 ||
+       if (fseek(fp, 0, SEEK_SET) == -1 ||
+           ftruncate(fileno(fp), 0) == -1 ||
            fprintf(fp, "0x%016" PRIu64 "\n", rdm) != 19)
        {
                if (!last_rdm_set) {