X2Go Bug report logs - #515
"connectedHost" variable contains wrong IP, reason unknown (was: Re: [X2Go-User] Pb with x2go agent on ppc64 system)

version graph

Package: x2goagent; Maintainer for x2goagent is X2Go Developers <x2go-dev@lists.x2go.org>; Source for x2goagent is src:nx-libs.

Reported by: x2go-dev@lists.x2go.org

Date: Wed, 11 Jun 2014 21:55:02 UTC

Severity: normal

Tags: pending

Found in version 3.5.0.24

Fixed in version 2:3.5.0.25

Done: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>

Bug is archived. No further changes may be made.

Full log


Message #35 received at 515@bugs.x2go.org (full text, mbox, reply):

Received: (at 515) by bugs.x2go.org; 14 Jun 2014 01:40:08 +0000
From ionic@ionic.de  Sat Jun 14 03:40:07 2014
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID,
	URIBL_BLOCKED autolearn=ham version=3.3.2
Received: from Root24.de (powered.by.root24.eu [91.121.15.64])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTP id EE3BC5DB11
	for <515@bugs.x2go.org>; Sat, 14 Jun 2014 03:40:06 +0200 (CEST)
Received: from nopileos.local (home.ionic.de [85.183.67.131])
	by Root24.de (Postfix) with ESMTPSA id 5452D3B005C9;
	Sat, 14 Jun 2014 03:40:06 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=ionic.de; s=default;
	t=1402710006; bh=xyCAQ7OQWn6ZZ9EXWNyJgH+yaxb1zCHO3FQOtqNiQW4=;
	h=Date:From:To:CC:Subject:References:In-Reply-To:From;
	b=vpC+gh+Q7ALX1unW62JsHSflkjkMaSyF1v3yLX6OwOtwgZv+iKHKJPyHJiOp+9wZ4
	 rBrqLNA+cWJnCtOkpH04nz/ICeiYYxUtq3N1iALeJ3MybIgRMirUZSVsb0hORPaofY
	 rI5/D5ILV5Zl36/xFbM5FQ7lLqrVwbQPuF1/xaWA=
Message-ID: <539BA7F7.5070002@ionic.de>
Date: Sat, 14 Jun 2014 03:40:07 +0200
From: Mihai Moldovan <ionic@ionic.de>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
MIME-Version: 1.0
To: 515@bugs.x2go.org
CC: sebastien chabrolles <s.chabrolles@fr.ibm.com>
Subject: Re: Bug#515: [X2Go-Dev] [X2Go-User] "connectedHost" variable contains
 wrong IP, reason unknown
References: <OF63CDD2EA.AB0207C6-ONC1257CF4.0033135B-C1257CF4.0039D4E6@fr.ibm.com> <20140611113037.Horde.qsAKjfq9P_p1svkMBI8Mtg1@mail.das-netzwerkteam.de> <539842C3.6010208@stefanbaur.de> <20140611124358.Horde.3fgisOaRzDKMd2835Ld1uA4@mail.das-netzwerkteam.de> <5398CE20.4090601@stefanbaur.de> <5398E061.6010000@gmail.com> <5399D7CC.9010408@ionic.de> <OF47115B4E.4B401215-ONC1257CF5.005EFDAE-C1257CF5.005FFA1D@fr.ibm.com> <539A0414.7040805@ionic.de> <539B239F.1060401@ionic.de> <539B87A3.3060801@ionic.de> <539B9FBE.2080200@ionic.de>
In-Reply-To: <539B9FBE.2080200@ionic.de>
X-Enigmail-Version: 1.6
Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha1; boundary="------------ms080208060800010108080404"
[Message part 1 (text/plain, inline)]
Basically, the addresses Sebastien has seen were "nothing more" than
uninitialized memory.

The underlaying issue was that accept() wants a socklen_t *addrlen parameter.
The original code created a size_t variable to store the size of the sockaddr
structure where information like the IP address is to be written. This value has
been, correctly, set to 16. It was then casted to (socklen_t) and given to accept().

The problem, however, is that socklen_t is defined as a 4 byte integer, while
size_t is at least 8 bytes wide on ppc64. (I highly recommend reading man 2
accept and the in the man page included Linus Torvald rant on that matter!)

This is "not a big deal" on little endian machines, as casting size_t to
socklen_t there will only cut the upper 4 bytes off and leave you with the lower
4 bytes -- which is just fine, as struct sockaddr isn't bigger than 2^32-1 bytes
anyway. 16 stays 16 in that case.

Doing the same thing on big endian machines, however, cuts the lower 4 bytes off
and leaves you with the upper 4 bytes. As the original value was "16", the upper
4 bytes were all zero.

Thus, zero was passed as the addrlen parameter to accept().

As the addrlen parameter defines how many bytes may be written to the sockaddr
structure given to accept(), the function didn't even touch addr. Hence, addr
was left in its original, un-initialized state.

It was an endianness issue after all, but not exactly where anyone would have
expected it.

The fix is trivial -- don't use size_t as the type of the addrlen variable, but
socklen_t, which will also remove the need of casting.


Mike: I hope the patch applies fine. I have quiltimported all other patches
before, so my patch is based on the patched nx-libs repository.
[nx-libs-ppc64.diff (text/plain, attachment)]
[smime.p7s (application/pkcs7-signature, attachment)]

Send a report that this bug log contains spam.


X2Go Developers <owner@bugs.x2go.org>. Last modified: Thu Mar 28 13:51:07 2024; Machine Name: ymir.das-netzwerkteam.de

X2Go Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.