浏览代码

Kernel: Return ENOPROTOOPT instead of asserting on unimplemented levels in getsockopt

Luke 4 年之前
父节点
当前提交
ec136db592
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      Kernel/Net/Socket.cpp

+ 6 - 1
Kernel/Net/Socket.cpp

@@ -156,7 +156,12 @@ KResult Socket::getsockopt(FileDescription&, int level, int option, Userspace<vo
     if (!copy_from_user(&size, value_size.unsafe_userspace_ptr()))
     if (!copy_from_user(&size, value_size.unsafe_userspace_ptr()))
         return KResult(-EFAULT);
         return KResult(-EFAULT);
 
 
-    ASSERT(level == SOL_SOCKET);
+    // FIXME: Add TCP_NODELAY, IPPROTO_TCP and IPPROTO_IP (used in OpenSSH)
+    if (level != SOL_SOCKET) {
+        // Not sure if this is the correct error code, but it's only temporary until other levels are implemented.
+        return KResult(-ENOPROTOOPT);
+    }
+
     switch (option) {
     switch (option) {
     case SO_SNDTIMEO:
     case SO_SNDTIMEO:
         if (size < sizeof(timeval))
         if (size < sizeof(timeval))