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

Bug#543379: libc6: Valgrind says getprotobyname(3) performs an invalid read



Package: libc6
Version: 2.7-18
Severity: normal

Valgrind says getprotobyname(3) performs an invalid read.

Compile and (valgrind-)execute the following C code:

/* main.c
 * compile with: gcc main.c
 * valgrind-execute with: valgrind --tool=memcheck --partial-loads-ok=no ./a.out
 */
#include <netdb.h>
int main(int argc, char ** argv) {
    getprotobyname("tcp");
}


You will get the followin output:
==4325== Memcheck, a memory error detector.
==4325== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==4325== Using LibVEX rev 1854, a library for dynamic binary translation.
==4325== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==4325== Using valgrind-3.3.1-Debian, a dynamic binary instrumentation framework.
==4325== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==4325== For more details, rerun with: -v
==4325==
==4325== Invalid read of size 4
==4325==    at 0x4015847: (within /lib/ld-2.7.so)
==4325==    by 0x4158131: (within /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x400DA15: (within /lib/ld-2.7.so)
==4325==    by 0x41582F4: __libc_dlopen_mode (in /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x41306DF: __nss_lookup_function (in /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x41307CF: (within /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x41324D5: (within /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x41389F0: getprotobyname_r (in /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x41387E6: getprotobyname (in /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x80483C0: main (in /tmp/a.out)
==4325==  Address 0x4199f74 is 44 bytes inside a block of size 46 alloc'd
==4325==    at 0x4023D6E: malloc (vg_replace_malloc.c:207)
==4325==    by 0x400DB23: (within /lib/ld-2.7.so)
==4325==    by 0x4008555: (within /lib/ld-2.7.so)
==4325==    by 0x4011B46: (within /lib/ld-2.7.so)
==4325==    by 0x400DA15: (within /lib/ld-2.7.so)
==4325==    by 0x401154D: (within /lib/ld-2.7.so)
==4325==    by 0x4158131: (within /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x400DA15: (within /lib/ld-2.7.so)
==4325==    by 0x41582F4: __libc_dlopen_mode (in /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x41306DF: __nss_lookup_function (in /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x41307CF: (within /lib/i686/cmov/libc-2.7.so)
==4325==    by 0x41324D5: (within /lib/i686/cmov/libc-2.7.so)
==4325==
==4325== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 30 from 3)
==4325== malloc/free: in use at exit: 0 bytes in 0 blocks.
==4325== malloc/free: 43 allocs, 43 frees, 3,591 bytes allocated.
==4325== For counts of detected errors, rerun with: -v
==4325== All heap blocks were freed -- no leaks are possible.

If you valgrind-execute ignoring partial-loads, you wont get the error:
valgrind --tool=memcheck --partial-loads-ok=yes ./a.out
==4326== Memcheck, a memory error detector.
==4326== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==4326== Using LibVEX rev 1854, a library for dynamic binary translation.
==4326== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==4326== Using valgrind-3.3.1-Debian, a dynamic binary instrumentation framework.
==4326== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==4326== For more details, rerun with: -v
==4326==
==4326==
==4326== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 29 from 2)
==4326== malloc/free: in use at exit: 0 bytes in 0 blocks.
==4326== malloc/free: 43 allocs, 43 frees, 3,591 bytes allocated.
==4326== For counts of detected errors, rerun with: -v
==4326== All heap blocks were freed -- no leaks are possible.


-- System Information:
Debian Release: 5.0.2
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: i386 (i686)

Kernel: Linux 2.6.29.1
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libc6 depends on:
ii  libgcc1                      1:4.3.2-1.1 GCC support library

libc6 recommends no packages.

Versions of packages libc6 suggests:
ii  glibc-doc                     2.7-18     GNU C Library: Documentation
ii  libc6-i686                    2.7-18     GNU C Library: Shared libraries [i
ii  locales                       2.7-18     GNU C Library: National Language (

-- debconf information:
  glibc/upgrade: true
  glibc/restart-failed:
* glibc/restart-services: ssh rsync openbsd-inetd exim4 cron atd



Reply to: