09299d
--- netkit-ftp-0.17/ftp/ftp.c.rasold	2005-08-22 14:22:50.000000000 +0200
09299d
+++ netkit-ftp-0.17/ftp/ftp.c	2005-08-22 14:23:02.000000000 +0200
09299d
@@ -139,7 +139,7 @@
09299d
 static char *gunique(char *);
09299d
 static void proxtrans(const char *cmd, char *local, char *remote);
09299d
 static int initconn(void);
09299d
-static void ptransfer(const char *direction, long bytes, 
09299d
+static void ptransfer(const char *direction, long long bytes, 
09299d
 		      const struct timeval *t0, 
09299d
 		      const struct timeval *t1);
09299d
 static void tvsub(struct timeval *tdiff, 
09299d
@@ -579,7 +579,7 @@
09299d
 	int (*volatile closefunc)(FILE *);
09299d
 	void (*volatile oldintr)(int);
09299d
 	void (*volatile oldintp)(int);
09299d
-	volatile long bytes = 0, hashbytes = HASHBYTES;
09299d
+	volatile long long bytes = 0, hashbytes = HASHBYTES;
09299d
 	char buf[BUFSIZ], *bufp;
09299d
 	const char *volatile lmode;
09299d
 
09299d
@@ -713,14 +713,14 @@
09299d
 				if ((d = write(fileno(dout), bufp, c)) <= 0)
09299d
 					break;
09299d
 			if (hash) {
09299d
-				while (bytes >= hashbytes) {
09299d
-					(void) putchar('#');
09299d
-					hashbytes += HASHBYTES;
09299d
-				}
09299d
-				(void) fflush(stdout);
09299d
-			}
09299d
+				while (bytes >= hashbytes) {        /* <-- 'long long' signed overflow is  */
09299d
+					(void) putchar('#');        /* possible. In this case, we can      */
09299d
+					hashbytes += HASHBYTES;     /* 'cycle' there for very long time.   */
09299d
+				}                                   /* Search 'hasbytes' in file down,     */
09299d
+				(void) fflush(stdout);              /* there are similar parts.            */
09299d
+			}                                           /*           <praszyk@redhat.com>      */
09299d
 			if (tick && (bytes >= hashbytes)) {
09299d
-				printf("\rBytes transferred: %ld", bytes);
09299d
+				printf("\rBytes transferred: %lld", bytes);
09299d
 				(void) fflush(stdout);
09299d
 				while (bytes >= hashbytes)
09299d
 					hashbytes += TICKBYTES;
09299d
@@ -733,7 +733,7 @@
09299d
 			(void) fflush(stdout);
09299d
 		}
09299d
 		if (tick) {
09299d
-			(void) printf("\rBytes transferred: %ld\n", bytes);
09299d
+			(void) printf("\rBytes transferred: %lld\n", bytes);
09299d
 			(void) fflush(stdout);
09299d
 		}
09299d
 		if (c < 0)
09299d
@@ -755,7 +755,7 @@
09299d
 					hashbytes += HASHBYTES;
09299d
 				}
09299d
 				if (tick && (bytes >= hashbytes)) {
09299d
-					(void) printf("\rBytes transferred: %ld",
09299d
+					(void) printf("\rBytes transferred: %lld",
09299d
 						bytes);
09299d
 					(void) fflush(stdout);
09299d
 					while (bytes >= hashbytes)
09299d
@@ -780,7 +780,7 @@
09299d
 			(void) fflush(stdout);
09299d
 		}
09299d
 		if (tick) {
09299d
-			(void) printf("\rBytes transferred: %ld\n", bytes);
09299d
+			(void) printf("\rBytes transferred: %lld\n", bytes);
09299d
 			(void) fflush(stdout);
09299d
 		}
09299d
 		if (ferror(fin))
09299d
@@ -853,9 +853,9 @@
09299d
 	void (*volatile oldintp)(int);
09299d
 	void (*volatile oldintr)(int);
09299d
 	volatile int is_retr, tcrflag, bare_lfs = 0;
09299d
-	static unsigned bufsize;
09299d
+	static unsigned bufsize=0;
09299d
 	static char *buf;
09299d
-	volatile long bytes = 0, hashbytes = HASHBYTES;
09299d
+	volatile long long bytes = 0, hashbytes = HASHBYTES;
09299d
 	register int c, d;
09299d
 	struct timeval start, stop;
09299d
 	struct stat st;
09299d
@@ -1031,7 +1031,7 @@
09299d
 				(void) fflush(stdout);
09299d
 			}
09299d
 			if (tick && (bytes >= hashbytes) && is_retr) {
09299d
-				(void) printf("\rBytes transferred: %ld",
09299d
+				(void) printf("\rBytes transferred: %lld",
09299d
 					bytes);
09299d
 				(void) fflush(stdout);
09299d
 				while (bytes >= hashbytes)
09299d
@@ -1045,7 +1045,7 @@
09299d
 			(void) fflush(stdout);
09299d
 		}
09299d
 		if (tick && is_retr) {
09299d
-			(void) printf("\rBytes transferred: %ld\n", bytes);
09299d
+			(void) printf("\rBytes transferred: %lld\n", bytes);
09299d
 			(void) fflush(stdout);
09299d
 		}
09299d
 		if (c < 0) {
09299d
@@ -1095,7 +1095,7 @@
09299d
 					hashbytes += HASHBYTES;
09299d
 				}
09299d
 				if (tick && (bytes >= hashbytes) && is_retr) {
09299d
-					printf("\rBytes transferred: %ld",
09299d
+					printf("\rBytes transferred: %lld",
09299d
 						bytes);
09299d
 					fflush(stdout);
09299d
 					while (bytes >= hashbytes)
09299d
@@ -1126,7 +1126,7 @@
09299d
 			(void) fflush(stdout);
09299d
 		}
09299d
 		if (tick && is_retr) {
09299d
-			(void) printf("\rBytes transferred: %ld\n", bytes);
09299d
+			(void) printf("\rBytes transferred: %lld\n", bytes);
09299d
 			(void) fflush(stdout);
09299d
 		}
09299d
 		if (bare_lfs) {
09299d
@@ -1540,7 +1540,7 @@
09299d
 }
09299d
 
09299d
 static void
09299d
-ptransfer(const char *direction, long bytes, 
09299d
+ptransfer(const char *direction, long long bytes, 
09299d
 	  const struct timeval *t0, 
09299d
 	  const struct timeval *t1)
09299d
 {
09299d
@@ -1552,7 +1552,7 @@
09299d
 		s = td.tv_sec + (td.tv_usec / 1000000.);
09299d
 #define	nz(x)	((x) == 0 ? 1 : (x))
09299d
 		bs = bytes / nz(s);
09299d
-		printf("%ld bytes %s in %.3g secs (%.2g Kbytes/sec)\n",
09299d
+		printf("%lld bytes %s in %.3g secs (%.2g Kbytes/sec)\n",
09299d
 		    bytes, direction, s, bs / 1024.0);
09299d
 	}
09299d
 }