diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-08-14 09:48:51 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2008-08-14 09:48:51 +0000 |
commit | b3e2d4f445ac1ad0e943883a3e456ed5f166d218 (patch) | |
tree | 7a1ce90171cf5cfbf46e6703f881c65e66e2f025 /usr.bin/aucat | |
parent | bbe89da068e007184794faab6172f819027c8882 (diff) |
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
Diffstat (limited to 'usr.bin/aucat')
-rw-r--r-- | usr.bin/aucat/file.c | 17 |
1 files changed, 12 insertions, 5 deletions
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 <alex@caoua.org> * @@ -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; } } |