]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests/server/tftpd.c: close upload file in case of abort
authorMarc Hoersken <info@marc-hoersken.de>
Tue, 24 Nov 2020 19:49:09 +0000 (20:49 +0100)
committerMarc Hoersken <info@marc-hoersken.de>
Sat, 28 Nov 2020 18:19:18 +0000 (19:19 +0100)
Commit c353207 removed the closing right after do_tftp
which covered the case of abort. This handles that case.

Reviewed-by: Jay Satiro
Reviewed-by: Daniel Stenberg
Follow up to #6209
Closes #6234

tests/server/tftpd.c

index fdd6e061e7daa101ce774c07583349a6c6f907ea..92d584918f5d149bbe380f92b0da63ec41554d8c 100644 (file)
@@ -1299,6 +1299,7 @@ send_ack:
     }
   } while(size == SEGSIZE);
   write_behind(test, pf->f_convert);
+  /* close the output file as early as possible after upload completion */
   if(test->ofile > 0) {
     close(test->ofile);
     test->ofile = 0;
@@ -1325,6 +1326,11 @@ send_ack:
     (void) swrite(peer, &ackbuf.storage[0], 4);  /* resend final ack */
   }
 abort:
+  /* make sure the output file is closed in case of abort */
+  if(test->ofile > 0) {
+    close(test->ofile);
+    test->ofile = 0;
+  }
   return;
 }