From: Boyuan Yang <byang@debian.org>
Date: Tue, 31 Aug 2021 00:03:32 -0400
Subject: fix source code

---
 src/net.c      | 34 +++++++++++++++++++++++++++++++++-
 src/pussy      |  2 +-
 src/sendfile.c |  2 +-
 3 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/src/net.c b/src/net.c
index 2a4288f..b1d0a40 100644
--- a/src/net.c
+++ b/src/net.c
@@ -79,6 +79,10 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <sys/ioctl.h>
+#include <termios.h>
+#include <time.h>
+#include <stdlib.h>
 
 #include "string.h"	/* extended string functions */
 #include "message.h"	/* information, warning and error messages */
@@ -685,6 +689,8 @@ int send_data(int sockfd, off_t size, const char *file,
   extern int 
     quiet,		/* quiet mode flag */
     packet_size;	/* size of a packet in bytes */
+  struct winsize wsize;
+  char *thisfile = NULL;
 
   msec=0;
   offset=0;
@@ -777,6 +783,24 @@ int send_data(int sockfd, off_t size, const char *file,
     message("",'I',tmp);
   }
 
+  if (!quiet) {
+    if (ioctl(fileno(stdout), TIOCGWINSZ, &wsize) != 0)
+      wsize.ws_col = 80;
+    if (strlen (fname)+40 <= wsize.ws_col)
+      thisfile = fname;
+    else {
+      if ((thisfile = (char *)malloc ( (wsize.ws_col-40) +1)) == NULL) {
+        snprintf(MAXS(tmp),"error allocating %d bytes",(wsize.ws_col-40) +1);
+        message("",'E',tmp);
+      }
+      memset (thisfile, 0, (wsize.ws_col-40) +1);
+
+      strncpy (thisfile, fname, (wsize.ws_col-40-2) / 2);
+      strcat (thisfile, "..");
+      strncat (thisfile, fname+(strlen (fname) - (wsize.ws_col-40-2) / 2), (wsize.ws_col-40-2) / 2);
+    }
+  }
+
   /* get time normal */
 #if defined(SOLARIS2) || defined(IRIX)
    #ifdef _SVID_GETTOD
@@ -818,10 +842,15 @@ int send_data(int sockfd, off_t size, const char *file,
     bytes+=packet_size;
     percent=(bytes+offset)*100.0/(size+offset);
     if (!quiet) {
+
+      if (ioctl(fileno(stdout), TIOCGWINSZ, &wsize) != 0)
+	return (-1);
+      /* resizeterm(size.ws_row, size.ws_col); wrefresh(curscr); */
+
       sec2=time(0);
       if (sec2>sec1) {
 	fprintf(stderr,"%s%s: %3d%%  (%lld of %lld kB)\r",
-		tinfo,fname,percent,
+		tinfo,thisfile,percent,
 		(bytes+offset-1)/1024+1,(size+offset-1)/1024+1);
 	fflush(stderr);
 	sec1=sec2;
@@ -855,6 +884,9 @@ int send_data(int sockfd, off_t size, const char *file,
 
   close(ffd);
 
+  if (thisfile && strlen (fname)+40 > wsize.ws_col)
+    free (thisfile);
+
   if (quiet<2) {
    
     /* get time difference */
diff --git a/src/pussy b/src/pussy
index ec29db0..97ce0fc 100755
--- a/src/pussy
+++ b/src/pussy
@@ -1,4 +1,4 @@
-#!/client/bin/perl -w
+#! /usr/bin/perl -w
 
 # PUSSY - Perl User SAFT Server Yin
 
diff --git a/src/sendfile.c b/src/sendfile.c
index 9f84393..d9142f6 100644
--- a/src/sendfile.c
+++ b/src/sendfile.c
@@ -855,7 +855,7 @@ const char
       if (quiet<2) message(prg,'I',"you may specify -W=config, -W=spool, or "
 			           "-W=userspool");
     } 
-    if (argc-optind<1) exit(0);
+    if (argc-optind<1) {cleanup();exit(0);}
   }
 
   /* check tmp files */
