From df4a780888a5d9923bd9e4fc3465f316b99bcb0a Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Sun, 8 Oct 2000 13:15:33 +0000 Subject: [PATCH] (*): check that fds are not too large to select on git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@9097 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/ftp.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/appl/ftp/ftp/ftp.c b/appl/ftp/ftp/ftp.c index 617c04fc5..9b29ed812 100644 --- a/appl/ftp/ftp/ftp.c +++ b/appl/ftp/ftp/ftp.c @@ -530,9 +530,9 @@ empty (fd_set * mask, int sec) { struct timeval t; - t.tv_sec = (long) sec; + t.tv_sec = sec; t.tv_usec = 0; - return (select (32, mask, NULL, NULL, &t)); + return (select (FD_SETSIZE, mask, NULL, NULL, &t)); } jmp_buf sendabort; @@ -1627,6 +1627,8 @@ abort: pswitch (!proxy); if (cpend) { FD_ZERO (&mask); + if (fileno(cin) >= FD_SETSIZE) + errx (1, "fd too large"); FD_SET (fileno (cin), &mask); if ((nfnd = empty (&mask, 10)) <= 0) { if (nfnd < 0) { @@ -1655,6 +1657,8 @@ reset (int argc, char **argv) FD_ZERO (&mask); while (nfnd > 0) { + if (fileno (cin) >= FD_SETSIZE) + errx (1, "fd too large"); FD_SET (fileno (cin), &mask); if ((nfnd = empty (&mask, 0)) < 0) { warn ("reset"); @@ -1728,8 +1732,12 @@ abort_remote (FILE * din) fprintf (cout, "%cABOR\r\n", DM); fflush (cout); FD_ZERO (&mask); + if (fileno (cin) >= FD_SETSIZE) + errx (1, "fd too large"); FD_SET (fileno (cin), &mask); if (din) { + if (fileno (din) >= FD_SETSIZE) + errx (1, "fd too large"); FD_SET (fileno (din), &mask); } if ((nfnd = empty (&mask, 10)) <= 0) {