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

Bug#1741: getservbyport doesn't work

Package: libc
Version: 4.6.27

chiark:~> cat t.c
#include <netdb.h>
int main(void) {
  return 0;
chiark:~> gcc t.c
chiark:~> ./a.out
Segmentation fault (core dumped)
chiark:~> gcc -g t.c
chiark:~> gdb a.out
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.14 (i486-debian-linux), Copyright 1995 Free Software Foundation, Inc...
(gdb) print getservbyport(23,"tcp")
You can't do that without a process to debug
(gdb) run
Starting program: /u/ijackson/a.out

Program received signal SIGSEGV, Segmentation fault.
0x109d in main () at t.c:3
3         printf("%s\n",getservbyport(23,"tcp")->s_name);
(gdb) print getservbyport(23,"tcp")
$1 = (struct servent *) 0x0

getservbyport is returning NULL inappropriately, so the test program
dereferences zero and dumps core.

On a SunOS4 machine:
grus:~/junk> ./a.out


Reply to: