Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Check for zero length read here - and return zero.



details:   https://anonhg.NetBSD.org/src/rev/b3dea1f8a72c
branches:  trunk
changeset: 748057:b3dea1f8a72c
user:      dsl <dsl%NetBSD.org@localhost>
date:      Sun Oct 11 17:20:48 2009 +0000

description:
Check for zero length read here - and return zero.
Most times we've come through spec_read() which has already done the test,
but not always (eg pty with ptsfs mounted).
Without this there is a simple local-user panic in ureadc().
Noted Matthew Mondor on tech-kern.

diffstat:

 sys/kern/tty.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 36d5bb9bf656 -r b3dea1f8a72c sys/kern/tty.c
--- a/sys/kern/tty.c    Sun Oct 11 16:30:19 2009 +0000
+++ b/sys/kern/tty.c    Sun Oct 11 17:20:48 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.233 2009/10/02 23:58:53 elad Exp $   */
+/*     $NetBSD: tty.c,v 1.234 2009/10/11 17:20:48 dsl Exp $    */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.233 2009/10/02 23:58:53 elad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.234 2009/10/11 17:20:48 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1669,6 +1669,9 @@
        long            lflag, slp;
        struct timeval  now, stime;
 
+       if (uio->uio_resid == 0)
+               return 0;
+
        stime.tv_usec = 0;      /* XXX gcc */
        stime.tv_sec = 0;       /* XXX gcc */
 



Home | Main Index | Thread Index | Old Index