[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#501435: glibc-doc-reference: socket connection server example segfaults on 64bits due to missing arpa/inet.h header



Package: glibc-doc-reference
Version: 2.7-1
Severity: normal


The example of socket server in the info file is buggy on 64 bits.

(File: libc.info, Node: Connections, Next: Datagrams, Prev: Open/Close
Sockets, Up: Sockets)

It is doing segfault on x86-64 (and probably on most 64 bits architecture)
due to the usage of inet_ntoa() without its header 
#include <arpa/inet.h>

It is segfaulting in the fprintf line 107 :

 fprintf (stderr,
                              "Server: connect from host %s, port %hd.\n",
                              inet_ntoa (clientname.sin_addr),
                              ntohs (clientname.sin_port));

The return value of inet_ntoa() is defaulted to int (4 bytes) instead
of the char* (8 bytes). Thus the %s of the fprintf access a wrong
memory address.



-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

-- no debconf information



Reply to: