Changeset View
Changeset View
Standalone View
Standalone View
channels.c
/* $OpenBSD: channels.c,v 1.415 2022/03/30 21:10:25 djm Exp $ */ | /* $OpenBSD: channels.c,v 1.416 2022/04/11 22:52:08 djm Exp $ */ | ||||
/* | /* | ||||
* Author: Tatu Ylonen <ylo@cs.hut.fi> | * Author: Tatu Ylonen <ylo@cs.hut.fi> | ||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | ||||
* All rights reserved | * All rights reserved | ||||
* This file contains functions for generic socket connection forwarding. | * This file contains functions for generic socket connection forwarding. | ||||
* There is also code for initiating connection forwarding for X11 connections, | * There is also code for initiating connection forwarding for X11 connections, | ||||
* arbitrary tcp/ip connections, and the authentication agent connection. | * arbitrary tcp/ip connections, and the authentication agent connection. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 2,586 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
channel_prepare_poll(struct ssh *ssh, struct pollfd **pfdp, u_int *npfd_allocp, | channel_prepare_poll(struct ssh *ssh, struct pollfd **pfdp, u_int *npfd_allocp, | ||||
u_int *npfd_activep, u_int npfd_reserved, time_t *minwait_secs) | u_int *npfd_activep, u_int npfd_reserved, time_t *minwait_secs) | ||||
{ | { | ||||
struct ssh_channels *sc = ssh->chanctxt; | struct ssh_channels *sc = ssh->chanctxt; | ||||
u_int i, oalloc, p, npfd = npfd_reserved; | u_int i, oalloc, p, npfd = npfd_reserved; | ||||
channel_before_prepare_io(ssh); /* might create a new channel */ | channel_before_prepare_io(ssh); /* might create a new channel */ | ||||
/* clear out I/O flags from last poll */ | |||||
for (i = 0; i < sc->channels_alloc; i++) { | |||||
if (sc->channels[i] == NULL) | |||||
continue; | |||||
sc->channels[i]->io_want = sc->channels[i]->io_ready = 0; | |||||
} | |||||
/* Allocate 4x pollfd for each channel (rfd, wfd, efd, sock) */ | /* Allocate 4x pollfd for each channel (rfd, wfd, efd, sock) */ | ||||
emaste: this is a fix from the V_9_0 branch upstream | |||||
if (sc->channels_alloc >= (INT_MAX / 4) - npfd_reserved) | if (sc->channels_alloc >= (INT_MAX / 4) - npfd_reserved) | ||||
fatal_f("too many channels"); /* shouldn't happen */ | fatal_f("too many channels"); /* shouldn't happen */ | ||||
if (!ssh_packet_is_rekeying(ssh)) | if (!ssh_packet_is_rekeying(ssh)) | ||||
npfd += sc->channels_alloc * 4; | npfd += sc->channels_alloc * 4; | ||||
if (npfd > *npfd_allocp) { | if (npfd > *npfd_allocp) { | ||||
*pfdp = xrecallocarray(*pfdp, *npfd_allocp, | *pfdp = xrecallocarray(*pfdp, *npfd_allocp, | ||||
npfd, sizeof(**pfdp)); | npfd, sizeof(**pfdp)); | ||||
*npfd_allocp = npfd; | *npfd_allocp = npfd; | ||||
▲ Show 20 Lines • Show All 2,520 Lines • Show Last 20 Lines |
this is a fix from the V_9_0 branch upstream