From: ratchov Date: Thu, 14 Aug 2008 09:48:50 +0000 (+0000) Subject: in file.c, before dereferencing pointers to in(), out(), eof(), X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7e50537fcc72f901b172c4aad88a7986de05c727;p=openbsd in file.c, before dereferencing pointers to in(), out(), eof(), hup() routines of the aproc strucure check that the aproc structure has not desappeared. This never happens currently, but will be allowed later. No behaviour change. ok jakemsr --- diff --git a/usr.bin/aucat/file.c b/usr.bin/aucat/file.c index bb1d724ea70..7aae942925d 100644 --- a/usr.bin/aucat/file.c +++ b/usr.bin/aucat/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.1 2008/05/23 07:15:46 ratchov Exp $ */ +/* $OpenBSD: file.c,v 1.2 2008/08/14 09:48:50 ratchov Exp $ */ /* * Copyright (c) 2008 Alexandre Ratchov * @@ -87,6 +87,7 @@ file_poll(void) struct pollfd pfds[MAXFDS]; struct pollfd *pfd; struct file *f, *fnext; + struct aproc *p; nfds = 0; #ifdef DEBUG @@ -139,7 +140,8 @@ file_poll(void) f->state |= FILE_ROK; DPRINTFN(3, "file_poll: %s rok\n", f->name); while (f->state & FILE_ROK) { - if (!f->rproc->ops->in(f->rproc, NULL)) + p = f->rproc; + if (!p || !p->ops->in(p, NULL)) break; } } @@ -148,7 +150,8 @@ file_poll(void) f->state |= FILE_WOK; DPRINTFN(3, "file_poll: %s wok\n", f->name); while (f->state & FILE_WOK) { - if (!f->wproc->ops->out(f->wproc, NULL)) + p = f->wproc; + if (!p || !p->ops->out(p, NULL)) break; } } @@ -156,12 +159,16 @@ file_poll(void) LIST_FOREACH(f, &file_list, entry) { if (f->state & FILE_EOF) { DPRINTFN(2, "file_poll: %s: eof\n", f->name); - f->rproc->ops->eof(f->rproc, NULL); + p = f->rproc; + if (p) + p->ops->eof(p, NULL); f->state &= ~FILE_EOF; } if (f->state & FILE_HUP) { DPRINTFN(2, "file_poll: %s hup\n", f->name); - f->wproc->ops->hup(f->wproc, NULL); + p = f->wproc; + if (p) + p->ops->hup(p, NULL); f->state &= ~FILE_HUP; } }