Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern pipe_read(): initialize ocnt before pipelock() call...



details:   https://anonhg.NetBSD.org/src/rev/66693ef80123
branches:  trunk
changeset: 538874:66693ef80123
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Fri Nov 01 21:34:30 2002 +0000

description:
pipe_read(): initialize ocnt before pipelock() call; it might have been
used unitialized when the pipelock() call would fail
bug found by Krister Walfridsson

diffstat:

 sys/kern/sys_pipe.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (33 lines):

diff -r dae7a9fc1b26 -r 66693ef80123 sys/kern/sys_pipe.c
--- a/sys/kern/sys_pipe.c       Fri Nov 01 21:24:19 2002 +0000
+++ b/sys/kern/sys_pipe.c       Fri Nov 01 21:34:30 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_pipe.c,v 1.27 2002/10/23 09:14:22 jdolecek Exp $   */
+/*     $NetBSD: sys_pipe.c,v 1.28 2002/11/01 21:34:30 jdolecek Exp $   */
 
 /*
  * Copyright (c) 1996 John S. Dyson
@@ -58,7 +58,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.27 2002/10/23 09:14:22 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.28 2002/11/01 21:34:30 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -612,12 +612,12 @@
 
        PIPE_LOCK(rpipe);
        ++rpipe->pipe_busy;
+       ocnt = rpipe->pipe_buffer.cnt;
+
        error = pipelock(rpipe, 1);
        if (error)
                goto unlocked_error;
 
-       ocnt = rpipe->pipe_buffer.cnt;
-
        while (uio->uio_resid) {
                /*
                 * normal pipe buffer receive



Home | Main Index | Thread Index | Old Index