1 Description: Verify value returned by getservbyname
2 getservbyname() can return a NULL pointer and dereferencing it
3 would lead to a segfault.
5 The patch is not forwarded upstream but there's no real maintainance
7 Origin: vendor, see changelog entry 3.1-1-2
8 Author: Richard Braakman <dark@xs4all.nl>
9 Last-Update: 2009-10-29
12 diff --git a/linux/ftplib.c b/linux/ftplib.c
13 index 9089a5b..c4a5873 100644
16 @@ -416,7 +416,11 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
17 sin.sin_port = htons(atoi(pnum));
20 - pse = getservbyname(pnum,"tcp");
21 + if ((pse = getservbyname(pnum,"tcp")) == NULL)
23 + perror("getservbyname");
26 sin.sin_port = pse->s_port;