This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Strange getservbyname behaviour
- From: "Tuninetto, Paolo" <Paolo dot Tuninetto at hp dot com>
- To: <bug-glibc at gnu dot org>, <libc-alpha at sources dot redhat dot com>
- Date: Thu, 28 Nov 2002 16:37:05 +0100
- Subject: Strange getservbyname behaviour
Hi, I was trying to compile the ftpd from GNU inteutils and I found that when I try to run ftpd -D (daemon mode) it opens a connection on the 5376 port instead of the default 21.
Looking at the rource and it seems that there is a problem with the getservbyname function call that ftpd is using.
This is a simple test program. Afaik it should reply with PORT: 21 but the reply I get is PORT: 5376 (5376 = 21*256)
I get the same strange behaviour using any other servise/protocol (defined in my /etc/services) and also using the getservbyport function...
#include <stdio.h>
#include <netdb.h>
int main() {
struct servent *s;
s = getservbyname("ftp","tcp");
if (s == NULL)
printf("NULL!\n");
else
printf("PORT: %d\n", s->s_port);
}
Thanks in advance,
Paolo