]> git.sesse.net Git - vlc/blobdiff - src/network/httpd.c
Use strlcpy()
[vlc] / src / network / httpd.c
index e54bcca244c9ee504264dbb04de8dd9c2bb16289..26d0f4cd13a4918051262308558c9440e6cffeb5 100644 (file)
@@ -2436,6 +2436,7 @@ static void httpd_HostThread( httpd_host_t *host )
                 struct  sockaddr_storage sock;
 
                 fd = accept( fd, (struct sockaddr *)&sock, &i_sock_size );
+
                 if( fd >= 0 )
                 {
                     int i_state = 0;
@@ -2447,9 +2448,20 @@ static void httpd_HostThread( httpd_host_t *host )
                         ioctlsocket( fd, FIONBIO, &i_dummy );
                     }
 #else
-                    fcntl( fd, F_SETFL, O_NONBLOCK );
-#endif
+                    fcntl( fd, F_SETFD, FD_CLOEXEC );
+                    {
+                        int i_val = fcntl( fd, F_GETFL );
+                        fcntl( fd, F_SETFL,
+                               O_NONBLOCK | (i_val != -1) ? i_val : 0 );
+                    }
 
+                    if( fd >= FD_SETSIZE )
+                    {
+                        net_Close( fd );
+                        fd = -1;
+                    }
+                    else
+#endif
                     if( p_tls != NULL)
                     {
                         switch ( tls_ServerSessionHandshake( p_tls, fd ) )