diff -u nbd-3.17/debian/changelog nbd-3.17/debian/changelog --- nbd-3.17/debian/changelog +++ nbd-3.17/debian/changelog @@ -1,3 +1,9 @@ +nbd (1:3.17-2ubuntu1) cosmic; urgency=medium + + * Fix segfault when exporting only from a file on the command line. (LP: #1772024) + + -- Thadeu Lima de Souza Cascardo Wed, 23 May 2018 17:01:03 -0300 + nbd (1:3.17-2) unstable; urgency=medium * Add missing build-dependency on libnl-genl-dev diff -u nbd-3.17/debian/control nbd-3.17/debian/control --- nbd-3.17/debian/control +++ nbd-3.17/debian/control @@ -1,8 +1,9 @@ Source: nbd Section: admin Priority: optional -Maintainer: Wouter Verhelst -Build-Depends: debhelper (>= 9), libglib2.0-dev (>= 2.26.0), libgnutls28-dev, libnl-genl-3-dev +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Wouter Verhelst +Build-Depends: debhelper (>= 9), libglib2.0-dev (>= 2.26.0), libgnutls28-dev, libnl-genl-3-dev, quilt Standards-Version: 3.9.4 Vcs-Git: git://anonscm.debian.org/users/wouter/nbd.git Vcs-Browser: http://git.debian.org/?p=users/wouter/nbd.git;a=summary diff -u nbd-3.17/debian/rules nbd-3.17/debian/rules --- nbd-3.17/debian/rules +++ nbd-3.17/debian/rules @@ -5,7 +5,7 @@ DEB_HOST_GNU_SYSTEM := $(shell dpkg-architecture -qDEB_HOST_GNU_SYSTEM) %: - dh $@ + dh $@ --with quilt override_dh_auto_configure: debian/po/templates.pot test -f nbd.h only in patch2: unchanged: --- nbd-3.17.orig/debian/patches/0001-server-Close-socket-pair-when-fork-fails +++ nbd-3.17/debian/patches/0001-server-Close-socket-pair-when-fork-fails @@ -0,0 +1,25 @@ +From: Thadeu Lima de Souza Cascardo +Description: server: Close socket pair when fork fails. + +When fork fails, we return without closing the socket pair that was just +created. This might cause file descriptor leaks. + +Signed-off-by: Thadeu Lima de Souza Cascardo +Signed-off-by: Wouter Verhelst + +Origin: upstream, commit:0e094066a2676149e511f41a5eee1062de73e198 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1772024 + +diff --git a/nbd-server.c b/nbd-server.c +index f5b244f..c2e20c2 100644 +--- a/nbd-server.c ++++ b/nbd-server.c +@@ -2807,6 +2807,8 @@ spawn_child(int* socket) + pid = fork(); + if (pid < 0) { + msg(LOG_ERR, "Could not fork (%s)", strerror(errno)); ++ close(sockets[0]); ++ close(sockets[1]); + goto out; + } + if (pid > 0) { /* Parent */ only in patch2: unchanged: --- nbd-3.17.orig/debian/patches/0001-server-do-not-crash-when-handling-child-name +++ nbd-3.17/debian/patches/0001-server-do-not-crash-when-handling-child-name @@ -0,0 +1,28 @@ +From: Thadeu Lima de Souza Cascardo +Description: server: do not crash when handling child name + +The parent will receive the servename from the child to verify if it has +reached the max number of connections. When the servename is the empty name, it +will try to allocate a 0-sized buffer, which will return a NULL pointer, and +that segfaults when running strcmp. + +Signed-off-by: Thadeu Lima de Souza Cascardo +Signed-off-by: Wouter Verhelst + +Origin: upstream, commit:4c924b7b64fb1b6cb9be8e8f508d459c0ed05a60 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1772024 + +diff --git a/nbd-server.c b/nbd-server.c +index c2e20c2..1d1f4c8 100644 +--- a/nbd-server.c ++++ b/nbd-server.c +@@ -2952,7 +2952,8 @@ static int handle_childname(GArray* servers, int socket) + break; + } + } +- buf = g_malloc0(len); ++ buf = g_malloc0(len + 1); ++ buf[len] = 0; + readit(socket, buf, len); + for(i=0; ilen; i++) { + SERVER* srv = &g_array_index(servers, SERVER, i); only in patch2: unchanged: --- nbd-3.17.orig/debian/patches/series +++ nbd-3.17/debian/patches/series @@ -0,0 +1,2 @@ +0001-server-Close-socket-pair-when-fork-fails +0001-server-do-not-crash-when-handling-child-name