Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Avoid division by zero if label isn't valid.
details: https://anonhg.NetBSD.org/src/rev/fd47dfad4286
branches: trunk
changeset: 1008580:fd47dfad4286
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Fri Mar 27 11:13:57 2020 +0000
description:
Avoid division by zero if label isn't valid.
diffstat:
sys/kern/subr_disk.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diffs (29 lines):
diff -r 86cd64488cb5 -r fd47dfad4286 sys/kern/subr_disk.c
--- a/sys/kern/subr_disk.c Fri Mar 27 11:10:07 2020 +0000
+++ b/sys/kern/subr_disk.c Fri Mar 27 11:13:57 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_disk.c,v 1.129 2019/09/30 23:23:59 cnst Exp $ */
+/* $NetBSD: subr_disk.c,v 1.130 2020/03/27 11:13:57 mlelstv Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.129 2019/09/30 23:23:59 cnst Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.130 2020/03/27 11:13:57 mlelstv Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -440,6 +440,10 @@
disk_read_sectors(void (*strat)(struct buf *), const struct disklabel *lp,
struct buf *bp, unsigned int sector, int count)
{
+
+ if ((lp->d_secsize / DEV_BSIZE) == 0 || lp->d_secpercyl == 0)
+ return EINVAL;
+
bp->b_blkno = btodb((off_t)sector * lp->d_secsize);
bp->b_bcount = count * lp->d_secsize;
bp->b_flags = (bp->b_flags & ~B_WRITE) | B_READ;
Home |
Main Index |
Thread Index |
Old Index