Package: cvsps
Version: 2.1-4
Severity: normal
Tags: patch
The direct cvs code incorrectly converts the hostname to an IP address,
by doing a wrong check with the result of the inet_addr call.
The code does (at line 201 in file cbtcommon/tcp_socket.c):
if ( (*dest = inet_addr(addr_str)) != -1)
but here *dest is a long, which is signed and on 64 bit arches has a
different size than the actual return address of inet_addr (in_addr_t)
which is unsigned int. As such, the comparison fails, and the test is
always considered successful, and it will generate the known "Network
unreachable" message when running git-cvsimport. On 32bit arches, due to
the same size, the code will run correctly.
Per
http://www.opengroup.org/onlinepubs/000095399/functions/inet_addr.html,
it is simply enough to test the return value against (in_addr_t)(-1),
which I can confirm works on both 32 and 64 bit. Patch attached.
Side note: the function in cause also has a different codepath for
#ifdef LINUX, but this define is not used anywhere else; the same
problem can be solved (at least on Debian) by modifying in Makefile the
CFLAGS and adding -DLINUX.
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1,
'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.25.8-teal (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages cvsps depends on:
ii cvs 1:1.12.13-11 Concurrent Versions System
ii libc6 2.7-12 GNU C Library: Shared libraries
ii zlib1g 1:1.2.3.3.dfsg-12 compression library - runtime
cvsps recommends no packages.
-- no debconf information
#! /bin/sh /usr/share/dpatch/dpatch-run
## 05-inet_addr_fix.dpatch by Iustin Pop <[EMAIL PROTECTED]>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Fix the inet_addr result check with correct type casting
@DPATCH@
diff -urN cvsps-2.1.orig/cbtcommon/tcpsocket.c cvsps-2.1/cbtcommon/tcpsocket.c
--- cvsps-2.1.orig/cbtcommon/tcpsocket.c 2005-05-26 05:39:40.000000000
+0200
+++ cvsps-2.1/cbtcommon/tcpsocket.c 2008-07-04 07:45:08.571962583 +0200
@@ -198,7 +198,7 @@
memcpy(dest, &ip.s_addr, sizeof(ip.s_addr));
}
#else
- if ( (*dest = inet_addr(addr_str)) != -1)
+ if ( (*dest = inet_addr(addr_str)) != (in_addr_t)-1)
{
/* nothing */
}