Fix denial of service - memory corruption.
[samba.git] / source3 / lib / packet.c
index ef28bf9f625b53b0f8ef214eaf1e0ac3fe9262d4..c14d1e51ec30a1e5edd3956288b99ccd3cb838f7 100644 (file)
@@ -106,6 +106,11 @@ NTSTATUS packet_fd_read_sync(struct packet_context *ctx)
        int res;
        fd_set r_fds;
 
+       if (ctx->fd < 0 || ctx->fd >= FD_SETSIZE) {
+               errno = EBADF;
+               return map_nt_error_from_unix(errno);
+       }
+
        FD_ZERO(&r_fds);
        FD_SET(ctx->fd, &r_fds);