Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/alpha Match the two prom_getenv() and fix buffer ov...
details: https://anonhg.NetBSD.org/src/rev/0b9205c859d1
branches: trunk
changeset: 348285:0b9205c859d1
user: flxd <flxd%NetBSD.org@localhost>
date: Thu Oct 13 16:18:20 2016 +0000
description:
Match the two prom_getenv() and fix buffer overflow causing wrong host controller SCSI ID for DEC 3000.
OK skrll@
diffstat:
sys/arch/alpha/alpha/machdep.c | 6 +++---
sys/arch/alpha/alpha/prom.c | 16 ++++++++--------
sys/arch/alpha/stand/common/booted_dev.c | 5 ++---
sys/arch/alpha/stand/common/prom.c | 4 ++--
4 files changed, 15 insertions(+), 16 deletions(-)
diffs (112 lines):
diff -r 3d1b6ee47684 -r 0b9205c859d1 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c Thu Oct 13 13:29:39 2016 +0000
+++ b/sys/arch/alpha/alpha/machdep.c Thu Oct 13 16:18:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.346 2014/10/17 18:14:42 uebayasi Exp $ */
+/* $NetBSD: machdep.c,v 1.347 2016/10/13 16:18:20 flxd Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.346 2014/10/17 18:14:42 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.347 2016/10/13 16:18:20 flxd Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -173,7 +173,7 @@
/* For built-in TCDS */
#if defined(DEC_3000_300) || defined(DEC_3000_500)
-uint8_t dec_3000_scsiid[2], dec_3000_scsifast[2];
+uint8_t dec_3000_scsiid[3], dec_3000_scsifast[3];
#endif
struct platform platform;
diff -r 3d1b6ee47684 -r 0b9205c859d1 sys/arch/alpha/alpha/prom.c
--- a/sys/arch/alpha/alpha/prom.c Thu Oct 13 13:29:39 2016 +0000
+++ b/sys/arch/alpha/alpha/prom.c Thu Oct 13 16:18:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prom.c,v 1.48 2012/02/06 02:14:12 matt Exp $ */
+/* $NetBSD: prom.c,v 1.49 2016/10/13 16:18:20 flxd Exp $ */
/*
* Copyright (c) 1992, 1994, 1995, 1996 Carnegie Mellon University
@@ -27,7 +27,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.48 2012/02/06 02:14:12 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: prom.c,v 1.49 2016/10/13 16:18:20 flxd Exp $");
#include "opt_multiprocessor.h"
@@ -95,7 +95,7 @@
init_prom_interface(hwrpb);
- prom_getenv(PROM_E_TTY_DEV, buf, 4);
+ prom_getenv(PROM_E_TTY_DEV, buf, sizeof(buf));
alpha_console = buf[0] - '0';
/* XXX fake out the console routines, for now */
@@ -238,14 +238,14 @@
prom_enter();
ret.bits = prom_getenv_disp(id, to, len);
+ if (ret.u.status & 0x4)
+ ret.u.retval = 0;
+ len = min(len - 1, ret.u.retval);
memcpy(buf, to, len);
+ buf[len] = '\0';
prom_leave();
- if (ret.u.status & 0x4)
- ret.u.retval = 0;
- buf[ret.u.retval] = '\0';
-
- return (ret.bits);
+ return len;
}
void
diff -r 3d1b6ee47684 -r 0b9205c859d1 sys/arch/alpha/stand/common/booted_dev.c
--- a/sys/arch/alpha/stand/common/booted_dev.c Thu Oct 13 13:29:39 2016 +0000
+++ b/sys/arch/alpha/stand/common/booted_dev.c Thu Oct 13 16:18:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: booted_dev.c,v 1.3 1999/11/13 21:38:20 thorpej Exp $ */
+/* $NetBSD: booted_dev.c,v 1.4 2016/10/13 16:18:20 flxd Exp $ */
/*
* Copyright (c) 1999 Christopher G. Demetriou. All rights reserved.
@@ -53,9 +53,8 @@
* We don't know what device names look like yet,
* so we can't change them.
*/
- ret.bits = prom_getenv(PROM_E_BOOTED_DEV, booted_dev_name,
+ devlen = prom_getenv(PROM_E_BOOTED_DEV, booted_dev_name,
sizeof(booted_dev_name));
- devlen = ret.u.retval;
ret.bits = prom_open(booted_dev_name, devlen);
diff -r 3d1b6ee47684 -r 0b9205c859d1 sys/arch/alpha/stand/common/prom.c
--- a/sys/arch/alpha/stand/common/prom.c Thu Oct 13 13:29:39 2016 +0000
+++ b/sys/arch/alpha/stand/common/prom.c Thu Oct 13 16:18:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: prom.c,v 1.14 2009/03/18 10:22:22 cegger Exp $ */
+/* $NetBSD: prom.c,v 1.15 2016/10/13 16:18:20 flxd Exp $ */
/*
* Mach Operating System
@@ -57,7 +57,7 @@
prom_dispatch_v.routine = c->crb_v_dispatch->entry_va;
/* Look for console tty. */
- prom_getenv(PROM_E_TTY_DEV, buf, 4);
+ prom_getenv(PROM_E_TTY_DEV, buf, sizeof(buf));
console = buf[0] - '0';
}
Home |
Main Index |
Thread Index |
Old Index