Branch oldpackages for 14.07
[14.07/packages.git] / libs / ftplib / patches / 002-check_getserv_by_name.patch
1 Description: Verify value returned by getservbyname
2  getservbyname() can return a NULL pointer and dereferencing it
3  would lead to a segfault.
4  .
5  The patch is not forwarded upstream but there's no real maintainance
6  upstream any more.
7 Origin: vendor, see changelog entry 3.1-1-2
8 Author: Richard Braakman <dark@xs4all.nl>
9 Last-Update: 2009-10-29
10 Forwarded: no
11
12 diff --git a/linux/ftplib.c b/linux/ftplib.c
13 index 9089a5b..c4a5873 100644
14 --- a/src/ftplib.c
15 +++ b/src/ftplib.c
16 @@ -416,7 +416,11 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
17             sin.sin_port = htons(atoi(pnum));
18         else
19         {
20 -           pse = getservbyname(pnum,"tcp");
21 +           if ((pse = getservbyname(pnum,"tcp")) == NULL)
22 +            {
23 +                perror("getservbyname");
24 +                return 0;
25 +            }
26             sin.sin_port = pse->s_port;
27         }
28      }