From 34c089b9ad7ad25dc0d43f304e68e20320e9b281 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sun, 9 Jan 2011 08:01:14 +0000 Subject: [PATCH] - protect against socket signal in ftp server --- .../shared_lib/sources/feathery_ftp/ftpTargetPosix.c | 7 ++++++- .../shared_lib/sources/feathery_ftp/ftpTargetWin32.c | 11 +++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c b/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c index ad30dd43c..5b27ee32a 100644 --- a/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c +++ b/source/shared_lib/sources/feathery_ftp/ftpTargetPosix.c @@ -189,7 +189,12 @@ int ftpSend(socket_t s, const void *data, int len) do { - currLen = send(s, data, len, 0); +#ifdef __APPLE__ + currLen = send(s, data, len, SO_NOSIGPIPE); +#else + currLen = send(s, data, len, MSG_NOSIGNAL); +#endif + if(currLen >= 0) { len -= currLen; diff --git a/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c b/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c index 49668482e..a9626097c 100644 --- a/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c +++ b/source/shared_lib/sources/feathery_ftp/ftpTargetWin32.c @@ -31,6 +31,8 @@ #pragma comment(lib, "ws2_32") #pragma comment(lib, "MSWSOCK") + +#define MSG_NOSIGNAL 0 ip_t ownIp; @@ -218,8 +220,13 @@ int ftpSend(socket_t s, const void *data, int len) int currLen = 0; do - { - currLen = send((SOCKET)s, data, len, 0); + { +#ifdef __APPLE__ + currLen = send((SOCKET)s, data, len, SO_NOSIGPIPE); +#else + currLen = send((SOCKET)s, data, len, MSG_NOSIGNAL); +#endif + if(currLen >= 0) { len -= currLen;