diff options
Diffstat (limited to 'net-libs/ftplib/files/ftplib-4.0-crash.patch')
-rw-r--r-- | net-libs/ftplib/files/ftplib-4.0-crash.patch | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/net-libs/ftplib/files/ftplib-4.0-crash.patch b/net-libs/ftplib/files/ftplib-4.0-crash.patch new file mode 100644 index 000000000000..c984e2d81b19 --- /dev/null +++ b/net-libs/ftplib/files/ftplib-4.0-crash.patch @@ -0,0 +1,116 @@ +include sys/select.h for the select() prototype on unix systems. + +fix warning about using chars as subscripts in arrays. on many systems, isdigit +turns into an index of an array, so the pnum char needs to be casted to an int. +the spec says these funcs take an int, not a char. + +fix warnings about the rv return value being uninitialized in FtpAcceptConnection. + +fix a crasher in FtpClose where it derefs the ctrl pointer before checking +if it's NULL. + +fix the FtpQuit API to return 0/1 as it's documented so the caller can detect. + +patch by Mike Frysinger <vapier@gentoo.org> + +--- a/src/ftplib.c ++++ b/src/ftplib.c +@@ -31,6 +32,7 @@ + #if defined(__unix__) + #include <sys/time.h> + #include <sys/types.h> ++#include <sys/select.h> + #include <sys/socket.h> + #include <netinet/in.h> + #include <netdb.h> +@@ -453,7 +456,7 @@ GLOBALDEF int FtpConnect(const char *hos + pnum = "ftp"; + else + *pnum++ = '\0'; +- if (isdigit(*pnum)) ++ if (isdigit((int)*pnum)) + sin.sin_port = htons(atoi(pnum)); + else + { +@@ -841,7 +862,7 @@ static int FtpAcceptConnection(netbuf *n + int i; + struct timeval tv; + fd_set mask; +- int rv; ++ int rv = 0; + + FD_ZERO(&mask); + FD_SET(nControl->handle, &mask); +@@ -858,14 +879,12 @@ static int FtpAcceptConnection(netbuf *n + sizeof(nControl->response)); + net_close(nData->handle); + nData->handle = 0; +- rv = 0; + } + else if (i == 0) + { + strcpy(nControl->response, "timed out waiting for connection"); + net_close(nData->handle); + nData->handle = 0; +- rv = 0; + } + else + { +@@ -885,7 +904,6 @@ static int FtpAcceptConnection(netbuf *n + strncpy(nControl->response, strerror(i), + sizeof(nControl->response)); + nData->handle = 0; +- rv = 0; + } + } + else if (FD_ISSET(nControl->handle, &mask)) +@@ -893,7 +911,6 @@ static int FtpAcceptConnection(netbuf *n + net_close(nData->handle); + nData->handle = 0; + readresp('2', nControl); +- rv = 0; + } + } + return rv; +@@ -1054,10 +1054,11 @@ GLOBALDEF int FtpClose(netbuf *nData) + net_close(nData->handle); + ctrl = nData->ctrl; + free(nData); +- ctrl->data = NULL; +- if (ctrl && ctrl->response[0] != '4' && ctrl->response[0] != 5) ++ if (ctrl) + { +- return(readresp('2', ctrl)); ++ ctrl->data = NULL; ++ if (ctrl->response[0] != '4' && ctrl->response[0] != 5) ++ return readresp('2', ctrl); + } + return 1; + case FTPLIB_CONTROL: +@@ -1442,12 +1443,13 @@ GLOBALDEF int FtpDelete(const char *fnm, netbuf *nControl) + * + * return 1 if successful, 0 otherwise + */ +-GLOBALDEF void FtpQuit(netbuf *nControl) ++GLOBALDEF int FtpQuit(netbuf *nControl) + { + if (nControl->dir != FTPLIB_CONTROL) +- return; ++ return 0; + FtpSendCmd("QUIT",'2',nControl); + net_close(nControl->handle); + free(nControl->buf); + free(nControl); ++ return 1; + } +--- a/src/ftplib.h ++++ b/src/ftplib.h +@@ -111,7 +111,7 @@ GLOBALREF int FtpPut(const char *input, const char *path, char mode, + netbuf *nControl); + GLOBALREF int FtpRename(const char *src, const char *dst, netbuf *nControl); + GLOBALREF int FtpDelete(const char *fnm, netbuf *nControl); +-GLOBALREF void FtpQuit(netbuf *nControl); ++GLOBALREF int FtpQuit(netbuf *nControl); + + #ifdef __cplusplus + }; |