Browse Source

[Pal/Linux] Use MAX_FDS instead of variable length array

Isaku Yamahata 5 years ago
parent
commit
dbd1b2cf6b
1 changed files with 2 additions and 2 deletions
  1. 2 2
      Pal/src/host/Linux/db_streams.c

+ 2 - 2
Pal/src/host/Linux/db_streams.c

@@ -331,7 +331,7 @@ int _DkSendHandle (PAL_HANDLE hdl, PAL_HANDLE cargo)
 
     // Control message buffer with added space for 2 fds (ie. max size
     // that it will have)
-    char cbuf[sizeof(struct cmsghdr) + nfds * sizeof(int)];
+    char cbuf[sizeof(struct cmsghdr) + MAX_FDS * sizeof(int)];
 
     // Initialize iovec[0] with struct PAL_HANDLE
     iov[0].iov_base = hdl_data;
@@ -340,7 +340,7 @@ int _DkSendHandle (PAL_HANDLE hdl, PAL_HANDLE cargo)
     hdr.msg_iov = iov;
     hdr.msg_iovlen = 1;
     hdr.msg_control = cbuf; // Control Message Buffer
-    hdr.msg_controllen = sizeof(struct cmsghdr) + sizeof(int) * nfds;
+    hdr.msg_controllen = sizeof(cbuf);
 
     // Fill control message infomation for the file descriptors
     // Check hdr.msg_controllen >= sizeof(struct cmsghdr) to point to