summaryrefslogtreecommitdiffstats
path: root/libftp/ftplib.c
diff options
context:
space:
mode:
Diffstat (limited to 'libftp/ftplib.c')
-rw-r--r--libftp/ftplib.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libftp/ftplib.c b/libftp/ftplib.c
index f312db89..004ede87 100644
--- a/libftp/ftplib.c
+++ b/libftp/ftplib.c
@@ -411,14 +411,18 @@ GLOBALDEF int FtpConnect(const char *host, netbuf **nControl)
}
else
{
- *pnum++ = '\0';
- if (isdigit(*pnum))
- sin.sin_port = htons(atoi(pnum));
- else
- {
- pse = getservbyname(pnum,"tcp");
- sin.sin_port = pse->s_port;
- }
+ *pnum++ = '\0';
+ if (isdigit(*pnum))
+ sin.sin_port = htons(atoi(pnum));
+ else
+ {
+ pse = getservbyname(pnum,"tcp");
+ if(pse == NULL) {
+ perror("getservbyname");
+ return 0;
+ }
+ sin.sin_port = pse->s_port;
+ }
}
if ((sin.sin_addr.s_addr = inet_addr(lhost)) == -1)
{