Skip to content

Commit

Permalink
net-misc/iputils: backport tftpd fixes
Browse files Browse the repository at this point in the history
Closes: https://bugs.gentoo.org/738872
Signed-off-by: Mike Gilbert <[email protected]>
  • Loading branch information
floppym committed Jan 25, 2021
1 parent 0bd4548 commit 20d6a21
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
45 changes: 45 additions & 0 deletions net-misc/iputils/files/iputils-20200821-fclose.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
From e1c3d09b412ad0d022178344b8cbf748dc60f17f Mon Sep 17 00:00:00 2001
From: Mike Gilbert <[email protected]>
Date: Sun, 24 Jan 2021 23:29:27 -0500
Subject: [PATCH] tftpd: recvfile: avoid closing the file twice

The close_stream function calls fclose, so don't call it again.

This resolves an abort in glibc:

Message: Process 1038079 (tftpd) of user 65534 dumped core.

Stack trace of thread 1038079:
#0 0x00007f5f650ed204 raise (libc.so.6 + 0x39204)
#1 0x00007f5f650d6547 abort (libc.so.6 + 0x22547)
#2 0x00007f5f6512f25f n/a (libc.so.6 + 0x7b25f)
#3 0x00007f5f651372fa n/a (libc.so.6 + 0x832fa)
#4 0x00007f5f65138dc2 n/a (libc.so.6 + 0x84dc2)
#5 0x00007f5f65124b2f fclose (libc.so.6 + 0x70b2f)
#6 0x000055571a50de73 recvfile (tftpd + 0x2e73)
#7 0x000055571a50e064 tftp (tftpd + 0x3064)
#8 0x000055571a50e387 tftpd_inetd (tftpd + 0x3387)
#9 0x000055571a50e50f main (tftpd + 0x350f)
#10 0x00007f5f650d7e6d __libc_start_main (libc.so.6 + 0x23e6d)
#11 0x000055571a50d3ca _start (tftpd + 0x23ca)

Fixes: 5d6be65 ("tftpd: remove global variables by using a run state struct")

Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Mike Gilbert <[email protected]>
---
tftpd/tftpd.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index 42998f9b..a09d32ba 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -387,7 +387,6 @@ void recvfile(struct run_state *ctl, struct formats *pf)
write_behind(ctl->file, pf->f_convert);
if (close_stream(ctl->file))
syslog(LOG_ERR, "tftpd: write error: %s\n", strerror(errno));
- fclose(ctl->file); /* close data file */

ap->th_opcode = htons((uint16_t)ACK); /* send the "final" ack */
ap->th_block = htons(block);
29 changes: 29 additions & 0 deletions net-misc/iputils/files/iputils-20200821-install-sbindir.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From 8d1420f3019cd1caccf2ffa15a5873f0c61ab529 Mon Sep 17 00:00:00 2001
From: Mike Gilbert <[email protected]>
Date: Sun, 24 Jan 2021 22:39:03 -0500
Subject: [PATCH] tftpd: install into sbindir

The xinet.d config expects the daemon to live in sbindir.

Closes: https://github.com/iputils/iputils/pull/310

Reviewed-by: Petr Vorel <[email protected]>
Signed-off-by: Mike Gilbert <[email protected]>
---
tftpd/meson.build | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tftpd/meson.build b/tftpd/meson.build
index 6e508a24..b4cf6812 100644
--- a/tftpd/meson.build
+++ b/tftpd/meson.build
@@ -3,7 +3,8 @@ inc = include_directories('..')
executable('tftpd', ['tftpd.c', 'tftpsubs.c', git_version_h],
include_directories : inc,
link_with : [libcommon],
- install: true)
+ install: true,
+ install_dir: sbindir)

subs = configuration_data()
subs.set('sbindir', sbindir)
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ fi

PATCHES=(
"${FILESDIR}/iputils-20200821-getrandom-fallback.patch"
"${FILESDIR}/iputils-20200821-fclose.patch"
"${FILESDIR}/iputils-20200821-install-sbindir.patch"
)

src_prepare() {
Expand Down

0 comments on commit 20d6a21

Please sign in to comment.