Fix segfault when IPv6 client is used (RHBZ#986601).
This commit is contained in:
parent
7647dbf164
commit
b626755dbc
@ -0,0 +1,58 @@
|
||||
From 49c5ff9ad0316960f11b180715b3a6906d42be83 Mon Sep 17 00:00:00 2001
|
||||
From: Michael Scherer <misc@zarb.org>
|
||||
Date: Sun, 21 Jul 2013 21:59:28 +0100
|
||||
Subject: [PATCH] 'struct sockaddr' is not large enough to store a general
|
||||
sockaddr.
|
||||
|
||||
In particular, if IPv6 is used, then sizeof sockaddr_in6 > sizeof sockaddr,
|
||||
resulting in a segfault:
|
||||
|
||||
https://bugzilla.redhat.com/show_bug.cgi?id=986601
|
||||
|
||||
RWMJ:
|
||||
- Minor formatting
|
||||
- Free tls->addr on normal exit path
|
||||
---
|
||||
src/tls.c | 12 +++++++++---
|
||||
1 file changed, 9 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/tls.c b/src/tls.c
|
||||
index 08e8638..390b03e 100644
|
||||
--- a/src/tls.c
|
||||
+++ b/src/tls.c
|
||||
@@ -54,7 +54,7 @@
|
||||
struct tls {
|
||||
const char *name; /* Can be NULL. */
|
||||
size_t instance_num; /* Can be 0. */
|
||||
- struct sockaddr addr;
|
||||
+ struct sockaddr *addr;
|
||||
socklen_t addrlen;
|
||||
};
|
||||
|
||||
@@ -65,6 +65,7 @@ free_tls (void *tlsv)
|
||||
{
|
||||
struct tls *tls = tlsv;
|
||||
|
||||
+ free (tls->addr);
|
||||
free (tls);
|
||||
}
|
||||
|
||||
@@ -118,8 +119,13 @@ tls_set_sockaddr (struct sockaddr *addr, socklen_t addrlen)
|
||||
struct tls *tls = pthread_getspecific (tls_key);
|
||||
|
||||
if (tls) {
|
||||
- tls->addrlen = addrlen;
|
||||
- memcpy (&tls->addr, addr, addrlen);
|
||||
+ free(tls->addr);
|
||||
+ tls->addr = calloc (1, addrlen);
|
||||
+ if (tls->addr == NULL) {
|
||||
+ perror ("calloc");
|
||||
+ exit (EXIT_FAILURE);
|
||||
+ }
|
||||
+ memcpy(tls->addr, addr, addrlen);
|
||||
}
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
10
nbdkit.spec
10
nbdkit.spec
@ -2,13 +2,17 @@
|
||||
|
||||
Name: nbdkit
|
||||
Version: 1.1.2
|
||||
Release: 2%{?dist}
|
||||
Release: 3%{?dist}
|
||||
Summary: NBD server
|
||||
|
||||
License: BSD
|
||||
URL: https://github.com/libguestfs/nbdkit
|
||||
Source0: http://libguestfs.org/download/nbdkit/%{name}-%{version}.tar.gz
|
||||
|
||||
# Fix segfault when IPv6 client is used (RHBZ#986601).
|
||||
# Patch is upstream.
|
||||
Patch1: 0001-struct-sockaddr-is-not-large-enough-to-store-a-gener.patch
|
||||
|
||||
BuildRequires: /usr/bin/pod2man
|
||||
BuildRequires: libguestfs-devel
|
||||
BuildRequires: libvirt-devel
|
||||
@ -121,6 +125,7 @@ plugins for %{name}.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch1 -p1
|
||||
|
||||
|
||||
%build
|
||||
@ -199,6 +204,9 @@ make check
|
||||
|
||||
|
||||
%changelog
|
||||
* Sun Jul 21 2013 Richard W.M. Jones <rjones@redhat.com> - 1.1.2-3
|
||||
- Fix segfault when IPv6 client is used (RHBZ#986601).
|
||||
|
||||
* Tue Jul 16 2013 Richard W.M. Jones <rjones@redhat.com> - 1.1.2-2
|
||||
- New development version 1.1.2.
|
||||
- Disable the tests on Fedora <= 18.
|
||||
|
Loading…
Reference in New Issue
Block a user