Richard W.M. Jones 325e390421 block/ssh: Avoid segfault if inet_connect doesn't set errno.
On some (but not all) systems:

  $ qemu-img create -f qcow2 overlay -b ssh://xen/
  Segmentation fault

It turns out this happens when inet_connect returns -1 in the
following code, but errno == 0.

  s->sock = inet_connect(s->hostport, errp);
  if (s->sock < 0) {
      ret = -errno;
      goto err;
  }

In the test case above, no host called "xen" exists, so getaddrinfo fails.

On Fedora 22, getaddrinfo happens to set errno = ENOENT (although it
is *not* documented to do that), so it doesn't segfault.

On RHEL 7, errno is not set by the failing getaddrinfo, so ret =
-errno = 0, so the caller doesn't know there was an error and
continues with a half-initialized BDRVSSHState struct, and everything
goes south from there, eventually resulting in a segfault.

Fix this by setting ret to -EIO (same as block/nbd.c and
block/sheepdog.c).  The real error is saved in the Error** errp
struct, so it is printed correctly:

  $ ./qemu-img create -f qcow2 overlay -b ssh://xen/
  qemu-img: overlay: address resolution failed for xen:22: No address associated with hostname

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Reported-by: Jun Li
BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1147343
Signed-off-by: Jeff Cody <jcody@redhat.com>
2015-07-28 00:19:05 -04:00
2015-07-08 13:11:01 +02:00
2015-07-20 13:35:45 +02:00
2015-07-27 14:53:42 +01:00
2015-07-07 14:54:55 +02:00
2015-07-09 15:20:40 +02:00
2015-07-24 13:57:44 +02:00
2015-04-04 09:45:59 +03:00
2014-06-16 13:24:35 +02:00
2013-09-05 09:40:31 -05:00
2015-06-12 06:42:34 +02:00
2015-07-14 21:50:13 -04:00
2013-10-11 09:34:56 -07:00
2015-06-03 14:21:24 +03:00
2015-04-30 16:05:48 +03:00
2015-07-09 15:20:40 +02:00
2013-07-23 02:41:31 +02:00
2015-06-12 13:42:17 +01:00
2015-07-07 09:22:40 +01:00
2015-07-14 17:15:23 +02:00
2015-06-23 20:23:39 +03:00
2015-07-24 13:57:45 +02:00
2014-05-24 00:07:29 +04:00
2015-07-24 13:57:45 +02:00
2015-07-24 13:57:45 +02:00
2015-05-11 08:59:07 -04:00
2015-05-22 15:58:22 -04:00
2013-10-11 09:34:56 -07:00
2015-06-11 10:13:28 +01:00
2015-07-22 18:17:19 +01:00
2013-10-11 09:34:56 -07:00
2015-06-23 17:46:20 +01:00

Read the documentation in qemu-doc.html or on http://wiki.qemu-project.org

- QEMU team
Description
QEMU With E2K User Support
Readme 459 MiB
Languages
C 83.1%
C++ 6.3%
Python 3.2%
Dylan 2.8%
Shell 1.6%
Other 2.8%