diff --git a/legacy/evil/ChangeLog b/legacy/evil/ChangeLog index 24a73d9b15..2f16d88fdb 100644 --- a/legacy/evil/ChangeLog +++ b/legacy/evil/ChangeLog @@ -1,3 +1,13 @@ +2010-01-30 Vincent Torri + + * src/lib/evil_fcntl.c: + verify that the data passed to fcntl() is really a socket + and fix ioctlsocket() returned value check. + + * src/bin/Makefile.am: + * src/bin/evil_suite.c: + add unit test for pipe(). + 2010-01-30 Vincent Torri * src/lib/Evil.h: diff --git a/legacy/evil/src/bin/Makefile.am b/legacy/evil/src/bin/Makefile.am index ac9bb5797a..ec3a4bb023 100644 --- a/legacy/evil/src/bin/Makefile.am +++ b/legacy/evil/src/bin/Makefile.am @@ -20,6 +20,7 @@ evil_test_gettimeofday.c \ evil_test_link.c \ evil_test_memcpy.c \ evil_test_mkstemp.c \ +evil_test_pipe.c \ evil_test_realpath.c if EVIL_HAVE_WINCE diff --git a/legacy/evil/src/bin/evil_suite.c b/legacy/evil/src/bin/evil_suite.c index 190362ebec..cee01cc95b 100644 --- a/legacy/evil/src/bin/evil_suite.c +++ b/legacy/evil/src/bin/evil_suite.c @@ -17,6 +17,7 @@ #include "evil_test_link.h" #include "evil_test_memcpy.h" #include "evil_test_mkstemp.h" +#include "evil_test_pipe.h" #include "evil_test_realpath.h" @@ -182,6 +183,7 @@ main() { "gettimeofday", test_gettimeofday }, { "link ", test_link }, { "mkstemp ", test_mkstemp }, + { "pipe ", test_pipe }, { "realpath ", test_realpath }, /* { "memcpy ", test_memcpy }, */ { NULL, NULL }, diff --git a/legacy/evil/src/lib/evil_fcntl.c b/legacy/evil/src/lib/evil_fcntl.c index 68618c528f..accc42c963 100644 --- a/legacy/evil/src/lib/evil_fcntl.c +++ b/legacy/evil/src/lib/evil_fcntl.c @@ -75,8 +75,17 @@ int fcntl(int fd, int cmd, ...) if (flag == O_NONBLOCK) { u_long arg = 1; - if (ioctlsocket((SOCKET)fd, FIONBIO, &arg) == SOCKET_ERROR) - res = 0; + int type; + int len; + int ret; + + len = (int)sizeof(int); + ret = getsockopt((SOCKET)fd, SOL_SOCKET, SO_TYPE, (char *)&type, &len); + if (!ret && (type == SOCK_STREAM)) + { + if (!ioctlsocket((SOCKET)fd, FIONBIO, &arg) == SOCKET_ERROR) + res = 0; + } } } #if ! ( defined(__CEGCC__) || defined(__MINGW32CE__) )