Package: pilot-link
Version: 0.12.1-5
Severity: normal

Please forward this bug and patch upstream. I didn't find an easy way to
file it myself.


The "-H hostname" option from pilot-csd doesn't work because of:

pilot-link-0.12.2/src/pilot-csd.c:51
        char hostname[130];

pilot-link-0.12.2/src/pilot-csd.c:253
        struct poptOption options[] = {
                ...
        {"hostname",    'H', POPT_ARG_STRING, &hostname, 0, "The hostname used 
for verification"},
                                              ^^^^^^^^^
hostname is already the address of the beginning of that char[130] array.
Passing the address of the address doesn't work, since the address is
static and expanded during compilation.
gcc thinks itself clever enougth and silently stripps the '&' operator,
which is very wrong in this case, since popt expects it to be passed the
adress of an pointer to a character array.

pilot-link-0.12.2/popt/popt.c:890
                case POPT_ARG_STRING:
                    /* XXX memory leak, hard to plug */
                    *((const char **) opt->arg) = (con->os->nextArg)
                        ? xstrdup(con->os->nextArg) : NULL;

Instead of chaning the pointer to the command line argument option, popt
instead overwrites the first 4 characters of the string itself.

The following patch fixes this problem by replacing "hostname" to be a
pointer to a buffer named "hostname_", so popt can change it.
"hostname_" needs to be an static buffer, since fetch_host() expects a
buffer to write to.

--- pilot-link-0.12.2/src/pilot-csd.c.orig      2007-02-14 22:21:15.000000000 
+0100
+++ pilot-link-0.12.2/src/pilot-csd.c   2007-06-27 13:57:52.000000000 +0200
@@ -48,7 +48,8 @@
 #include "pi-userland.h"
 #include "pi-debug.h"
 
-char hostname[130];
+static char hostname_[130]; /* buffer fetch_host() can write to. */
+static char *hostname = hostname_; /* pointer poptGetNextOpt() can change. */
 struct in_addr address, netmask;
 
 #ifdef HAVE_SA_LEN

-- System Information:
Debian Release: 4.0
  APT prefers stable
  APT policy: (990, 'stable'), (989, 'proposed-updates'), (450, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.20.14-station
Locale: LANG=de_DE.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

Versions of packages pilot-link depends on:
ii  libc6                     2.3.6.ds1-13   GNU C Library: Shared libraries
ii  libpisock9                0.12.1-5       library for communicating with a P
ii  libpng12-0                1.2.15~beta5-1 PNG library - runtime
ii  libreadline5              5.2-2          GNU readline and history libraries

pilot-link recommends no packages.

-- debconf information excluded


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to