chiark / gitweb /
regress: fuzz: Fix check1fuzz and Makefile
[adns.git] / regress / hfuzzraw.c.m4
index 0ed71a2c326232cba12bb4e72fdac6b58ea575ec..5ce1b3efc92567cb8e01de6288667652ee12714b 100644 (file)
@@ -74,7 +74,10 @@ void Tensuresetup(void) {
   const char *traceprintstr= getenv("ADNS_TEST_FUZZRAW_TRACEPRINT");
   if (traceprintstr) {
     traceprint= atoi(traceprintstr);
-    traceout= fdopen(2,"w");  if (!traceout) Tfailed("fdopen for traceout");
+    int tracefd= dup(2);
+    if (tracefd<0) Tfailed("dup for tracefd");
+    traceout= fdopen(tracefd,"w");
+    if (!traceout) Tfailed("fdopen for traceout");
   }
 }
 
@@ -91,6 +94,7 @@ static void Pformat(const char *what) {
 }
 
 extern void Tshutdown(void) {
+  if (!Tinputfile) return;
   int c= fgetc(Tinputfile);
   if (c!=EOF) Pformat("unwanted additional syscall reply data");
   if (ferror(Tinputfile)) Tfailed("read test log input (at end)");