From 3b2b3ebad47b657fbc6d77cc21c19124f3f9c077 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Fri, 24 Apr 2020 16:19:33 -0400 Subject: [PATCH] socket-ssl: Updated docs. Check for output sockfd=-1 from the cmd with socketSslConnectionSetSocketDescriptor. --- nx/include/switch/runtime/devices/socket.h | 4 ++-- nx/source/runtime/devices/socket.c | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nx/include/switch/runtime/devices/socket.h b/nx/include/switch/runtime/devices/socket.h index 3a552eff..58ed9d68 100644 --- a/nx/include/switch/runtime/devices/socket.h +++ b/nx/include/switch/runtime/devices/socket.h @@ -40,9 +40,9 @@ NX_INLINE Result socketInitializeDefault(void) { return socketInitialize(NULL); } -/// Wrapper for \ref sslConnectionSetSocketDescriptor. Returns the output sockfd on success. +/// Wrapper for \ref sslConnectionSetSocketDescriptor. Returns the output sockfd on success and -1 on error. errno==ENOENT indicates that no sockfd was returned, this error must be ignored. int socketSslConnectionSetSocketDescriptor(SslConnection *c, int sockfd); -/// Wrapper for \ref sslConnectionGetSocketDescriptor. Returns the output sockfd on success. +/// Wrapper for \ref sslConnectionGetSocketDescriptor. Returns the output sockfd on success and -1 on error. int socketSslConnectionGetSocketDescriptor(SslConnection *c); diff --git a/nx/source/runtime/devices/socket.c b/nx/source/runtime/devices/socket.c index 0a3b4be4..02eddf3f 100644 --- a/nx/source/runtime/devices/socket.c +++ b/nx/source/runtime/devices/socket.c @@ -156,6 +156,11 @@ int socketSslConnectionSetSocketDescriptor(SslConnection *c, int sockfd) { return -1; } + if (tmpfd==-1) { // The cmd didn't return a sockfd. This error must be ignored. + errno = ENOENT; + return -1; + } + dev = FindDevice("soc:"); if(dev == -1) return -1;