NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Problems unpacking sets with ftp -o



Can you try the patch below?

---START PATCH---
diff -urN ftp.orig/fetch.c ftp/fetch.c
--- ftp.orig/fetch.c	2020-07-11 00:29:38.000000000 +0000
+++ ftp/fetch.c	2021-07-01 22:20:41.620575702 +0000
@@ -1640,7 +1640,7 @@
 			if (ischunked)
 				bufrem = MIN(chunksize, bufrem);
 			while (bufrem > 0) {
-				size_t nr = MIN((off_t)bufsize, bufrem);
+				size_t wrt, nw, nr = MIN((off_t)bufsize, bufrem);
 				flen = fetch_read(xferbuf, sizeof(char),
 				    nr, fin);
 				if (flen == 0) {
@@ -1650,10 +1650,14 @@
 				}
 				bytes += flen;
 				bufrem -= flen;
-				if (fwrite(xferbuf, sizeof(char), flen, fout)
-				    != flen) {
-					warn("Writing `%s'", savefile);
-					goto cleanup_fetch_url;
+				for (wrt = 0; wrt < flen; wrt += nw) {
+					errno = 0;
+					nw = fwrite(xferbuf + wrt, sizeof(char),
+						    flen - wrt, fout);
+					if ((nw != flen - wrt) && (errno != EINTR)) {
+						warn("Writing `%s'", savefile);
+						goto cleanup_fetch_url;
+					}
 				}
 				if (hash && !progress) {
 					while (bytes >= hashbytes) {
---END PATCH---

-RVP



Home | Main Index | Thread Index | Old Index