changeset 2245:22a45fca5cf4 draft

Fix monofile truncation.
author Roy Marples <roy@marples.name>
date Sat, 25 Jan 2014 02:31:45 +0000
parents 253f689f57bf
children 4331ac84793a
files auth.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/auth.c	Sat Jan 25 02:23:41 2014 +0000
+++ b/auth.c	Sat Jan 25 02:31:45 2014 +0000
@@ -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 @@
 	}
 
 	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) {