summaryrefslogtreecommitdiffstats
path: root/otherlibs/win32unix/socket.c
diff options
context:
space:
mode:
authorJonathan Protzenko <Jonathan.Protzenko@ens-lyon.org>2012-01-30 16:07:18 +0000
committerJonathan Protzenko <Jonathan.Protzenko@ens-lyon.org>2012-01-30 16:07:18 +0000
commit824179a92fe789e5e26ab39538693fdf279c9ea0 (patch)
tree1396ba82e6c5d4ecf67bbd717313541cfbcb576c /otherlibs/win32unix/socket.c
parentd9d4bd2ad0da783ba008cc8d9d41f55255ce3c57 (diff)
Partial fix for #5398: at least avoid an out-of-bounds access.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@12104 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'otherlibs/win32unix/socket.c')
-rw-r--r--otherlibs/win32unix/socket.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/otherlibs/win32unix/socket.c b/otherlibs/win32unix/socket.c
index 37ad175d2..dc7a157c0 100644
--- a/otherlibs/win32unix/socket.c
+++ b/otherlibs/win32unix/socket.c
@@ -17,7 +17,7 @@
#include "unixsupport.h"
int socket_domain_table[] = {
- PF_UNIX, PF_INET
+ PF_UNIX, PF_INET /*, PF_INET6 */
};
int socket_type_table[] = {
@@ -28,6 +28,13 @@ CAMLprim value unix_socket(domain, type, proto)
value domain, type, proto;
{
SOCKET s;
+
+ /* IPv6 requires WinSock2, we must raise an error on PF_INET6 */
+ if (Int_val(domain) >= sizeof(socket_domain_table)/sizeof(int)) {
+ win32_maperr(WSAEPFNOSUPPORT);
+ uerror("socket", Nothing);
+ }
+
s = socket(socket_domain_table[Int_val(domain)],
socket_type_table[Int_val(type)],
Int_val(proto));