Browse Source

[Pal/Linux-SGX] Fix undef behavior by initializing opt with const in get_sockopt()

Isaku Yamahata 5 years ago
parent
commit
f53c3afd95
1 changed files with 3 additions and 0 deletions
  1. 3 0
      Pal/src/host/Linux-SGX/sgx_enclave.c

+ 3 - 0
Pal/src/host/Linux-SGX/sgx_enclave.c

@@ -274,6 +274,9 @@ static int sock_getopt(int fd, struct sockopt * opt)
 {
     SGX_DBG(DBG_M, "sock_getopt (fd = %d, sockopt addr = %p) is not implemented \
             always returns 0\n", fd, opt);
+    /* initialize *opt with constant */
+    *opt = (struct sockopt){0};
+    opt->reuseaddr = 1;
     return 0;
 }