Debian bug report logs - #1741
getservbyport doesn't work

Package: libc; Reported by: Ian Jackson <ijackson@chiark.chu.cam.ac.uk>; 8 days old.

Message received at debian-bugs:


From chiark.chu.cam.ac.uk!ijackson Mon Oct 23 11:11:15 1995
Return-Path: <ijackson@chiark.chu.cam.ac.uk>
Received: from pixar.com by mongo.pixar.com with smtp
	(Smail3.1.28.1 #15) id m0t7RL9-0002NhC; Mon, 23 Oct 95 11:11 PDT
Received: from artemis.chu.cam.ac.uk by pixar.com with SMTP id AA10126
  (5.67b/IDA-1.5 for debian-bugs-pipe@mongo.pixar.com); Mon, 23 Oct 1995 11:10:44 -0700
Received: from chiark.chu.cam.ac.uk by artemis.chu.cam.ac.uk with smtp
	(Smail3.1.29.1 #33) id m0t7RKx-0007uaC; Mon, 23 Oct 95 18:11 GMT
Received: by chiark.chu.cam.ac.uk
	id m0t7RKn-0002aNC
	(Debian /\oo/\ Smail3.1.29.1 #29.33); Mon, 23 Oct 95 18:10 GMT
Message-Id: <m0t7RKn-0002aNC@chiark.chu.cam.ac.uk>
Date: Mon, 23 Oct 95 18:10 GMT
From: Ian Jackson <ijackson@chiark.chu.cam.ac.uk>
To: Debian bugs submission address <debian-bugs@pixar.com>
Subject: getservbyport doesn't work

Package: libc
Version: 4.6.27

chiark:~> cat t.c
#include <netdb.h>
int main(void) {
  printf("%s\n",getservbyport(23,"tcp")->s_name);
  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
(gdb) 

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

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

Ian.

Acknowledgement sent to Ian Jackson <ijackson@chiark.chu.cam.ac.uk>:
New bug report received and forwarded. Full text available.
Report forwarded to debian-devel@pixar.com:
Bug#1741; Package libc. Full text available.
Ian Jackson / iwj10@thor.cam.ac.uk, with the debian-bugs tracking mechanism
This page last modified 07:43:01 GMT Wed 01 Nov