From 8e620c269ddc4116076280aa2bf085b06a47ca02 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 2 Jul 2015 18:53:16 -0400 Subject: [PATCH] Fixed socket() error handling when cmdbuf[2] is actually an error-code, not a handle. In socket(), write SYNC_ERROR to errno when an error occurs due to cmdbuf[1]. --- libctru/source/services/soc/soc_socket.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libctru/source/services/soc/soc_socket.c b/libctru/source/services/soc/soc_socket.c index 5072275..bf02700 100644 --- a/libctru/source/services/soc/soc_socket.c +++ b/libctru/source/services/soc/soc_socket.c @@ -41,9 +41,11 @@ int socket(int domain, int type, int protocol) } ret = (int)cmdbuf[1]; - if(ret != 0) { + if(ret == 0)ret = cmdbuf[2]; + if(ret < 0) { __release_handle(fd); - errno = _net_convert_error(cmdbuf[2]); + if(cmdbuf[1] == 0)errno = _net_convert_error(ret); + if(cmdbuf[1] != 0)errno = SYNC_ERROR; return -1; }