Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/sun If the sector size is 0, return early in readdis...



details:   https://anonhg.NetBSD.org/src/rev/634df63f480f
branches:  trunk
changeset: 932250:634df63f480f
user:      jdc <jdc%NetBSD.org@localhost>
date:      Sun May 03 06:31:02 2020 +0000

description:
If the sector size is 0, return early in readdisklabel().
Prevents a panic trying to use a 0-sized buffer, which can happen if we run
(e.g.) `scsictl /dev/cd0c identify` with no medium in the CD drive.

diffstat:

 sys/dev/sun/disksubr.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r dfd0fa782e5b -r 634df63f480f sys/dev/sun/disksubr.c
--- a/sys/dev/sun/disksubr.c    Sun May 03 06:30:45 2020 +0000
+++ b/sys/dev/sun/disksubr.c    Sun May 03 06:31:02 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr.c,v 1.16 2019/04/03 22:10:52 christos Exp $ */
+/*     $NetBSD: disksubr.c,v 1.17 2020/05/03 06:31:02 jdc Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1988 Regents of the University of California.
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.16 2019/04/03 22:10:52 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr.c,v 1.17 2020/05/03 06:31:02 jdc Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -104,6 +104,8 @@
                        lp->d_partitions[RAW_PART].p_size = 0x1fffffff;
                lp->d_partitions[RAW_PART].p_offset = 0;
        }
+       if (lp->d_secsize == 0)
+               return ("sector size 0");
 
        /* obtain buffer to probe drive with */
        bp = geteblk((int)lp->d_secsize);



Home | Main Index | Thread Index | Old Index