libc6 2.2.1 malloc() bug
I have just setup a chroot woody installation and have found that the
hostname utility fails with a seg fault.
sparks:/# hostname
(null)
sparks:/# hostname -f
Segmentation fault
After a little investigation I have tracked it down to the first call to
malloc() always setting errno even when it succeeds. The hostname utility
relies on errno remaining zero after a successful malloc().
Here is a little test program:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int
main
( int argc,
char *argv[]
)
{ char *p;
errno = 0;
p = malloc(128);
printf("1st malloc %s - errno = %d\n",
(p == NULL) ? "failed" : "succeeded",
errno
);
errno = 0;
p = malloc(128);
printf("2nd malloc %s - errno = %d\n",
(p == NULL) ? "failed" : "succeeded",
errno
);
}
This is what it produced:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err:
uppercase=bad)
||/ Name Version Description
+++-==============-==============-==========================================
==
ii libc6 2.1.3-13 GNU C Library: Shared libraries and
Timezone
1st malloc succeeded - errno = 0
2nd malloc succeeded - errno = 0
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Installed/Config-files/Unpacked/Failed-config/Half-installed
|/ Err?=(none)/Hold/Reinst-required/X=both-problems (Status,Err:
uppercase=bad)
||/ Name Version Description
+++-==============-==============-==========================================
==
ii libc6 2.2.1-1 GNU C Library: Shared libraries and
Timezone
1st malloc succeeded - errno = 38
2nd malloc succeeded - errno = 0
Sorry just a report, no fix.
Nick
----------------------------------------------------------------
Nick Holgate <holgate@debian.org>
GPG key from public servers : Key ID FD9C18AF
Fingerprint = 9DCA EDEA D5C5 57DA 23F3 1A2B 2273 5645 FD9C 18AF
Reply to: