diff --git a/ftp.spec b/ftp.spec index 0adb339c35c960f618e013491dc03e1d7afa10a9..46a5e881cb6aef6b61d30aef1f6a8455034b3845 100644 --- a/ftp.spec +++ b/ftp.spec @@ -1,13 +1,13 @@ -%define anolis_release 3 +%define anolis_release 4 Summary: The standard UNIX FTP (File Transfer Protocol) client Name: ftp -Version: 0.17 +Version: 0.17 Release: %{anolis_release}%{dist} License: BSD with advertising URL: http://ftp.linux.org.uk/pub/linux/Networking/netkit +Source0: ftp://ftp.linux.org.uk/pub/linux/Networking/netkit/netkit-ftp-0.17.tar.gz -Source0: http://ftp.linux.org.uk/pub/linux/Networking/netkit/netkit-ftp-%{version}.tar.gz Patch0001: 0001-PATCH-netkit-ftp-0.17-pre20000412.pasv-security.patch Patch0002: 0002-PATCH-netkit-ftp-0.17-acct.patch @@ -45,6 +45,33 @@ Patch0033: 0033-PATCH-netkit-ftp-0.17-getlogin.patch Patch0034: 0034-PATCH-netkit-ftp-0.17-token.patch Patch0035: 0035-PATCH-netkit-ftp-0.17-linelen-segfault.patch Patch0036: 0036-PATCH-netkit-ftp-0.17-out-of-memory.patch +Patch37: netkit-ftp-0.17-fdleak.patch +Patch38: netkit-ftp-0.17-size.patch +Patch39: netkit-ftp-0.17-token.patch +Patch40: netkit-ftp-0.17-chkmalloc.patch +Patch41: netkit-ftp-0.17-acct_ovl.patch +Patch42: netkit-ftp-0.17-acct.patch +Patch43: netkit-ftp-0.17-linelen-segfault.patch +Patch44: netkit-ftp-0.17-segv.patch +Patch45: netkit-ftp-0.17-volatile.patch +Patch46: netkit-ftp-0.17-arg_max.patch +Patch47: netkit-ftp-0.17-bitrate.patch +Patch48: netkit-ftp-0.17-lsn-timeout.patch +Patch49: netkit-ftp-0.17-out-of-memory.patch +Patch50: netkit-ftp-0.17-commands-leaks.patch +Patch51: netkit-ftp-0.17-longint.patch +Patch52: netkit-ftp-0.17-data.patch +Patch53: netkit-ftp-0.17-C-Frame121.patch +Patch54: netkit-ftp-0.17-vsftp165083.patch +Patch55: netkit-ftp-0.17-runique_mget.patch +Patch56: netkit-ftp-0.17-sigseg.patch +Patch57: netkit-ftp-0.17-case.patch +Patch58: netkit-ftp-0.17-fprintf.patch +Patch59: netkit-ftp-0.17-remove-nested-include.patch +Patch60: netkit-ftp-0.17-linelen.patch +Patch61: netkit-ftp-0.17-getlogin.patch +Patch62: netkit-ftp-0.17-man.patch +Patch63: netkit-ftp-0.17-printf.patch BuildRequires: glibc-devel, readline-devel, ncurses-devel BuildRequires: perl-interpreter, gcc @@ -136,4 +163,30 @@ make INSTALLROOT=${RPM_BUILD_ROOT} install - Optimize spec file * Wed Apr 13 2022 Zhongling He - 0.17-1 -- Init package from upstream v0.17 +- Init package from upstream v0.17* Thu Sep 18 2025 wenyuzifang - 0.17-4 +- Close data connection after retrieval to prevent file descriptor leaks +- Ensure accurate file size queries by forcing binary mode during SIZE command +- Prevent buffer overflows in .netrc token parsing with long tokens +- Prevent crashes by checking malloc results before copying data +- Fix buffer overflow vulnerability in string concatenation with proper null termination +- Prevent redundant account prompts and enhance login reliability +- Prevent buffer overflow by limiting argument count and improving parsing safety +- Prevent segmentation faults in FTP control connection handling +- Fix signal handling correctness and improve diagnostics on platforms like IA-64 +- Ensure runtime argument limit accuracy, prevent stack overflow, and fix memory leaks +- Fix transfer rate display using proper decimal units and consistent formatting +- Prevent indefinite hangs with 30-second receive timeout on data connections +- Ensure reliable globbing under low ARG_MAX conditions +- Fix memory leak by freeing dynamically allocated argument memory +- Prevent integer overflow in byte counters for large file transfers +- Prevent file descriptor leaks by closing stale sockets before new connections +- Enable EPSV support for improved passive mode reliability +- Prevent protocol desynchronization with misbehaving FTP servers +- Skip unnecessary file uniqueness checks during directory listings +- Prevent undefined behavior by calling fclose only on valid file pointers +- Fix unsafe filename handling via correct pointer usage +- Route error messages to stderr to avoid stdout interference +- Prevent buffer overflows using larger, dynamically sized input buffers +- Use UID for reliable user identity lookup instead of session-dependent names +- Fix documentation typos for clarity and professionalism +- Ensure type safety by explicitly casting restart_point during printing diff --git a/netkit-ftp-0.17-C-Frame121.patch b/netkit-ftp-0.17-C-Frame121.patch new file mode 100644 index 0000000000000000000000000000000000000000..f687d1660be702434c2756b177c3a44b771e4111 --- /dev/null +++ b/netkit-ftp-0.17-C-Frame121.patch @@ -0,0 +1,25 @@ +--- netkit-ftp-0.17/ftp/ftp.c.rasold 2005-10-26 16:56:09.000000000 +0200 ++++ netkit-ftp-0.17/ftp/ftp.c 2005-10-26 16:56:46.000000000 +0200 +@@ -1253,14 +1253,14 @@ + switch (data_addr.su_family) { + case AF_INET: + #if 0 +- if (try_epsv) { +- result = command(pasvcmd = "EPSV 1"); +- if (code / 10 == 22 && code != 229) { +- fprintf(stderr, +- "wrong server: return code must be 229\n"); +- result = COMPLETE + 1; +- } +- } else { ++/*@*/ if (try_epsv) { ++/*@*/ result = command(pasvcmd = "EPSV 1"); ++/*@*/ if (code / 10 == 22 && code != 229) { ++/*@*/ fprintf(stderr, ++/*@*/ "wrong server: return code must be 229\n"); ++/*@*/ result = COMPLETE + 1; ++/*@*/ } ++/*@*/ } else { + #endif + result = COMPLETE + 1; + diff --git a/netkit-ftp-0.17-acct.patch b/netkit-ftp-0.17-acct.patch new file mode 100644 index 0000000000000000000000000000000000000000..aaadc1f045c4f2a3b97ddfe0b01ce02056b0a003 --- /dev/null +++ b/netkit-ftp-0.17-acct.patch @@ -0,0 +1,12 @@ +--- netkit-ftp-0.17/ftp/ftp.c.acct Sun Jan 21 00:08:29 2001 ++++ netkit-ftp-0.17/ftp/ftp.c Sun Jan 21 00:09:04 2001 +@@ -254,7 +254,8 @@ + if (n == CONTINUE) { + aflag++; + /* fflush(stdout); */ +- zacct = getpass("Account:"); ++ if(zacct==NULL) ++ zacct = getpass("Account:"); + n = command("ACCT %s", zacct); + } + if (n != COMPLETE) { diff --git a/netkit-ftp-0.17-acct_ovl.patch b/netkit-ftp-0.17-acct_ovl.patch new file mode 100644 index 0000000000000000000000000000000000000000..ebff49c122f6abff03a9d8fc87b89d42738ecd96 --- /dev/null +++ b/netkit-ftp-0.17-acct_ovl.patch @@ -0,0 +1,13 @@ +diff -up netkit-ftp-0.17/ftp/cmds.c.acct_ovl netkit-ftp-0.17/ftp/cmds.c +--- netkit-ftp-0.17/ftp/cmds.c.acct_ovl 2011-09-09 15:36:36.087956561 +0200 ++++ netkit-ftp-0.17/ftp/cmds.c 2011-09-09 15:41:16.457495370 +0200 +@@ -1837,8 +1837,7 @@ account(int argc, char *argv[]) + while (argc > 1) { + --argc; + ++argv; +- strncat(buf, *argv, sizeof(buf)-strlen(buf)); +- buf[sizeof(buf)-1] = 0; ++ strncat(buf, *argv, sizeof(buf)-strlen(buf)-1); + } + ap = buf; + } diff --git a/netkit-ftp-0.17-arg_max.patch b/netkit-ftp-0.17-arg_max.patch new file mode 100644 index 0000000000000000000000000000000000000000..08a88bb54b41b7d1efc1457263222b231b4b11ff --- /dev/null +++ b/netkit-ftp-0.17-arg_max.patch @@ -0,0 +1,55 @@ +diff -up netkit-ftp-0.17/ftp/glob.c.arg_max netkit-ftp-0.17/ftp/glob.c +--- netkit-ftp-0.17/ftp/glob.c.arg_max 2008-04-07 11:41:14.000000000 +0200 ++++ netkit-ftp-0.17/ftp/glob.c 2008-04-07 12:01:53.000000000 +0200 +@@ -50,6 +50,7 @@ char glob_rcsid[] = + #include + #include + #include ++#include + + #include "ftp_var.h" /* for protos only */ + #include "glob.h" +@@ -57,7 +58,7 @@ char glob_rcsid[] = + #define QUOTE 0200 + #define TRIM 0177 + #define eq(a,b) (strcmp(a, b)==0) +-#define GAVSIZ (ARG_MAX/6) ++#define GAVSIZ (sysconf(_SC_ARG_MAX)/6) + #define isdir(d) ((d.st_mode & S_IFMT) == S_IFDIR) + + const char *globerr; +@@ -115,7 +116,7 @@ char ** + ftpglob(const char *v) + { + char agpath[BUFSIZ]; +- entry agargv[GAVSIZ]; ++ entry *agargv; + centry vv[2]; + vv[0].text = v; + vv[1].text = NULL; +@@ -133,6 +134,8 @@ ftpglob(const char *v) + /* added ()'s to sizeof, (ambigious math for the compiler) */ + lastgpathp = agpath + (sizeof(agpath)- 2); + ++ agargv = (entry *)malloc(sizeof (entry) * GAVSIZ); ++ if (agargv == NULL) fatal("Out of memory"); + ginit(agargv); + globcnt = 0; + collect(v); +@@ -156,7 +159,7 @@ ginit(entry *agargv) + gargv = agargv; + sortbas = agargv; + gargc = 0; +- gnleft = ARG_MAX - 4; ++ gnleft = sysconf(_SC_ARG_MAX) - 4; + } + + static +@@ -674,6 +677,7 @@ efree(entry *av) + { + int i; + for (i=0; av[i].text; i++) free(av[i].text); ++ free((void *)av); + } + + static diff --git a/netkit-ftp-0.17-bitrate.patch b/netkit-ftp-0.17-bitrate.patch new file mode 100644 index 0000000000000000000000000000000000000000..eb2506e1d54937c1d43d71e544f0d3aff2707fc5 --- /dev/null +++ b/netkit-ftp-0.17-bitrate.patch @@ -0,0 +1,14 @@ +diff -up netkit-ftp-0.17/ftp/ftp.c.old netkit-ftp-0.17/ftp/ftp.c +--- netkit-ftp-0.17/ftp/ftp.c.old 2008-01-28 10:23:17.000000000 +0100 ++++ netkit-ftp-0.17/ftp/ftp.c 2008-01-28 10:32:01.000000000 +0100 +@@ -1609,8 +1609,8 @@ ptransfer(const char *direction, long lo + s = td.tv_sec + (td.tv_usec / 1000000.); + #define nz(x) ((x) == 0 ? 1 : (x)) + bs = bytes / nz(s); +- printf("%lld bytes %s in %.3g secs (%.2g Kbytes/sec)\n", +- bytes, direction, s, bs / 1024.0); ++ printf("%lld bytes %s in %.3g secs (%.2f Kbytes/sec)\n", ++ bytes, direction, s, bs / 1000.0); + } + } + diff --git a/netkit-ftp-0.17-case.patch b/netkit-ftp-0.17-case.patch new file mode 100644 index 0000000000000000000000000000000000000000..a6eb166b2c86c892c79c9a634f91f6352ab46eaa --- /dev/null +++ b/netkit-ftp-0.17-case.patch @@ -0,0 +1,16 @@ +diff -up netkit-ftp-0.17/ftp/cmds.c.case netkit-ftp-0.17/ftp/cmds.c +--- netkit-ftp-0.17/ftp/cmds.c.case 2008-04-23 14:52:59.000000000 +0200 ++++ netkit-ftp-0.17/ftp/cmds.c 2008-04-23 14:58:07.000000000 +0200 +@@ -831,8 +831,11 @@ mget(int argc, char **argv) + tp++; + tp2++; + } ++ tp = tmpbuf; ++ } ++ else { ++ tp = cp; + } +- tp = tmpbuf; + } + if (ntflag) { + tp = dotrans(tp); diff --git a/netkit-ftp-0.17-chkmalloc.patch b/netkit-ftp-0.17-chkmalloc.patch new file mode 100644 index 0000000000000000000000000000000000000000..f9a12107bc3b249b5a7a97a8ee1d97c804129d70 --- /dev/null +++ b/netkit-ftp-0.17-chkmalloc.patch @@ -0,0 +1,33 @@ +diff -up netkit-ftp-0.17/ftp/ruserpass.c.chkmalloc netkit-ftp-0.17/ftp/ruserpass.c +--- netkit-ftp-0.17/ftp/ruserpass.c.chkmalloc 2008-12-01 11:54:15.000000000 +0100 ++++ netkit-ftp-0.17/ftp/ruserpass.c 2008-12-01 11:56:06.000000000 +0100 +@@ -137,7 +137,8 @@ next: + if (token()) { + if (*aname == 0) { + *aname = malloc((unsigned) strlen(tokval) + 1); +- (void) strcpy(*aname, tokval); ++ if (*aname != NULL) ++ (void) strcpy(*aname, tokval); + } else { + if (strcmp(*aname, tokval)) + goto next; +@@ -158,7 +159,8 @@ next: + } + if (token() && *apass == 0) { + *apass = malloc((unsigned) strlen(tokval) + 1); +- (void) strcpy(*apass, tokval); ++ if (*apass != NULL) ++ (void) strcpy(*apass, tokval); + } + break; + case ACCOUNT: +@@ -170,7 +172,8 @@ next: + } + if (token() && *aacct == 0) { + *aacct = malloc((unsigned) strlen(tokval) + 1); +- (void) strcpy(*aacct, tokval); ++ if (*aacct != NULL) ++ (void) strcpy(*aacct, tokval); + } + break; + case MACDEF: diff --git a/netkit-ftp-0.17-commands-leaks.patch b/netkit-ftp-0.17-commands-leaks.patch new file mode 100644 index 0000000000000000000000000000000000000000..a2bd2647e3a1bfe914a36424e7b4bec833c2047d --- /dev/null +++ b/netkit-ftp-0.17-commands-leaks.patch @@ -0,0 +1,13 @@ +diff -up netkit-ftp-0.17/ftp/cmds.c.orig netkit-ftp-0.17/ftp/cmds.c +--- netkit-ftp-0.17/ftp/cmds.c.orig 2011-09-05 14:41:34.000000000 +0200 ++++ netkit-ftp-0.17/ftp/cmds.c 2011-09-05 14:44:44.000000000 +0200 +@@ -499,6 +499,9 @@ usage: + } + sendrequest(cmd, argv[1], argv[2], + argv[1] != oldargv1 || argv[2] != oldargv2); ++ if (argv[1] != oldargv1) { ++ free(argv[1]); ++ } + } + + void mabort(int); diff --git a/netkit-ftp-0.17-data.patch b/netkit-ftp-0.17-data.patch new file mode 100644 index 0000000000000000000000000000000000000000..43157f87742139ddf74176b23f8024745b2d525c --- /dev/null +++ b/netkit-ftp-0.17-data.patch @@ -0,0 +1,24 @@ +--- netkit-ftp-0.17/ftp/ftp.c.data 2005-12-02 15:31:27.000000000 +0100 ++++ netkit-ftp-0.17/ftp/ftp.c 2005-12-02 15:35:46.000000000 +0100 +@@ -1223,6 +1223,7 @@ + static int + initconn(void) + { ++ int rc; + u_char *p, *a; + int result, tmpno = 0; + socklen_t len; +@@ -1240,6 +1241,13 @@ + } + #endif + if (passivemode) { ++ if (data >= 0){ ++ rc = close (data); ++ data = -1; ++ if (rc == -1){ ++ perror ("ftp: close"); ++ } ++ } + data_addr = hisctladdr; + data = socket(data_addr.su_family, SOCK_STREAM, 0); + if (data < 0) { diff --git a/netkit-ftp-0.17-fdleak.patch b/netkit-ftp-0.17-fdleak.patch new file mode 100644 index 0000000000000000000000000000000000000000..0f995c5d4927d4978a8f89a23b88d64eb8e16e42 --- /dev/null +++ b/netkit-ftp-0.17-fdleak.patch @@ -0,0 +1,11 @@ +diff -up netkit-ftp-0.17/ftp/cmds.c.old netkit-ftp-0.17/ftp/cmds.c +--- netkit-ftp-0.17/ftp/cmds.c.old 2007-10-17 16:28:57.000000000 +0200 ++++ netkit-ftp-0.17/ftp/cmds.c 2007-10-17 16:33:41.000000000 +0200 +@@ -764,6 +764,7 @@ usage: + + recvrequest("RETR", argv[2], argv[1], modestr, + argv[1] != oldargv1 || argv[2] != oldargv2); ++ (void) close(data), data = -1; + restart_point = 0; + return (0); + } diff --git a/netkit-ftp-0.17-fprintf.patch b/netkit-ftp-0.17-fprintf.patch new file mode 100644 index 0000000000000000000000000000000000000000..f0c81e79787d4ecf4cc453bb15c178eb5f6e92f4 --- /dev/null +++ b/netkit-ftp-0.17-fprintf.patch @@ -0,0 +1,225 @@ +diff -up netkit-ftp-0.17/ftp/cmds.c.old netkit-ftp-0.17/ftp/cmds.c +--- netkit-ftp-0.17/ftp/cmds.c.old 2007-11-15 13:34:31.000000000 +0100 ++++ netkit-ftp-0.17/ftp/cmds.c 2007-11-15 13:44:44.000000000 +0100 +@@ -137,7 +137,7 @@ static char *pathprotect(char *name) + if (name[i]=='.' && gotdots>=0) gotdots++; + else if (name[i]=='/' && gotdots<0) gotdots=0; + else if (name[i]=='/' && gotdots==2) { +- printf("Warning: embedded .. in %.*s (changing to !!)\n", ++ fprintf(stderr, "Warning: embedded .. in %.*s (changing to !!)\n", + len-1, name); + name[i-1] = '!'; + name[i-2] = '!'; +@@ -167,7 +167,7 @@ another(int *pargc, char ***pargv, const + int ret; + + if (len >= sizeof(line) - 3) { +- printf("sorry, arguments too long\n"); ++ fprintf(stderr, "sorry, arguments too long\n"); + intr(0); + } + printf("(%s) ", prompt); +@@ -195,7 +195,7 @@ setpeer(int argc, char *argv[]) + char *port; + + if (connected) { +- printf("Already connected to %s, use close first.\n", ++ fprintf(stderr, "Already connected to %s, use close first.\n", + hostname); + code = -1; + return; +@@ -278,7 +278,7 @@ setpeer(int argc, char *argv[]) + unix_server = 0; + if (overbose && + !strncmp(reply_string, "215 TOPS20", 10)) +- printf( ++ fprintf(stderr, + "Remember to set tenex mode when transfering binary files from this machine.\n"); + } + verbose = overbose; +@@ -316,7 +316,7 @@ do_settype(const char *thetype) + if (strcmp(thetype, p->t_name) == 0) + break; + if (p->t_name == 0) { +- printf("%s: unknown mode\n", thetype); ++ fprintf(stderr, "%s: unknown mode\n", thetype); + code = -1; + return; + } +@@ -378,7 +378,7 @@ changetype(int newtype, int show) + if (newtype == p->t_type) + break; + if (p->t_name == 0) { +- printf("ftp: internal error: unknown type %d\n", newtype); ++ fprintf(stderr, "ftp: internal error: unknown type %d\n", newtype); + return; + } + if (newtype == TYPE_L && bytename[0] != '\0') +@@ -428,7 +428,7 @@ settenex(void) + void + setmode(void) + { +- printf("We only support %s mode, sorry.\n", modename); ++ fprintf(stderr, "We only support %s mode, sorry.\n", modename); + code = -1; + } + +@@ -439,7 +439,7 @@ setmode(void) + void + setform(void) + { +- printf("We only support %s format, sorry.\n", formname); ++ fprintf(stderr, "We only support %s format, sorry.\n", formname); + code = -1; + } + +@@ -449,7 +449,7 @@ setform(void) + void + setstruct(void) + { +- printf("We only support %s structure, sorry.\n", structname); ++ fprintf(stderr, "We only support %s structure, sorry.\n", structname); + code = -1; + } + +@@ -594,7 +594,7 @@ mput(int argc, char *argv[]) + } + gargs = ftpglob(argv[i]); + if (globerr != NULL) { +- printf("%s\n", globerr); ++ fprintf(stderr, "%s\n", globerr); + if (gargs) { + blkfree(gargs); + free((char *)gargs); +@@ -906,7 +906,7 @@ remglob(char *argv[], int doswitch) + umask(oldumask); + + if (fd<0) { +- printf("Error creating temporary file, oops\n"); ++ fprintf(stderr, "Error creating temporary file, oops\n"); + return NULL; + } + +@@ -931,13 +931,13 @@ remglob(char *argv[], int doswitch) + } + verbose = oldverbose; hash = oldhash; + if (badglob) { +- printf("Refusing to handle insecure file list\n"); ++ fprintf(stderr, "Refusing to handle insecure file list\n"); + close(fd); + return NULL; + } + ftemp = fdopen(fd, "r"); + if (ftemp == NULL) { +- printf("fdopen failed, oops\n"); ++ fprintf(stderr, "fdopen failed, oops\n"); + return NULL; + } + rewind(ftemp); +@@ -1006,7 +1006,7 @@ checkglob(int fd, const char *pattern) + while (*sp == '/') + sp++; + if (nrslash >= MAXPATHLEN) { +- printf("Incredible pattern: %s\n", pattern); ++ fprintf(stderr, "Incredible pattern: %s\n", pattern); + return 0; + } + dotdot[nrslash++] = isdotdotglob(sp); +@@ -1019,7 +1019,7 @@ checkglob(int fd, const char *pattern) + if ((sp = strchr(buffer, '\n')) != 0) { + *sp = '\0'; + } else { +- printf("Extremely long filename from server: %s", ++ fprintf(stderr, "Extremely long filename from server: %s", + buffer); + okay = 0; + break; +@@ -1038,7 +1038,7 @@ checkglob(int fd, const char *pattern) + } + + if (!okay) +- printf("Filename provided by server " ++ fprintf(stderr, "Filename provided by server " + "doesn't match pattern `%s': %s\n", pattern, buffer); + + fclose(fp); +@@ -1061,14 +1061,14 @@ status(void) + if (connected) + printf("Connected to %s.\n", hostname); + else +- printf("Not connected.\n"); ++ fprintf(stderr, "Not connected.\n"); + if (!proxy) { + pswitch(1); + if (connected) { + printf("Connected for proxy commands to %s.\n", hostname); + } + else { +- printf("No proxy connection.\n"); ++ fprintf(stderr, "No proxy connection.\n"); + } + pswitch(0); + } +@@ -1218,7 +1218,7 @@ setdebug(int argc, char *argv[]) + if (argc > 1) { + val = atoi(argv[1]); + if (val < 0) { +- printf("%s: bad debugging value.\n", argv[1]); ++ fprintf(stderr, "%s: bad debugging value.\n", argv[1]); + code = -1; + return; + } +@@ -1248,7 +1248,7 @@ cd(int argc, char *argv[]) + } + if (command("CWD %s", argv[1]) == ERROR && code == 500) { + if (verbose) +- printf("CWD command not recognized, trying XCWD\n"); ++ fprintf(stderr, "CWD command not recognized, trying XCWD\n"); + (void) command("XCWD %s", argv[1]); + } + } +@@ -1546,7 +1546,7 @@ user(int argc, char *argv[]) + aflag++; + } + if (n != COMPLETE) { +- fprintf(stdout, "Login failed.\n"); ++ fprintf(stderr, "Login failed.\n"); + return; + } + if (!aflag && argc == 4) { +@@ -1567,7 +1567,7 @@ pwd(void) + */ + verbose = 1; + if (command("PWD") == ERROR && code == 500) { +- printf("PWD command not recognized, trying XPWD\n"); ++ fprintf(stderr, "PWD command not recognized, trying XPWD\n"); + (void) command("XPWD"); + } + verbose = oldverbose; +@@ -1587,7 +1587,7 @@ makedir(int argc, char *argv[]) + } + if (command("MKD %s", argv[1]) == ERROR && code == 500) { + if (verbose) +- printf("MKD command not recognized, trying XMKD\n"); ++ fprintf(stderr, "MKD command not recognized, trying XMKD\n"); + (void) command("XMKD %s", argv[1]); + } + } +@@ -1606,7 +1606,7 @@ removedir(int argc, char *argv[]) + } + if (command("RMD %s", argv[1]) == ERROR && code == 500) { + if (verbose) +- printf("RMD command not recognized, trying XRMD\n"); ++ fprintf(stderr, "RMD command not recognized, trying XRMD\n"); + (void) command("XRMD %s", argv[1]); + } + } +@@ -2212,7 +2212,7 @@ cdup(void) + { + if (command("CDUP") == ERROR && code == 500) { + if (verbose) +- printf("CDUP command not recognized, trying XCUP\n"); ++ fprintf(stderr, "CDUP command not recognized, trying XCUP\n"); + (void) command("XCUP"); + } + } diff --git a/netkit-ftp-0.17-getlogin.patch b/netkit-ftp-0.17-getlogin.patch new file mode 100644 index 0000000000000000000000000000000000000000..9feb315925ac247e09b79cb9997d6cc27cb2498a --- /dev/null +++ b/netkit-ftp-0.17-getlogin.patch @@ -0,0 +1,37 @@ +--- netkit-ftp-0.17-dist/ftp/ftp.c 2012-10-02 14:44:06.328343277 +0200 ++++ netkit-ftp-0.17-new/ftp/ftp.c 2012-10-03 09:07:47.381868330 +0200 +@@ -328,14 +328,12 @@ dologin(const char *host) + return(0); + } + while (luser == NULL) { +- char *myname = getlogin(); ++ char *myname = NULL; + +- if (myname == NULL) { +- struct passwd *pp = getpwuid(getuid()); ++ struct passwd *pp = getpwuid(getuid()); + +- if (pp != NULL) +- myname = pp->pw_name; +- } ++ if (pp != NULL) ++ myname = pp->pw_name; + if (myname) + printf("Name (%s:%s): ", host, myname); + else +--- netkit-ftp-0.17-dist/ftp/main.c 2012-10-02 14:44:06.330343274 +0200 ++++ netkit-ftp-0.17-new/ftp/main.c 2012-10-03 09:07:36.849862227 +0200 +@@ -204,12 +204,7 @@ main(volatile int argc, char **volatile + /* + * Set up the home directory in case we're globbing. + */ +- cp = getlogin(); +- if (cp != NULL) { +- pw = getpwnam(cp); +- } +- if (pw == NULL) +- pw = getpwuid(getuid()); ++ pw = getpwuid(getuid()); + if (pw != NULL) { + strncpy(homedir, pw->pw_dir, sizeof(homedir)); + homedir[sizeof(homedir)-1] = 0; diff --git a/netkit-ftp-0.17-linelen-segfault.patch b/netkit-ftp-0.17-linelen-segfault.patch new file mode 100644 index 0000000000000000000000000000000000000000..a16db5855431925cfac12f6883e655dab023c02f --- /dev/null +++ b/netkit-ftp-0.17-linelen-segfault.patch @@ -0,0 +1,23 @@ +diff -up netkit-ftp-0.17/ftp/ftp.c.orig netkit-ftp-0.17/ftp/ftp.c +diff -up netkit-ftp-0.17/ftp/ftp_var.h.orig netkit-ftp-0.17/ftp/ftp_var.h +diff -up netkit-ftp-0.17/ftp/main.c.orig netkit-ftp-0.17/ftp/main.c +--- netkit-ftp-0.17/ftp/main.c.orig 2018-09-03 16:49:16.459000000 +0200 ++++ netkit-ftp-0.17/ftp/main.c 2018-09-03 17:00:14.853452345 +0200 +@@ -399,7 +399,7 @@ int slrflag; + char ** + makeargv(int *pargc, char **parg) + { +- static char *rargv[20]; ++ static char *rargv[LINELEN]; + int rargc = 0; + char **argp; + +@@ -407,7 +407,7 @@ makeargv(int *pargc, char **parg) + stringbase = line; /* scan from first of buffer */ + argbase = argbuf; /* store from first of buffer */ + slrflag = 0; +- while ((*argp++ = slurpstring())!=NULL) ++ while ((rargc < LINELEN) && (*argp++ = slurpstring())!=NULL) + rargc++; + + *pargc = rargc; diff --git a/netkit-ftp-0.17-linelen.patch b/netkit-ftp-0.17-linelen.patch new file mode 100644 index 0000000000000000000000000000000000000000..2e80a3f1d736afb152bb79f87ca1ce6c1714b7f5 --- /dev/null +++ b/netkit-ftp-0.17-linelen.patch @@ -0,0 +1,33 @@ +--- netkit-ftp-0.17-dist/ftp/ftp_var.h 2012-10-29 10:02:44.455342130 +0100 ++++ netkit-ftp-0.17-new/ftp/ftp_var.h 2012-10-29 10:02:31.292342775 +0100 +@@ -54,6 +54,7 @@ + #define Extern extern + #endif + ++#define LINELEN PATH_MAX+200 + + /* + * Options and other state info. +@@ -109,9 +110,9 @@ Extern int ftp_port; /* htons'd port num + + Extern sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */ + +-Extern char line[200]; /* input line buffer */ ++Extern char line[LINELEN]; /* input line buffer */ + Extern char *stringbase; /* current scan point in line buffer */ +-Extern char argbuf[200]; /* argument storage buffer */ ++Extern char argbuf[LINELEN]; /* argument storage buffer */ + Extern char *argbase; /* current storage point in arg buffer */ + Extern int cpend; /* flag: if != 0, then pending server reply */ + Extern int mflag; /* flag: if != 0, then active multi command */ +--- netkit-ftp-0.17/ftp/domacro.c 2012-10-29 10:02:44.394342130 +0100 ++++ netkit-ftp-0.17-new/ftp/domacro.c 2012-10-29 10:02:31.292342775 +0100 +@@ -53,7 +53,7 @@ domacro(int argc, char *argv[]) + register int i, j; + register char *cp1, *cp2; + int count = 2, loopflg = 0; +- char line2[200]; ++ char line2[LINELEN]; + struct cmd *c; + + if (argc < 2 && !another(&argc, &argv, "macro name")) { diff --git a/netkit-ftp-0.17-longint.patch b/netkit-ftp-0.17-longint.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7b9f91d1d10ebdfadd3cf038e65b8ab87d1d047 --- /dev/null +++ b/netkit-ftp-0.17-longint.patch @@ -0,0 +1,135 @@ +--- netkit-ftp-0.17/ftp/ftp.c.rasold 2005-08-22 14:22:50.000000000 +0200 ++++ netkit-ftp-0.17/ftp/ftp.c 2005-08-22 14:23:02.000000000 +0200 +@@ -139,7 +139,7 @@ + static char *gunique(char *); + static void proxtrans(const char *cmd, char *local, char *remote); + static int initconn(void); +-static void ptransfer(const char *direction, long bytes, ++static void ptransfer(const char *direction, long long bytes, + const struct timeval *t0, + const struct timeval *t1); + static void tvsub(struct timeval *tdiff, +@@ -579,7 +579,7 @@ + int (*volatile closefunc)(FILE *); + void (*volatile oldintr)(int); + void (*volatile oldintp)(int); +- volatile long bytes = 0, hashbytes = HASHBYTES; ++ volatile long long bytes = 0, hashbytes = HASHBYTES; + char buf[BUFSIZ], *bufp; + const char *volatile lmode; + +@@ -713,14 +713,14 @@ + if ((d = write(fileno(dout), bufp, c)) <= 0) + break; + if (hash) { +- while (bytes >= hashbytes) { +- (void) putchar('#'); +- hashbytes += HASHBYTES; +- } +- (void) fflush(stdout); +- } ++ while (bytes >= hashbytes) { /* <-- 'long long' signed overflow is */ ++ (void) putchar('#'); /* possible. In this case, we can */ ++ hashbytes += HASHBYTES; /* 'cycle' there for very long time. */ ++ } /* Search 'hasbytes' in file down, */ ++ (void) fflush(stdout); /* there are similar parts. */ ++ } /* */ + if (tick && (bytes >= hashbytes)) { +- printf("\rBytes transferred: %ld", bytes); ++ printf("\rBytes transferred: %lld", bytes); + (void) fflush(stdout); + while (bytes >= hashbytes) + hashbytes += TICKBYTES; +@@ -733,7 +733,7 @@ + (void) fflush(stdout); + } + if (tick) { +- (void) printf("\rBytes transferred: %ld\n", bytes); ++ (void) printf("\rBytes transferred: %lld\n", bytes); + (void) fflush(stdout); + } + if (c < 0) +@@ -755,7 +755,7 @@ + hashbytes += HASHBYTES; + } + if (tick && (bytes >= hashbytes)) { +- (void) printf("\rBytes transferred: %ld", ++ (void) printf("\rBytes transferred: %lld", + bytes); + (void) fflush(stdout); + while (bytes >= hashbytes) +@@ -780,7 +780,7 @@ + (void) fflush(stdout); + } + if (tick) { +- (void) printf("\rBytes transferred: %ld\n", bytes); ++ (void) printf("\rBytes transferred: %lld\n", bytes); + (void) fflush(stdout); + } + if (ferror(fin)) +@@ -853,9 +853,9 @@ + void (*volatile oldintp)(int); + void (*volatile oldintr)(int); + volatile int is_retr, tcrflag, bare_lfs = 0; +- static unsigned bufsize; ++ static unsigned bufsize=0; + static char *buf; +- volatile long bytes = 0, hashbytes = HASHBYTES; ++ volatile long long bytes = 0, hashbytes = HASHBYTES; + register int c, d; + struct timeval start, stop; + struct stat st; +@@ -1031,7 +1031,7 @@ + (void) fflush(stdout); + } + if (tick && (bytes >= hashbytes) && is_retr) { +- (void) printf("\rBytes transferred: %ld", ++ (void) printf("\rBytes transferred: %lld", + bytes); + (void) fflush(stdout); + while (bytes >= hashbytes) +@@ -1045,7 +1045,7 @@ + (void) fflush(stdout); + } + if (tick && is_retr) { +- (void) printf("\rBytes transferred: %ld\n", bytes); ++ (void) printf("\rBytes transferred: %lld\n", bytes); + (void) fflush(stdout); + } + if (c < 0) { +@@ -1095,7 +1095,7 @@ + hashbytes += HASHBYTES; + } + if (tick && (bytes >= hashbytes) && is_retr) { +- printf("\rBytes transferred: %ld", ++ printf("\rBytes transferred: %lld", + bytes); + fflush(stdout); + while (bytes >= hashbytes) +@@ -1126,7 +1126,7 @@ + (void) fflush(stdout); + } + if (tick && is_retr) { +- (void) printf("\rBytes transferred: %ld\n", bytes); ++ (void) printf("\rBytes transferred: %lld\n", bytes); + (void) fflush(stdout); + } + if (bare_lfs) { +@@ -1540,7 +1540,7 @@ + } + + static void +-ptransfer(const char *direction, long bytes, ++ptransfer(const char *direction, long long bytes, + const struct timeval *t0, + const struct timeval *t1) + { +@@ -1552,7 +1552,7 @@ + s = td.tv_sec + (td.tv_usec / 1000000.); + #define nz(x) ((x) == 0 ? 1 : (x)) + bs = bytes / nz(s); +- printf("%ld bytes %s in %.3g secs (%.2g Kbytes/sec)\n", ++ printf("%lld bytes %s in %.3g secs (%.2g Kbytes/sec)\n", + bytes, direction, s, bs / 1024.0); + } + } diff --git a/netkit-ftp-0.17-lsn-timeout.patch b/netkit-ftp-0.17-lsn-timeout.patch new file mode 100644 index 0000000000000000000000000000000000000000..561ccdbba71bbb8ed8960452daa75c5597e91bd1 --- /dev/null +++ b/netkit-ftp-0.17-lsn-timeout.patch @@ -0,0 +1,24 @@ +--- netkit-ftp-0.17/ftp/ftp.c.to 2012-08-10 15:49:08.510257542 +0200 ++++ netkit-ftp-0.17/ftp/ftp.c 2012-08-10 15:49:32.386220785 +0200 +@@ -1245,6 +1245,10 @@ initconn(void) + u_int ad[16], po[2], af, alen, plen; + char *pasvcmd = NULL; + char hbuf[MAXHOSTNAMELEN], pbuf[NI_MAXSERV]; ++ struct timeval timeout; ++ ++ timeout.tv_sec = 30; ++ timeout.tv_usec = 0; + + #ifdef INET6 + if (myctladdr.su_family == AF_INET6 +@@ -1486,6 +1490,10 @@ noport: + perror("ftp: setsockopt (reuse address)"); + goto bad; + } ++ if (setsockopt (data, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, ++ sizeof(timeout)) < 0) { ++ perror("ftp: setsockopt failed\n"); ++ } + if (bind(data, (struct sockaddr *)&data_addr, sizeof (data_addr)) < 0) { + perror("ftp: bind"); + goto bad; diff --git a/netkit-ftp-0.17-man.patch b/netkit-ftp-0.17-man.patch new file mode 100644 index 0000000000000000000000000000000000000000..13bc0a62ca1a5392e8ad9c90481e32424e0bba98 --- /dev/null +++ b/netkit-ftp-0.17-man.patch @@ -0,0 +1,30 @@ +diff -up netkit-ftp-0.17/ftp/ftp.1.man netkit-ftp-0.17/ftp/ftp.1 +--- netkit-ftp-0.17/ftp/ftp.1.man 2011-03-29 09:35:52.588039000 +0200 ++++ netkit-ftp-0.17/ftp/ftp.1 2011-03-29 09:36:45.365651621 +0200 +@@ -197,7 +197,7 @@ current remote machine working directory + Change the permission modes of the file + .Ar file-name + on the remote +-sytem to ++system to + .Ar mode . + .It Ic close + Terminate the +@@ -342,7 +342,7 @@ Set the inactivity timer on the remote s + seconds. + If + .Ar seconds +-is ommitted, the current inactivity timer is printed. ++is omitted, the current inactivity timer is printed. + .It Ic lcd Op Ar directory + Change the working directory on the local machine. + If +@@ -850,7 +850,7 @@ Set the default umask on the remote serv + .Ar newmask . + If + .Ar newmask +-is ommitted, the current umask is printed. ++is omitted, the current umask is printed. + .It Xo + .Ic user Ar user-name + .Op Ar password diff --git a/netkit-ftp-0.17-out-of-memory.patch b/netkit-ftp-0.17-out-of-memory.patch new file mode 100644 index 0000000000000000000000000000000000000000..7fe56163053dbfaf53201d780c6c3833e4a19163 --- /dev/null +++ b/netkit-ftp-0.17-out-of-memory.patch @@ -0,0 +1,29 @@ +diff -up netkit-ftp-0.17/ftp/glob.c.arg_max1 netkit-ftp-0.17/ftp/glob.c +--- netkit-ftp-0.17/ftp/glob.c.arg_max1 2012-01-24 12:59:09.335021131 +0100 ++++ netkit-ftp-0.17/ftp/glob.c 2012-01-24 13:05:27.752028732 +0100 +@@ -55,10 +55,15 @@ char glob_rcsid[] = + #include "ftp_var.h" /* for protos only */ + #include "glob.h" + ++#ifndef LOWEST_ARG_MAX ++ #define LOWEST_ARG_MAX 2621440 /* ARG_MAX for default stack size limit 10240 */ ++#endif ++ + #define QUOTE 0200 + #define TRIM 0177 + #define eq(a,b) (strcmp(a, b)==0) +-#define GAVSIZ (sysconf(_SC_ARG_MAX)/6) ++#define max(a,b) (a > b ? a : b) ++#define GAVSIZ (max((int)sysconf(_SC_ARG_MAX), LOWEST_ARG_MAX)/6) + #define isdir(d) ((d.st_mode & S_IFMT) == S_IFDIR) + + const char *globerr; +@@ -159,7 +164,7 @@ ginit(entry *agargv) + gargv = agargv; + sortbas = agargv; + gargc = 0; +- gnleft = sysconf(_SC_ARG_MAX) - 4; ++ gnleft = max((int)sysconf(_SC_ARG_MAX), LOWEST_ARG_MAX) - 4; + } + + static diff --git a/netkit-ftp-0.17-printf.patch b/netkit-ftp-0.17-printf.patch new file mode 100644 index 0000000000000000000000000000000000000000..2d7ecc4cde713c325cfa595e45e0cd5b4c9c1121 --- /dev/null +++ b/netkit-ftp-0.17-printf.patch @@ -0,0 +1,11 @@ +--- netkit-ftp-0.17/ftp/cmds.c.printf 2005-05-24 22:12:24.000000000 +0200 ++++ netkit-ftp-0.17/ftp/cmds.c 2005-05-24 22:12:37.000000000 +0200 +@@ -2223,7 +2223,7 @@ + printf("restart: offset not specified\n"); + else { + restart_point = atol(argv[1]); +- printf("restarting at %ld. %s\n", restart_point, ++ printf("restarting at %ld. %s\n", (long)restart_point, + "execute get, put or append to initiate transfer"); + } + } diff --git a/netkit-ftp-0.17-remove-nested-include.patch b/netkit-ftp-0.17-remove-nested-include.patch new file mode 100644 index 0000000000000000000000000000000000000000..97cf1360c746f3ba8fd3ae0e1b2c4f66f6e117a2 --- /dev/null +++ b/netkit-ftp-0.17-remove-nested-include.patch @@ -0,0 +1,18 @@ +--- netkit-ftp-0.17/ftp/ftp.c 2012-07-20 07:55:48.545151322 +0200 ++++ netkit-ftp-0.17-new/ftp/ftp.c 2012-07-20 08:05:07.941468914 +0200 +@@ -74,6 +74,7 @@ char ftp_rcsid[] = + #include + #include + #include ++#include + + #include + #include +@@ -820,7 +821,6 @@ sendrequest(const char *cmd, char *local + /* It can be later removed. */ + if (old_code_l == 150 && code == 150 && cpend == 1 + && sunique == 1 && cin != NULL && fileno (cin) >= 0 ) { +- #include + struct pollfd fds_events_l [2] ; + int rc; + diff --git a/netkit-ftp-0.17-runique_mget.patch b/netkit-ftp-0.17-runique_mget.patch new file mode 100644 index 0000000000000000000000000000000000000000..8ba1152deea7b1570f0cc3ee442a6cfdcd74cfc2 --- /dev/null +++ b/netkit-ftp-0.17-runique_mget.patch @@ -0,0 +1,13 @@ +--- netkit-ftp-0.17/ftp/ftp.c.runique_mget 2004-12-07 12:05:49.360133092 +0100 ++++ netkit-ftp-0.17/ftp/ftp.c 2004-12-07 12:06:48.480883902 +0100 +@@ -923,7 +923,9 @@ + return; + } + } +- else if (runique && (local = gunique(local)) == NULL) { ++ else if (runique && (strcmp(cmd, "NLST") != 0) && ++ (local = gunique(local)) == NULL) ++ { + (void) signal(SIGINT, oldintr); + code = -1; + return; diff --git a/netkit-ftp-0.17-segv.patch b/netkit-ftp-0.17-segv.patch new file mode 100644 index 0000000000000000000000000000000000000000..12d59608d57090e63a4a6689d54f2db1dfecb266 --- /dev/null +++ b/netkit-ftp-0.17-segv.patch @@ -0,0 +1,82 @@ +--- netkit-ftp-0.17/ftp/ftp.c.segv 2004-06-14 11:04:38.000000000 -0400 ++++ netkit-ftp-0.17/ftp/ftp.c 2004-06-14 11:06:46.000000000 -0400 +@@ -472,6 +472,8 @@ + return (0); + } + lostpeer(0); ++ fclose(cout); ++ cout = NULL; + if (verbose) { + printf("421 Service not available, remote server has closed connection\n"); + (void) fflush(stdout); +@@ -529,7 +531,14 @@ + cpend = 0; + (void) signal(SIGINT,oldintr); + if (code == 421 || originalcode == 421) ++ { + lostpeer(0); ++ if(cout) ++ { ++ fclose(cout); ++ cout = NULL; ++ } ++ } + if (abrtflag && oldintr != cmdabort && oldintr != SIG_IGN) + (*oldintr)(SIGINT); + return (n - '0'); +@@ -1790,6 +1799,11 @@ + if (ptabflg) + code = -1; + lostpeer(0); ++ if(cout != NULL) ++ { ++ fclose(cout); ++ cout = NULL; ++ } + } + (void) getreply(0); + (void) getreply(0); +@@ -1815,6 +1829,11 @@ + perror("reset"); + code = -1; + lostpeer(0); ++ if(cout != NULL) ++ { ++ fclose(cout); ++ cout = NULL; ++ } + } + else if (nfnd) { + (void) getreply(0); +@@ -1897,6 +1916,11 @@ + if (ptabflg) + code = -1; + lostpeer(0); ++ if(cout != NULL) ++ { ++ fclose(cout); ++ cout = NULL; ++ } + } + if (din && FD_ISSET(fileno(din), &mask)) { + while (read(fileno(din), buf, BUFSIZ) > 0) +--- netkit-ftp-0.17/ftp/main.c.segv 2004-06-14 11:03:18.000000000 -0400 ++++ netkit-ftp-0.17/ftp/main.c 2004-06-14 11:03:42.000000000 -0400 +@@ -235,8 +235,6 @@ + if (connected) { + if (cout != NULL) { + shutdown(fileno(cout), 1+1); +- fclose(cout); +- cout = NULL; + } + if (data >= 0) { + shutdown(data, 1+1); +@@ -249,8 +247,6 @@ + if (connected) { + if (cout != NULL) { + shutdown(fileno(cout), 1+1); +- fclose(cout); +- cout = NULL; + } + connected = 0; + } diff --git a/netkit-ftp-0.17-sigseg.patch b/netkit-ftp-0.17-sigseg.patch new file mode 100644 index 0000000000000000000000000000000000000000..0972eb19513d8199897e29992fdca4cefd38909c --- /dev/null +++ b/netkit-ftp-0.17-sigseg.patch @@ -0,0 +1,16 @@ +--- netkit-ftp-0.17-orig/ftp/ftp.c 2007-08-06 23:32:49.000000000 +0200 ++++ netkit-ftp-0.17/ftp/ftp.c 2007-08-06 23:31:06.000000000 +0200 +@@ -483,8 +483,10 @@ getreply(int expecteof) + return (0); + } + lostpeer(0); +- fclose(cout); +- cout = NULL; ++ if (cout) { ++ fclose(cout); ++ cout = NULL; ++ } + if (verbose) { + printf("421 Service not available, remote server has closed connection\n"); + (void) fflush(stdout); + diff --git a/netkit-ftp-0.17-size.patch b/netkit-ftp-0.17-size.patch new file mode 100644 index 0000000000000000000000000000000000000000..22e08069f604dd23f2a08cb5e3c7fd3e8fa08ded --- /dev/null +++ b/netkit-ftp-0.17-size.patch @@ -0,0 +1,12 @@ +diff -up netkit-ftp-0.17/ftp/cmds.c.size netkit-ftp-0.17/ftp/cmds.c +--- netkit-ftp-0.17/ftp/cmds.c.size 2007-10-10 14:17:18.000000000 +0200 ++++ netkit-ftp-0.17/ftp/cmds.c 2007-10-10 14:17:18.000000000 +0200 +@@ -1650,6 +1650,8 @@ quote1(const char *initial, int argc, ch + register int i, len; + char buf[BUFSIZ]; /* must be >= sizeof(line) */ + ++ if (strncmp(argv[1],"size",4) == 0) ++ changetype(TYPE_I, 1); + (void) strcpy(buf, initial); + if (argc > 1) { + len = strlen(buf); diff --git a/netkit-ftp-0.17-token.patch b/netkit-ftp-0.17-token.patch new file mode 100644 index 0000000000000000000000000000000000000000..d8883009b84da18b311c094afe26f5d72313b66b --- /dev/null +++ b/netkit-ftp-0.17-token.patch @@ -0,0 +1,75 @@ +diff -rup netkit-ftp-0.17/ftp/ruserpass.c netkit-ftp-0.17-new/ftp/ruserpass.c +--- netkit-ftp-0.17/ftp/ruserpass.c 2012-10-29 15:11:10.593841089 +0100 ++++ netkit-ftp-0.17-new/ftp/ruserpass.c 2012-10-29 15:13:14.379822697 +0100 +@@ -58,7 +58,8 @@ static int token(void); + #define ID 10 + #define MACH 11 + +-static char tokval[100]; ++#define MAXTOKENLEN 4096 ++static char tokval[MAXTOKENLEN]; + + static struct toktab { + const char *tokstr; +@@ -249,13 +250,16 @@ bad: + return(-1); + } + +-static ++static + int + token(void) + { + char *cp; + int c; + struct toktab *t; ++ size_t toklen = 0; ++ int showwarn = 1; ++ int quote = 0; + + if (feof(cfile)) + return (0); +@@ -266,20 +270,32 @@ token(void) + return (0); + cp = tokval; + if (c == '"') { +- while ((c = getc(cfile)) != EOF && c != '"') { +- if (c == '\\') +- c = getc(cfile); +- *cp++ = c; +- } +- } else { ++ quote = 1; ++ } ++ else { + *cp++ = c; +- while ((c = getc(cfile)) != EOF +- && c != '\n' && c != '\t' && c != ' ' && c != ',') { +- if (c == '\\') +- c = getc(cfile); +- *cp++ = c; ++ toklen++; ++ } ++ while ((c = getc(cfile)) != EOF) { ++ if (c == '"') ++ break; ++ if (c == '\\') ++ c = getc(cfile); ++ if (!quote && (c == '\n' || c == '\t' || c == ' ' || c == ',')) ++ break; ++ if (toklen >= MAXTOKENLEN) { ++ if (showwarn) { ++ fprintf(stderr, ++ "Warning: .netrc token too long, will be trunctated to %zd characters\n", ++ toklen); ++ showwarn = 0; ++ } ++ continue; + } ++ *cp++ = c; ++ toklen++; + } ++ + *cp = 0; + if (tokval[0] == 0) + return (0); diff --git a/netkit-ftp-0.17-volatile.patch b/netkit-ftp-0.17-volatile.patch new file mode 100644 index 0000000000000000000000000000000000000000..e7a3431ef9e72f93059289b6af9c5c7ef9bc2ee2 --- /dev/null +++ b/netkit-ftp-0.17-volatile.patch @@ -0,0 +1,39 @@ +--- netkit-ftp-0.17/configure.volatile 2004-06-14 12:08:26.000000000 -0400 ++++ netkit-ftp-0.17/configure 2004-06-14 12:52:41.000000000 -0400 +@@ -193,8 +193,8 @@ + cat <__conftest.c + #include + #include +-int count=0; +-void handle(int foo) { count++; } ++volatile int count=0; ++void handle(int foo) { count++; write(1,"X",1);} + int main() { + int pid=getpid(); + signal(SIGINT, handle); +@@ -209,20 +209,20 @@ + if ( + $CC $CFLAGS __conftest.c -o __conftest || exit 1 + ./__conftest || exit 1 +- ) >/dev/null 2>&1; then ++ ); then + echo 'yes' + else + if ( + $CC $CFLAGS -D__USE_BSD_SIGNAL __conftest.c -o __conftest || exit 1 + ./__conftest || exit 1 +- ) >/dev/null 2>&1; then ++ ); then + echo '-D__USE_BSD_SIGNAL' + CFLAGS="$CFLAGS -D__USE_BSD_SIGNAL" + else + echo 'no' +- echo 'This package needs BSD signal semantics to run.' +- rm -f __conftest* +- exit ++ echo '***WARNING***: This package needs BSD signal semantics to run.' ++ echo '***WARNING***: Assuming its just ia64 buildroot breakage.' ++ CFLAGS="$CFLAGS -D__USE_BSD_SIGNAL" + fi + fi + rm -f __conftest* diff --git a/netkit-ftp-0.17-vsftp165083.patch b/netkit-ftp-0.17-vsftp165083.patch new file mode 100644 index 0000000000000000000000000000000000000000..8dcd9057b459f3096bced1723fababdceedca01d --- /dev/null +++ b/netkit-ftp-0.17-vsftp165083.patch @@ -0,0 +1,47 @@ +--- netkit-ftp-0.17/ftp/ftp.c.vsftp 2005-08-29 16:07:35.000000000 +0200 ++++ netkit-ftp-0.17/ftp/ftp.c 2005-08-30 10:58:10.000000000 +0200 +@@ -582,6 +582,7 @@ + volatile long long bytes = 0, hashbytes = HASHBYTES; + char buf[BUFSIZ], *bufp; + const char *volatile lmode; ++ int old_code_l; + + if (verbose && printnames) { + if (local && *local != '-') +@@ -799,7 +800,35 @@ + (void) fclose(dout); + /* closes data as well, so discard it */ + data = -1; +- (void) getreply(0); ++ old_code_l = code; ++ (void) getreply(0); ++ ++ /* Following "if" will avoid a bug #165083 in ftp-server */ ++ /* It can be later removed. */ ++ if (old_code_l == 150 && code == 150 && cpend == 1 ++ && sunique == 1 && cin != NULL && fileno (cin) >= 0 ) { ++ #include ++ struct pollfd fds_events_l [2] ; ++ int rc; ++ ++ fds_events_l [0] .fd = fileno (cin); ++ fds_events_l [0] .events = POLLIN | POLLERR | POLLHUP; ++ ++ rc = poll (fds_events_l, 1, 5000); ++ switch (rc) { ++ case 1: ++ (void) getreply (0); ++ break; ++ case 0: ++ fprintf (stderr, "ftp: no answer from ftp-server " ++ "(more than 5 sec).\n"); ++ break; ++ case -1: ++ perror("ftp: poll"); ++ break; ++ } ++ } ++ + (void) signal(SIGINT, oldintr); + if (oldintp) + (void) signal(SIGPIPE, oldintp);