Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/scsipi Prompted by PR kern/47646, zero the value buf...



details:   https://anonhg.NetBSD.org/src/rev/5334f3c41faf
branches:  trunk
changeset: 785476:5334f3c41faf
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Mar 15 16:16:12 2013 +0000

description:
Prompted by PR kern/47646, zero the value buffer before running the
GET_CONFIGURATION command and check for an unexpectedly large feature
length answer afterwards.

diffstat:

 sys/dev/scsipi/cd.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (35 lines):

diff -r d721be7e265d -r 5334f3c41faf sys/dev/scsipi/cd.c
--- a/sys/dev/scsipi/cd.c       Fri Mar 15 16:14:12 2013 +0000
+++ b/sys/dev/scsipi/cd.c       Fri Mar 15 16:16:12 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd.c,v 1.309 2012/05/06 17:23:10 martin Exp $  */
+/*     $NetBSD: cd.c,v 1.310 2013/03/15 16:16:12 martin Exp $  */
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.309 2012/05/06 17:23:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.310 2013/03/15 16:16:12 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -3033,6 +3033,7 @@
                gc_cmd.opcode = GET_CONFIGURATION;
                _lto2b(last_feature, gc_cmd.start_at_feature);
                _lto2b(feat_tbl_len, gc_cmd.data_len);
+               memset(gc, 0, feat_tbl_len);
 
                error = scsipi_command(periph,
                        (void *)&gc_cmd, sizeof(gc_cmd),
@@ -3044,7 +3045,7 @@
                }
 
                features_len = _4btol(gc->data_len);
-               if (features_len < 4)
+               if (features_len < 4 || features_len > feat_tbl_len)
                        break;
 
                pos  = 0;



Home | Main Index | Thread Index | Old Index