Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 87b2fb1497fa9045c83fd64464f5af4e > files > 2

chntpw-1.0-4.mga7.src.rpm

Detect stream write failure.
--- a/ntreg.c
+++ b/ntreg.c
@@ -3493,7 +3493,14 @@
 
     fprintf(file,"\r\n"); /* Must end file with an empty line, windows does that */
 
-    fclose(file);
+    if (ferror (file)) {
+	printf("failed to write file '%s'\n", filename);
+	fclose (file);
+	return;
+    }
+    if (fclose(file))
+      printf("failed to write file '%s': %s\n", filename,
+	     strerror(errno));
 }
 
 /* ================================================================ */