From 67fa859f2ac11862142fedd59403114bcd78cb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Mon, 27 Mar 2000 14:38:09 +0200 Subject: [PATCH] More paranoid pike_make_pipe(). Rev: src/modules/files/file.c:1.167 --- src/modules/files/file.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/modules/files/file.c b/src/modules/files/file.c index 01515c4071..9bcf7538ca 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -5,7 +5,7 @@ \*/ /**/ #include "global.h" -RCSID("$Id: file.c,v 1.166 2000/03/13 16:46:50 grubba Exp $"); +RCSID("$Id: file.c,v 1.167 2000/03/27 12:38:09 grubba Exp $"); #include "fdlib.h" #include "interpret.h" #include "svalue.h" @@ -2752,7 +2752,22 @@ void pike_module_init(void) /* Used from backend */ int pike_make_pipe(int *fds) { - return socketpair(AF_UNIX, SOCK_STREAM, 0, fds); + int res = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); + if (res < 0) return res; + if ((fds[0] > MAX_OPEN_FILEDESCRIPTORS) || + (fds[1] > MAX_OPEN_FILEDESCRIPTORS)) { + close(fds[0]); + close(fds[1]); +#ifdef EMFILE + errno = EMFILE; +#else /* !EMFILE */ +#ifdef EBADF + errno = EBADF; +#endif /* EBADF */ +#endif /* EMFILE */ + return -1; + } + return res; } int fd_from_object(struct object *o) -- GitLab