pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/emulators/qemu emulators/qemu: fix crash in slirp:tcp_...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/addb997652a4
branches:  trunk
changeset: 458677:addb997652a4
user:      yhardy <yhardy%pkgsrc.org@localhost>
date:      Sun Sep 19 13:49:12 2021 +0000

description:
emulators/qemu: fix crash in slirp:tcp_subr.c

Reported upstream to the qemu and slirp projects (thanks to Marc), fixed in

 https://gitlab.freedesktop.org/slirp/libslirp/-/commit/23db43abdb5740287bbb7cbf5cc99eb22e121298

This adds the corresponding patch for qemu-6.1.0.

diffstat:

 emulators/qemu/Makefile                            |   4 +-
 emulators/qemu/distinfo                            |   3 +-
 emulators/qemu/patches/patch-slirp_src_tcp__subr.c |  57 ++++++++++++++++++++++
 3 files changed, 61 insertions(+), 3 deletions(-)

diffs (91 lines):

diff -r b05f45fc8d25 -r addb997652a4 emulators/qemu/Makefile
--- a/emulators/qemu/Makefile   Sun Sep 19 13:32:32 2021 +0000
+++ b/emulators/qemu/Makefile   Sun Sep 19 13:49:12 2021 +0000
@@ -1,8 +1,8 @@
-# $NetBSD: Makefile,v 1.287 2021/09/10 13:10:58 nia Exp $
+# $NetBSD: Makefile,v 1.288 2021/09/19 13:49:12 yhardy Exp $
 
 DISTNAME=      qemu-6.1.0
 PKGNAME=       ${DISTNAME:S/-rc/rc/}
-PKGREVISION=   2
+PKGREVISION=   3
 CATEGORIES=    emulators
 MASTER_SITES=  https://download.qemu.org/
 EXTRACT_SUFX=  .tar.xz
diff -r b05f45fc8d25 -r addb997652a4 emulators/qemu/distinfo
--- a/emulators/qemu/distinfo   Sun Sep 19 13:32:32 2021 +0000
+++ b/emulators/qemu/distinfo   Sun Sep 19 13:49:12 2021 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.185 2021/09/10 19:44:37 nia Exp $
+$NetBSD: distinfo,v 1.186 2021/09/19 13:49:12 yhardy Exp $
 
 SHA1 (palcode-clipper-qemu-5.2.0nb8) = ddbf1dffb7c2b2157e0bbe9fb7db7e57105130b1
 RMD160 (palcode-clipper-qemu-5.2.0nb8) = 3f9fe19a40f7ca72ecfe047d1449e55b63cba3ee
@@ -25,5 +25,6 @@
 SHA1 (patch-meson.build) = 35f4d563e99dcc014a011bb4c7cddefac852d4cf
 SHA1 (patch-net_tap-solaris.c) = cc953c9a624dd55ace4e130d0b31bbfb956c17d5
 SHA1 (patch-roms_u-boot-sam460ex_Makefile) = 3a1bbf19b1422c10ebdd819eb0b711fafc78e2f2
+SHA1 (patch-slirp_src_tcp__subr.c) = bd6d80ecf3baeaf6f8458b2361bcb92298d41f7e
 SHA1 (patch-target_i386_nvmm_nvmm-all.c) = 8f4b51a6460090d7826af1ae02840a208767345b
 SHA1 (patch-target_sparc_translate.c) = 7ec2add2fd808facb48b9a66ccc345599251bf76
diff -r b05f45fc8d25 -r addb997652a4 emulators/qemu/patches/patch-slirp_src_tcp__subr.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/emulators/qemu/patches/patch-slirp_src_tcp__subr.c        Sun Sep 19 13:49:12 2021 +0000
@@ -0,0 +1,57 @@
+$NetBSD: patch-slirp_src_tcp__subr.c,v 1.1 2021/09/19 13:49:12 yhardy Exp $
+
+Issues:
+
+ QEMU crashes when receiving network connection on NetBSD
+ https://gitlab.com/qemu-project/qemu/-/issues/605
+
+ Use the exact sockaddr size in getnameinfo call
+ https://gitlab.freedesktop.org/slirp/libslirp/-/issues/52
+ Fixed in commit: 23db43ab
+
+--- slirp/src/tcp_subr.c.orig  2021-09-18 20:05:43.313555017 +0000
++++ slirp/src/tcp_subr.c
+@@ -464,7 +464,7 @@ void tcp_connect(struct socket *inso)
+     Slirp *slirp = inso->slirp;
+     struct socket *so;
+     struct sockaddr_storage addr;
+-    socklen_t addrlen = sizeof(struct sockaddr_storage);
++    socklen_t addrlen;
+     struct tcpcb *tp;
+     int s, opt, ret;
+     /* AF_INET6 addresses are bigger than AF_INET, so this is big enough. */
+@@ -473,7 +473,17 @@ void tcp_connect(struct socket *inso)
+ 
+     DEBUG_CALL("tcp_connect");
+     DEBUG_ARG("inso = %p", inso);
+-    ret = getnameinfo((const struct sockaddr *) &inso->lhost.ss, sizeof(inso->lhost.ss), addrstr, sizeof(addrstr), portstr, sizeof(portstr), NI_NUMERICHOST|NI_NUMERICSERV);
++    switch (inso->lhost.ss.ss_family) {
++    case AF_INET:
++        addrlen = sizeof(struct sockaddr_in);
++        break;
++    case AF_INET6:
++        addrlen = sizeof(struct sockaddr_in6);
++        break;
++    default:
++        g_assert_not_reached();
++    }
++    ret = getnameinfo((const struct sockaddr *) &inso->lhost.ss, addrlen, addrstr, sizeof(addrstr), portstr, sizeof(portstr), NI_NUMERICHOST|NI_NUMERICSERV);
+     g_assert(ret == 0);
+     DEBUG_ARG("ip = [%s]:%s", addrstr, portstr);
+     DEBUG_ARG("so_state = 0x%x", inso->so_state);
+@@ -494,6 +504,7 @@ void tcp_connect(struct socket *inso)
+              * us again until the guest address is available.
+              */
+             DEBUG_MISC(" guest address not available yet");
++            addrlen = sizeof(addr);
+             s = accept(inso->s, (struct sockaddr *)&addr, &addrlen);
+             if (s >= 0) {
+                 close(s);
+@@ -518,6 +529,7 @@ void tcp_connect(struct socket *inso)
+ 
+     tcp_mss(sototcpcb(so), 0);
+ 
++    addrlen = sizeof(addr);
+     s = accept(inso->s, (struct sockaddr *)&addr, &addrlen);
+     if (s < 0) {
+         tcp_close(sototcpcb(so)); /* This will sofree() as well */



Home | Main Index | Thread Index | Old Index