/* Close established socket */
+#if HAVE_FUNCTION_ATTRIBUTE_DESTRUCTOR
+__attribute__((destructor))
+#endif
void winbind_close_sock(void)
{
if (winbindd_fd != -1) {
switch (errno) {
case EINPROGRESS:
FD_ZERO(&w_fds);
+ if (fd < 0 || fd >= FD_SETSIZE) {
+ errno = EBADF;
+ goto error_out;
+ }
FD_SET(fd, &w_fds);
tv.tv_sec = CONNECT_TIMEOUT - wait_time;
tv.tv_usec = 0;
call would not block by calling select(). */
FD_ZERO(&r_fds);
+ if (winbindd_fd < 0 || winbindd_fd >= FD_SETSIZE) {
+ errno = EBADF;
+ winbind_close_sock();
+ return -1;
+ }
FD_SET(winbindd_fd, &r_fds);
ZERO_STRUCT(tv);
call would not block by calling select(). */
FD_ZERO(&r_fds);
+ if (winbindd_fd < 0 || winbindd_fd >= FD_SETSIZE) {
+ errno = EBADF;
+ winbind_close_sock();
+ return -1;
+ }
FD_SET(winbindd_fd, &r_fds);
ZERO_STRUCT(tv);
/* Wait for 5 seconds for a reply. May need to parameterise this... */