[or-cvs] check return value of fclose while writing to disk, since i...

Roger Dingledine arma at seul.org
Fri Jul 23 21:25:31 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/common

Modified Files:
	util.c 
Log Message:
check return value of fclose while writing to disk, since it might
return out-of-space, etc


Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- util.c	22 Jul 2004 08:29:07 -0000	1.115
+++ util.c	23 Jul 2004 21:25:28 -0000	1.116
@@ -1334,7 +1334,10 @@
     fclose(file);
     return -1;
   }
-  fclose(file);
+  if (fclose(file) == EOF) {
+    log(LOG_WARN,"Error flushing to %s: %s", tempname, strerror(errno));
+    return -1;
+  }
 
 #ifdef MS_WINDOWS
   /* On Windows, rename doesn't replace.  We could call ReplaceFile, but



More information about the tor-commits mailing list