new file mode 100644
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@zytor.com>
+Date: Mon, 12 Oct 2026 13:50:12 -0700
+Subject: [PATCH] autoconf: add AC_CONFIG_MACRO_DIRS for autoreconf benefit
+
+The official way to build configure is with the included "autogen.sh"
+script, but this way "autoreconf" works too.
+
+Reported-by: Xose Vazquez Perez <xose.vazquez@gmail.com>
+Fixes: https://github.com/hpax/tftp-hpa/issues/5
+Signed-off-by: H. Peter Anvin <hpa@zytor.com>
+
+Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/tftp/tftp-hpa.git/commit/?id=563db263a5fe38c7eaf26207e8f0f501e44989c0]
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ configure.ac | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/configure.ac b/configure.ac
+index 62d0607..3e909f2 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -11,6 +11,7 @@ AC_INIT
+ AC_CONFIG_SRCDIR([MRULES])
+ AC_PREFIX_DEFAULT([/usr])
+ AC_CONFIG_AUX_DIR([autoconf/helpers])
++AC_CONFIG_MACRO_DIRS([autoconf/m4])
+
+ dnl This prevents us from running Wine and thinking we are not
+ dnl cross-compiling when in fact we are; running Wine here is at
new file mode 100644
@@ -0,0 +1,36 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@zytor.com>
+Date: Mon, 12 Oct 2026 13:56:54 -0700
+Subject: [PATCH] Fix autoconf test for off_t
+
+AC_TYPE_OFF_T *defines* off_t if it doesn't exist, so testing for a
+HAVE_OFF_T variable is plain wrong. It just happened to work on LP64
+systems...
+
+Reported-by: Chris Hofstaedtler <zeha@github.com>
+Fixes: https://github.com/hpax/tftp-hpa/issues/9
+Fixes: https://github.com/hpax/tftp-hpa/issues/10
+Signed-off-by: H. Peter Anvin <hpa@zytor.com>
+
+Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/tftp/tftp-hpa.git/commit/?id=0659f23cbbf8a853a82cd4117795a519900fba41]
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ config.h | 5 +----
+ 1 file changed, 1 insertion(+), 4 deletions(-)
+
+diff --git a/config.h b/config.h
+index 40114d0..a28f7bc 100644
+--- a/config.h
++++ b/config.h
+@@ -309,10 +309,7 @@ static inline void *mempcpy(void *dst, const void *src, size_t n)
+ #define TYPE_MAX(t) TYPE_MKMASK(t, (t)1 << (sizeof(t)*CHAR_BIT-1-IS_SIGNED(t)))
+ #define TYPE_MIN(t) ((t)~TYPE_MAX(t))
+
+-/* off_t and OFF_T_MAX */
+-#ifndef HAVE_OFF_T
+-typedef long off_t;
+-#endif
++/* If OFF_T_MAX isn't defined */
+ #ifndef OFF_T_MAX
+ #define OFF_T_MAX TYPE_MAX(off_t)
+ #endif
new file mode 100644
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: "H. Peter Anvin" <hpa@zytor.com>
+Date: Mon, 12 Oct 2026 14:01:57 -0700
+Subject: [PATCH] tftp: fix type of r_timeout
+
+r_timeout should be uintmax_t, not unsigned long. This would break
+compiling on 32-bit platforms.
+
+Reported-by: Chris Hofstaedtler <zeha@github.com>
+Fixes: https://github.com/hpax/tftp-hpa/issues/9
+Signed-off-by: H. Peter Anvin <hpa@zytor.com>
+
+Upstream-Status: Backport [https://git.kernel.org/pub/scm/network/tftp/tftp-hpa.git/commit/?id=f2d2b5d88ca3f329abe32f6366eae78a2ccb0ae7]
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ tftp/tftp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tftp/tftp.c b/tftp/tftp.c
+index 2fd4bdf..964bf5c 100644
+--- a/tftp/tftp.c
++++ b/tftp/tftp.c
+@@ -280,7 +280,7 @@ int tftp_sendfile(int fd, const char *name, const char *mode)
+ bool convert = !strcmp(mode, "netascii");
+ struct optreq optreq, optack;
+ uint16_t ap_opcode, ap_block;
+- unsigned long r_timeout;
++ uintmax_t r_timeout;
+ volatile uintmax_t amount = 0;
+ struct stat st;
+
new file mode 100644
@@ -0,0 +1,28 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Chris Hofstaedtler <zeha@debian.org>
+Date: Tue, 13 Oct 2026 13:14:11 +0200
+Subject: [PATCH] tftp: fix type of r_timeout
+
+Same as f2d2b5d88ca3f329abe32f6366eae78a2ccb0ae7 but in tftp_recv_file
+
+Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
+
+Upstream-Status: Backport [https://github.com/hpax/tftp-hpa/commit/088dfef0979e7e5364c586b60ea49c8fbd3a679d]
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ tftp/tftp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/tftp/tftp.c b/tftp/tftp.c
+index 964bf5c..a28ed9c 100644
+--- a/tftp/tftp.c
++++ b/tftp/tftp.c
+@@ -448,7 +448,7 @@ int tftp_recvfile(int fd, const char *name, const char *mode)
+ bool convert = !strcmp(mode, "netascii");
+ struct optreq optreq, optack;
+ uint16_t opcode;
+- unsigned long r_timeout;
++ uintmax_t r_timeout;
+ volatile uintmax_t amount = 0;
+
+ optreq_init(&optreq);
deleted file mode 100644
@@ -1,81 +0,0 @@
-From 0b89c5bd9723ebd5207590016a14e5f2c6a0bdc9 Mon Sep 17 00:00:00 2001
-From: "Roy.Li" <rongqing.li@windriver.com>
-Date: Thu, 22 Aug 2013 08:56:09 +0800
-Subject: [PATCH] tftp-hpa: add error check for disk filled up
-
-Add error check when the write-buffer is finally flushed to the file,
-the caller can detect if the disk filled up (or had an i/o error) and
-return a NOSAPCE nak to the other side.
-
-Upstream-Status: Submitted [http://www.syslinux.org/archives/2013-August/020765.html]
-
-Signed-off-by: Ming Liu <ming.liu@windriver.com>
-Signed-off-by: Roy.Li <rongqing.li@windriver.com>
----
- common/tftpsubs.c | 8 +++++---
- tftpd/tftpd.c | 12 ++++++++++--
- 2 files changed, 15 insertions(+), 5 deletions(-)
-
-diff --git a/common/tftpsubs.c b/common/tftpsubs.c
-index 8c999f6..b4d4ffe 100644
---- a/common/tftpsubs.c
-+++ b/common/tftpsubs.c
-@@ -206,20 +206,22 @@ int write_behind(FILE * file, int convert)
-
- p = buf;
- ct = count;
-+ count = 0;
- while (ct--) { /* loop over the buffer */
- c = *p++; /* pick up a character */
- if (prevchar == '\r') { /* if prev char was cr */
- if (c == '\n') /* if have cr,lf then just */
-- fseek(file, -1, 1); /* smash lf on top of the cr */
-+ count = count - 1;
- else if (c == '\0') /* if have cr,nul then */
- goto skipit; /* just skip over the putc */
- /* else just fall through and allow it */
- }
-- putc(c, file);
-+ buf[count] = c;
-+ count ++;
- skipit:
- prevchar = c;
- }
-- return count;
-+ return write(fileno(file), buf, count);
- }
-
- /* When an error has occurred, it is possible that the two sides
-diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
-index 3158c6d..001237b 100644
---- a/tftpd/tftpd.c
-+++ b/tftpd/tftpd.c
-@@ -1690,7 +1690,11 @@ static void tftp_recvfile(const struct formats *pf, struct tftphdr *oap, int oac
- syslog(LOG_WARNING, "tftpd: write(ack): %m");
- goto abort;
- }
-- write_behind(file, pf->f_convert);
-+ if(write_behind(file, pf->f_convert) < 0) {
-+ nak(ENOSPACE, NULL);
-+ (void)fclose(file);
-+ goto abort;
-+ }
- for (;;) {
- n = recv_time(peer, dp, PKTSIZE, 0, &r_timeout);
- if (n < 0) { /* really? */
-@@ -1721,7 +1725,11 @@ static void tftp_recvfile(const struct formats *pf, struct tftphdr *oap, int oac
- goto abort;
- }
- } while (size == segsize);
-- write_behind(file, pf->f_convert);
-+ if(write_behind(file, pf->f_convert) < 0) {
-+ nak(ENOSPACE, NULL);
-+ (void)fclose(file);
-+ goto abort;
-+ }
- (void)fclose(file); /* close data file */
-
- ap->th_opcode = htons((u_short) ACK); /* send the "final" ack */
-2.34.1
-
deleted file mode 100644
@@ -1,42 +0,0 @@
-From 1ce974f1cf6afbc528c941a8cdf0817a3fd7c5a7 Mon Sep 17 00:00:00 2001
-From: "Roy.Li" <rongqing.li@windriver.com>
-Date: Mon, 30 Mar 2026 22:37:22 +0800
-Subject: [PATCH] fix the empty file writting
-
-With the feature that checking the disk filled up, the return
-value of function write_behind was checked and used to detect
-the disk status. While for empty file, without data being
-written, this function will return -1 thus the disk filled up
-error was miss-raised.
-
-make write_behind to return 0 if written file is empty, to fix
-the this bug.
-
-Upstream-Status: Pending
-
-Signed-off-by: Roy.Li <rongqing.li@windriver.com>
----
- common/tftpsubs.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
-
-diff --git a/common/tftpsubs.c b/common/tftpsubs.c
-index b4ea3f2..30e749a 100644
---- a/common/tftpsubs.c
-+++ b/common/tftpsubs.c
-@@ -198,9 +198,12 @@ int write_behind(FILE * file, int convert)
- nextone = !nextone; /* incr for next time */
- buf = dp->th_data;
-
-- if (count <= 0)
-+ if (count < 0)
- return -1; /* nak logic? */
-
-+ if (count == 0)
-+ return 0;
-+
- if (convert == 0)
- return write(fileno(file), buf, count);
-
-2.34.1
-
deleted file mode 100644
@@ -1,25 +0,0 @@
-Patch originally from Fedora
-
-https://src.fedoraproject.org/rpms/tftp.git
-
-Upstream-Status: Pending
-
-diff -up tftp-hpa-0.49/tftpd/remap.c.zero tftp-hpa-0.49/tftpd/remap.c
---- tftp-hpa-0.49/tftpd/remap.c.zero 2008-10-20 18:08:31.000000000 -0400
-+++ tftp-hpa-0.49/tftpd/remap.c 2008-11-25 11:41:09.000000000 -0500
-@@ -286,6 +286,7 @@ struct rule *parserulefile(FILE * f)
- int lineno = 0;
- int err = 0;
-
-+ memset(this_rule, '\0', sizeof(struct rule));
- while (lineno++, fgets(line, MAXLINE, f)) {
- rv = parseline(line, this_rule, lineno);
- if (rv < 0)
-@@ -294,6 +295,7 @@ struct rule *parserulefile(FILE * f)
- *last_rule = this_rule;
- last_rule = &this_rule->next;
- this_rule = tfmalloc(sizeof(struct rule));
-+ memset(this_rule, '\0', sizeof(struct rule));
- }
- }
-
deleted file mode 100644
@@ -1,60 +0,0 @@
-Patch originally from Fedora
-
-https://src.fedoraproject.org/rpms/tftp.git
-
-Upstream-Status: Pending
-
-diff -up tftp-hpa-0.48/tftp-xinetd.tftpboot tftp-hpa-0.48/tftp-xinetd
---- tftp-hpa-0.48/tftp-xinetd.tftpboot 2007-01-31 00:51:05.000000000 +0100
-+++ tftp-hpa-0.48/tftp-xinetd 2008-05-20 12:05:53.000000000 +0200
-@@ -10,7 +10,7 @@ service tftp
- wait = yes
- user = root
- server = /usr/sbin/in.tftpd
-- server_args = -s /tftpboot
-+ server_args = -s /var/lib/tftpboot
- disable = yes
- per_source = 11
- cps = 100 2
-diff -up tftp-hpa-0.48/README.security.tftpboot tftp-hpa-0.48/README.security
---- tftp-hpa-0.48/README.security.tftpboot 2008-05-29 17:36:32.000000000 +0200
-+++ tftp-hpa-0.48/README.security 2008-05-29 17:37:21.000000000 +0200
-@@ -17,10 +17,10 @@ probably the following:
-
- 1. Create a separate "tftpd" user and group only used for tftpd;
- 2. Have all your boot files in a single directory tree (usually called
-- /tftpboot).
--3. Specify "-p -u tftpd -s /tftpboot" on the tftpd command line; if
-+ /var/lib/tftpboot).
-+3. Specify "-p -u tftpd -s /var/lib/tftpboot" on the tftpd command line; if
- you want clients to be able to create files use
-- "-p -c -U 002 -u tftpd -s /tftpboot" (replace 002 with whatever
-+ "-p -c -U 002 -u tftpd -s /var/lib/tftpboot" (replace 002 with whatever
- umask is appropriate for your setup.)
-
- =======================================
-@@ -40,12 +40,12 @@ directly. Thus, if your /etc/inetd.conf
- line):
-
- tftp dgram udp wait root /usr/sbin/tcpd
--/usr/sbin/in.tftpd -s /tftpboot -r blksize
-+/usr/sbin/in.tftpd -s /var/lib/tftpboot -r blksize
-
- ... it's better to change to ...
-
- tftp dgram udp wait root /usr/sbin/in.tftpd
--in.tftpd -s /tftpboot -r blksize
-+in.tftpd -s /var/lib/tftpboot -r blksize
-
- You should make sure that you are using "wait" option in tftpd; you
- also need to have tftpd spawned as root in order for chroot (-s) to
-diff -up tftp-hpa-0.48/tftpd/sample.rules.tftpboot tftp-hpa-0.48/tftpd/sample.rules
---- tftp-hpa-0.48/tftpd/sample.rules.tftpboot 2008-05-29 17:38:46.000000000 +0200
-+++ tftp-hpa-0.48/tftpd/sample.rules 2008-05-29 17:38:05.000000000 +0200
-@@ -30,5 +30,5 @@ rg \\ / # Convert backslashes to slash
- rg \# @ # Convert hash marks to @ signs
- rg /../ /..no../ # Convert /../ to /..no../
- e ^ok/ # These are always ok
--r ^[^/] /tftpboot/\0 # Convert non-absolute files
-+r ^[^/] /var/lib/tftpboot/\0 # Convert non-absolute files
- a \.pvt$ # Reject requests for private files
deleted file mode 100644
@@ -1,21 +0,0 @@
-Patch originally from Fedora
-
-https://src.fedoraproject.org/rpms/tftp.git
-
-Upstream-Status: Pending
-
-diff -up tftp-hpa-0.49/tftpd/tftpd.c.chk_retcodes tftp-hpa-0.49/tftpd/tftpd.c
---- tftp-hpa-0.49/tftpd/tftpd.c.chk_retcodes 2009-01-15 15:28:50.000000000 +0100
-+++ tftp-hpa-0.49/tftpd/tftpd.c 2009-01-15 15:31:36.000000000 +0100
-@@ -932,7 +932,10 @@ int main(int argc, char **argv)
- exit(EX_OSERR);
- }
- #ifdef __CYGWIN__
-- chdir("/"); /* Cygwin chroot() bug workaround */
-+ if (chdir("/") < 0) { /* Cygwin chroot() bug workaround */
-+ syslog(LOG_ERR, "chroot: %m");
-+ exit(EX_OSERR);
-+ }
- #endif
- }
- #ifdef HAVE_SETREGID
deleted file mode 100644
@@ -1,24 +0,0 @@
-Patch originally from Fedora
-
-https://src.fedoraproject.org/rpms/tftp.git
-
-Upstream-Status: Pending
-
-diff -up tftp-hpa-0.49/tftpd/tftpd.c.tzfix tftp-hpa-0.49/tftpd/tftpd.c
---- tftp-hpa-0.49/tftpd/tftpd.c.tzfix 2008-10-20 18:08:31.000000000 -0400
-+++ tftp-hpa-0.49/tftpd/tftpd.c 2008-11-25 11:45:27.000000000 -0500
-@@ -350,6 +350,14 @@ int main(int argc, char **argv)
- const char *pidfile = NULL;
- u_short tp_opcode;
-
-+ time_t my_time = 0;
-+ struct tm* p_tm;
-+ char envtz[10];
-+ my_time = time(NULL);
-+ p_tm = localtime(&my_time);
-+ snprintf(envtz, sizeof(envtz) - 1, "UTC%+d", (p_tm->tm_gmtoff * -1)/3600);
-+ setenv("TZ", envtz, 0);
-+
- /* basename() is way too much of a pain from a portability standpoint */
-
- p = strrchr(argv[0], '/');
deleted file mode 100644
@@ -1,32 +0,0 @@
-Patch originally from Fedora
-
-https://src.fedoraproject.org/rpms/tftp.git
-
-Upstream-Status: Pending
-
-diff -urN tftp-hpa-0.49.orig/tftp/tftp.c tftp-hpa-0.49/tftp/tftp.c
---- tftp-hpa-0.49.orig/tftp/tftp.c 2008-10-20 18:08:31.000000000 -0400
-+++ tftp-hpa-0.49/tftp/tftp.c 2009-08-05 09:47:18.072585848 -0400
-@@ -279,15 +279,16 @@
- struct tftphdr *tp, const char *mode)
- {
- char *cp;
-+ size_t len;
-
- tp->th_opcode = htons((u_short) request);
- cp = (char *)&(tp->th_stuff);
-- strcpy(cp, name);
-- cp += strlen(name);
-- *cp++ = '\0';
-- strcpy(cp, mode);
-- cp += strlen(mode);
-- *cp++ = '\0';
-+ len = strlen(name) + 1;
-+ memcpy(cp, name, len);
-+ cp += len;
-+ len = strlen(mode) + 1;
-+ memcpy(cp, mode, len);
-+ cp += len;
- return (cp - (char *)tp);
- }
-
deleted file mode 100644
@@ -1,20 +0,0 @@
-Patch originally from Fedora
-
-https://src.fedoraproject.org/rpms/tftp.git
-
-Upstream-Status: Pending
-
-diff -up tftp-hpa-0.49/tftp/tftp.c.stats tftp-hpa-0.49/tftp/tftp.c
---- tftp-hpa-0.49/tftp/tftp.c.stats 2011-01-03 15:38:34.217918067 +0100
-+++ tftp-hpa-0.49/tftp/tftp.c 2011-01-03 15:38:37.498917014 +0100
-@@ -400,8 +400,8 @@ static void printstats(const char *direc
- {
- double delta;
-
-- delta = (tstop.tv_sec + (tstop.tv_usec / 100000.0)) -
-- (tstart.tv_sec + (tstart.tv_usec / 100000.0));
-+ delta = (tstop.tv_sec + (tstop.tv_usec / 1000000.0)) -
-+ (tstart.tv_sec + (tstart.tv_usec / 1000000.0));
- if (verbose) {
- printf("%s %lu bytes in %.1f seconds", direction, amount, delta);
- printf(" [%.0f bit/s]", (amount * 8.) / delta);
deleted file mode 100644
@@ -1,154 +0,0 @@
-Patch originally from Fedora
-
-https://src.fedoraproject.org/rpms/tftp.git
-
-Upstream-Status: Pending
-
-diff -up tftp-hpa-5.3/config.h.cmd_arg tftp-hpa-5.3/config.h
---- tftp-hpa-5.3/config.h.cmd_arg 2024-05-30 00:40:13.000000000 +0200
-+++ tftp-hpa-5.3/config.h 2025-12-26 22:27:30.933202754 +0100
-@@ -277,6 +277,7 @@ typedef int socklen_t;
- /* Prototypes for libxtra functions */
-
- void *xmalloc(size_t);
-+void *xrealloc(void *, size_t);
- char *xstrdup(const char *);
-
- #ifndef HAVE_SIGHANDLER_T
-diff -up tftp-hpa-5.3/lib/xrealloc.c.cmd_arg tftp-hpa-5.3/lib/xrealloc.c
---- tftp-hpa-5.3/lib/xrealloc.c.cmd_arg 2025-12-26 22:19:59.751870026 +0100
-+++ tftp-hpa-5.3/lib/xrealloc.c 2025-12-26 22:19:59.751870026 +0100
-@@ -0,0 +1,20 @@
-+/*
-+ * xrealloc.c
-+ *
-+ * Simple error-checking version of realloc()
-+ *
-+ */
-+
-+#include "config.h"
-+
-+void *xrealloc(void *ptr, size_t size)
-+{
-+ void *p = realloc(ptr, size);
-+
-+ if (!p) {
-+ fprintf(stderr, "Out of memory!\n");
-+ exit(128);
-+ }
-+
-+ return p;
-+}
-diff -up tftp-hpa-5.3/tftp/main.c.cmd_arg tftp-hpa-5.3/tftp/main.c
---- tftp-hpa-5.3/tftp/main.c.cmd_arg 2024-05-30 00:40:13.000000000 +0200
-+++ tftp-hpa-5.3/tftp/main.c 2025-12-26 22:19:59.752870023 +0100
-@@ -89,11 +89,14 @@ int connected;
- const struct modes *mode;
- #ifdef WITH_READLINE
- char *line = NULL;
-+char *remote_pth = NULL;
- #else
- char line[LBUFLEN];
-+char remote_pth[LBUFLEN];
- #endif
- int margc;
--char *margv[20];
-+char **margv;
-+int sizeof_margv=0;
- const char *prompt = "tftp> ";
- sigjmp_buf toplevel;
- void intr(int);
-@@ -379,6 +382,10 @@ static void getmoreargs(const char *part
- free(line);
- line = NULL;
- }
-+ if (remote_pth) {
-+ free(remote_pth);
-+ remote_pth = NULL;
-+ }
- line = xmalloc(len + elen + 1);
- strcpy(line, partial);
- strcpy(line + len, eline);
-@@ -535,6 +542,7 @@ void put(int argc, char *argv[])
- int fd;
- int n, err;
- char *cp, *targ;
-+ long dirlen, namelen, lastlen=0;
-
- if (argc < 2) {
- getmoreargs("send ", "(file) ");
-@@ -588,9 +596,22 @@ void put(int argc, char *argv[])
- }
- /* this assumes the target is a directory */
- /* on a remote unix system. hmmmm. */
-- cp = strchr(targ, '\0');
-- *cp++ = '/';
-+ dirlen = strlen(targ)+1;
-+#ifdef WITH_READLINE
-+ remote_pth = xmalloc(dirlen+1);
-+#endif
-+ strcpy(remote_pth, targ);
-+ remote_pth[dirlen-1] = '/';
-+ cp = remote_pth + dirlen;
- for (n = 1; n < argc - 1; n++) {
-+#ifdef WITH_READLINE
-+ namelen = strlen(tail(argv[n])) + 1;
-+ if (namelen > lastlen) {
-+ remote_pth = xrealloc(remote_pth, dirlen + namelen + 1);
-+ cp = remote_pth + dirlen;
-+ lastlen = namelen;
-+ }
-+#endif
- strcpy(cp, tail(argv[n]));
- fd = open(argv[n], O_RDONLY | mode->m_openflags);
- if (fd < 0) {
-@@ -600,9 +621,9 @@ void put(int argc, char *argv[])
- }
- if (verbose)
- printf("putting %s to %s:%s [%s]\n",
-- argv[n], hostname, targ, mode->m_mode);
-+ argv[n], hostname, remote_pth, mode->m_mode);
- sa_set_port(&peeraddr, port);
-- tftp_sendfile(fd, targ, mode->m_mode);
-+ tftp_sendfile(fd, remote_pth, mode->m_mode);
- }
- }
-
-@@ -801,6 +822,10 @@ static void command(void)
- free(line);
- line = NULL;
- }
-+ if (remote_pth) {
-+ free(remote_pth);
-+ remote_pth = NULL;
-+ }
- line = readline(prompt);
- if (!line)
- exit(0); /* EOF */
-@@ -872,7 +897,13 @@ struct cmd *getcmd(char *name)
- static void makeargv(void)
- {
- char *cp;
-- char **argp = margv;
-+ char **argp;
-+
-+ if (!sizeof_margv) {
-+ sizeof_margv = 20;
-+ margv = xmalloc(sizeof_margv * sizeof(char *));
-+ }
-+ argp = margv;
-
- margc = 0;
- for (cp = line; *cp;) {
-@@ -882,6 +913,11 @@ static void makeargv(void)
- break;
- *argp++ = cp;
- margc += 1;
-+ if (margc == sizeof_margv) {
-+ sizeof_margv += 20;
-+ margv = xrealloc(margv, sizeof_margv * sizeof(char *));
-+ argp = margv + margc;
-+ }
- while (*cp != '\0' && !isspace(*cp))
- cp++;
- if (*cp == '\0')
deleted file mode 100644
@@ -1,29 +0,0 @@
-Patch originally from Fedora
-
-https://src.fedoraproject.org/rpms/tftp.git
-
-Upstream-Status: Pending
-
-diff -up tftp-hpa-5.3/tftpd/recvfrom.c.pktinfo tftp-hpa-5.3/tftpd/recvfrom.c
---- tftp-hpa-5.3/tftpd/recvfrom.c.pktinfo 2024-05-30 00:40:13.000000000 +0200
-+++ tftp-hpa-5.3/tftpd/recvfrom.c 2025-12-26 22:30:37.142522362 +0100
-@@ -170,16 +170,16 @@ myrecvfrom(int s, void *buf, int len, un
-
- /* Try to enable getting the return address */
- #ifdef IP_RECVDSTADDR
-- if (from->sa.sa_family == AF_INET)
-+ if (from->sa.sa_family == AF_INET || !from->sa.sa_family)
- setsockopt(s, IPPROTO_IP, IP_RECVDSTADDR, &on, sizeof(on));
- #endif
- #ifdef IP_PKTINFO
-- if (from->sa.sa_family == AF_INET)
-+ if (from->sa.sa_family == AF_INET || !from->sa.sa_family)
- setsockopt(s, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
- #endif
- #ifdef HAVE_IPV6
- #ifdef IPV6_RECVPKTINFO
-- if (from->sa.sa_family == AF_INET6)
-+ if (from->sa.sa_family == AF_INET6 || !from->sa.sa_family)
- setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &on, sizeof(on));
- #endif
- #endif
deleted file mode 100644
@@ -1,38 +0,0 @@
-From 2be04543d790d9ec29fa8522f07f221468ccd033 Mon Sep 17 00:00:00 2001
-From: Zhang Xiao <xiao.zhang@windriver.com>
-Date: Wed, 11 Jun 2014 14:01:16 +0800
-Subject: [PATCH] tftp-hpa: bug fix on separated CR and LF
-
-In ascii mode, if the CR and LF was separated into different transfer
-blocks, LF will be just dropped instead of replacing the previous CR.
-Add a checking on the first character to fix it.
-
-Upstream-Status: Pending
-
-Signed-off-by: Zhang Xiao <xiao.zhang@windriver.com>
----
- common/tftpsubs.c | 8 ++++++++
- 1 file changed, 8 insertions(+)
-
-diff --git a/common/tftpsubs.c b/common/tftpsubs.c
-index b4d4ffe..b4ea3f2 100644
---- a/common/tftpsubs.c
-+++ b/common/tftpsubs.c
-@@ -207,6 +207,14 @@ int write_behind(FILE * file, int convert)
- p = buf;
- ct = count;
- count = 0;
-+
-+ /* Check the first character together with prevchar */
-+ c = *p;
-+ if ((prevchar == '\r') && (c == '\n')) {
-+ lseek(fileno(file), -1, SEEK_CUR);
-+ count++;
-+ }
-+
- while (ct--) { /* loop over the buffer */
- c = *p++; /* pick up a character */
- if (prevchar == '\r') { /* if prev char was cr */
-2.34.1
-
similarity index 74%
rename from meta-networking/recipes-daemons/tftp-hpa/tftp-hpa_5.3.bb
rename to meta-networking/recipes-daemons/tftp-hpa/tftp-hpa_7.2.bb
@@ -7,43 +7,33 @@ remote machine. This program and TFTP provide very little security, \
and should not be enabled unless it is expressly needed."
HOMEPAGE = "https://git.kernel.org/pub/scm/network/tftp/tftp-hpa.git/"
SECTION = "net"
-LICENSE = "BSD-4-Clause"
-LIC_FILES_CHKSUM = "file://MCONFIG.in;beginline=1;endline=9;md5=c28ba5adb43041fae4629db05c83cbdd \
- file://tftp/tftp.c;beginline=1;endline=32;md5=988c1cba99d70858a26cd877209857f4"
+LICENSE = "BSD-3-Clause AND BSD-4-Clause-UC"
+LIC_FILES_CHKSUM = "file://LICENSES/BSD-3-Clause.txt;md5=191956fc5761f4f309d43958771e7bee \
+ file://LICENSES/BSD-4-Clause-UC.txt;md5=0a2b1873d52ca8a734e17c403073bc5e \
+ file://tftp/tftp.c;beginline=1;endline=7;md5=f34f26134815d53d8019f335465c9945"
SRC_URI = "git://git.kernel.org/pub/scm/network/tftp/tftp-hpa.git;protocol=https;branch=master;tag=tftp-hpa-${PV} \
- file://tftp-0.40-remap.patch \
- file://tftp-0.42-tftpboot.patch \
- file://tftp-0.49-chk_retcodes.patch \
- file://tftp-hpa-5.3-cmd_arg.patch \
- file://tftp-hpa-0.39-tzfix.patch \
- file://tftp-hpa-0.49-fortify-strcpy-crash.patch \
- file://tftp-hpa-0.49-stats.patch \
- file://tftp-hpa-5.3-pktinfo.patch \
- file://add-error-check-for-disk-filled-up.patch \
- file://tftp-hpa-bug-fix-on-separated-CR-and-LF.patch \
- file://fix-writing-emtpy-file.patch \
+ file://0001-autoconf-add-AC_CONFIG_MACRO_DIRS-for-autoreconf-ben.patch \
+ file://0002-Fix-autoconf-test-for-off_t.patch \
+ file://0003-tftp-fix-type-of-r_timeout.patch \
+ file://0004-tftp-fix-type-of-r_timeout-in-tftp_recvfile.patch \
file://default \
file://init \
file://tftpd-hpa.socket \
file://tftpd-hpa.service \
"
-SRCREV = "15c4f369ee741e9205dc28ce631aaf6799193b04"
+SRCREV = "af23362c585b4904e51354d1e3faacc01ee85296"
inherit autotools-brokensep update-rc.d update-alternatives systemd
DEPENDS = "readline"
-EXTRA_OECONF = "--enable-largefile \
- --enable-year2038 \
- --with-readline \
- --without-tcpwrappers \
- "
+EXTRA_OECONF = "--enable-readline"
PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
-PACKAGECONFIG[ipv6] = "--with-ipv6,--without-ipv6,"
+PACKAGECONFIG[ipv6] = "--enable-ipv6,--disable-ipv6,"
CACHED_CONFIGUREVARS:libc-musl = "ac_cv_type_socklen_t=yes"
Two major releases after twelve years without one: - 6.0: RFC 7440 windowsize, threaded tftpd I/O, --reject-all, blksize and windowsize in the client and long client options; tcpwrappers support is removed. - 6.1: client and server share one transfer implementation, better windowed-transfer recovery, and netascii CR sequences spanning packet boundaries are handled. - 7.0: smaller server footprint, mget/mput, --jail (openat2) as a chroot-free alternative to --secure, --normalize, transfer logging, and nonzero exit status for command-mode failures. - 7.1: requires C99; -B mtu, the client rejects replies from other addresses (-U overrides), defaults to octet mode with MTU sized blocks and windowsize 64, and requests tsize; tftpd gains --validate, --read-only and --max-upload and refuses uploads through symlinks. - 7.2: tftpd drops unneeded Linux capabilities, limits "rollover" to 0 and 1, adds an experimental cookie option and fixes options negotiation returning invalid block sizes. Drop the eleven carried patches, like Fedora does for 7.2: the Fedora ones target code that was rewritten, 7.x reports a full disk as ENOSPACE (add-error-check-for-disk-filled-up.patch, fix-writing-emtpy-file.patch), and 6.1 fixes CR/LF split across packets (tftp-hpa-bug-fix-on-separated-CR-and-LF.patch). Backport four fixes from upstream master: AC_CONFIG_MACRO_DIRS so autoreconf finds the bundled m4 macros, the off_t check, and the r_timeout type in both transfer directions, which broke 32-bit builds. configure now uses --enable/--disable-readline and -ipv6, and no longer has --enable-largefile, --enable-year2038 or --without-tcpwrappers; update EXTRA_OECONF and the ipv6 PACKAGECONFIG. License-Update: MCONFIG.in is gone; the sources carry SPDX tags and the texts are in LICENSES/ (BSD-4-Clause-UC for the BSD code, BSD-3-Clause for newer code). AI-Generated: Uses Claude Code Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com> --- ...CONFIG_MACRO_DIRS-for-autoreconf-ben.patch | 30 ++++ .../0002-Fix-autoconf-test-for-off_t.patch | 36 ++++ .../0003-tftp-fix-type-of-r_timeout.patch | 31 ++++ ...x-type-of-r_timeout-in-tftp_recvfile.patch | 28 ++++ .../add-error-check-for-disk-filled-up.patch | 81 --------- .../files/fix-writing-emtpy-file.patch | 42 ----- .../tftp-hpa/files/tftp-0.40-remap.patch | 25 --- .../tftp-hpa/files/tftp-0.42-tftpboot.patch | 60 ------- .../files/tftp-0.49-chk_retcodes.patch | 21 --- .../tftp-hpa/files/tftp-hpa-0.39-tzfix.patch | 24 --- .../tftp-hpa-0.49-fortify-strcpy-crash.patch | 32 ---- .../tftp-hpa/files/tftp-hpa-0.49-stats.patch | 20 --- .../tftp-hpa/files/tftp-hpa-5.3-cmd_arg.patch | 154 ------------------ .../tftp-hpa/files/tftp-hpa-5.3-pktinfo.patch | 29 ---- ...p-hpa-bug-fix-on-separated-CR-and-LF.patch | 38 ----- .../{tftp-hpa_5.3.bb => tftp-hpa_7.2.bb} | 32 ++-- 16 files changed, 136 insertions(+), 547 deletions(-) create mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/0001-autoconf-add-AC_CONFIG_MACRO_DIRS-for-autoreconf-ben.patch create mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/0002-Fix-autoconf-test-for-off_t.patch create mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/0003-tftp-fix-type-of-r_timeout.patch create mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/0004-tftp-fix-type-of-r_timeout-in-tftp_recvfile.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/add-error-check-for-disk-filled-up.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/fix-writing-emtpy-file.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-0.40-remap.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-0.42-tftpboot.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-0.49-chk_retcodes.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-hpa-0.39-tzfix.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-hpa-0.49-fortify-strcpy-crash.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-hpa-0.49-stats.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-hpa-5.3-cmd_arg.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-hpa-5.3-pktinfo.patch delete mode 100644 meta-networking/recipes-daemons/tftp-hpa/files/tftp-hpa-bug-fix-on-separated-CR-and-LF.patch rename meta-networking/recipes-daemons/tftp-hpa/{tftp-hpa_5.3.bb => tftp-hpa_7.2.bb} (74%)