Module Name:    src
Committed By:   snj
Date:           Wed Nov 16 18:04:39 UTC 2016

Modified Files:
        src/sys/arch/alpha/alpha [netbsd-6]: machdep.c prom.c
        src/sys/arch/alpha/stand/common [netbsd-6]: booted_dev.c prom.c

Log Message:
Pull up following revision(s) (requested by flxd in ticket #1416):
        sys/arch/alpha/alpha/machdep.c: revision 1.347
        sys/arch/alpha/alpha/prom.c: revision 1.49
        sys/arch/alpha/stand/common/booted_dev.c: revision 1.4
        sys/arch/alpha/stand/common/prom.c: revision 1.15
Match the two prom_getenv() and fix buffer overflow causing wrong host
controller SCSI ID for DEC 3000.
OK skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.337.2.1 -r1.337.2.2 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.48 -r1.48.2.1 src/sys/arch/alpha/alpha/prom.c
cvs rdiff -u -r1.3 -r1.3.174.1 src/sys/arch/alpha/stand/common/booted_dev.c
cvs rdiff -u -r1.14 -r1.14.18.1 src/sys/arch/alpha/stand/common/prom.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/alpha/alpha/machdep.c
diff -u src/sys/arch/alpha/alpha/machdep.c:1.337.2.1 src/sys/arch/alpha/alpha/machdep.c:1.337.2.2
--- src/sys/arch/alpha/alpha/machdep.c:1.337.2.1	Mon May 21 15:25:57 2012
+++ src/sys/arch/alpha/alpha/machdep.c	Wed Nov 16 18:04:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.337.2.1 2012/05/21 15:25:57 riz Exp $ */
+/* $NetBSD: machdep.c,v 1.337.2.2 2016/11/16 18:04:39 snj 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.337.2.1 2012/05/21 15:25:57 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.337.2.2 2016/11/16 18:04:39 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -175,7 +175,7 @@ struct bootinfo_kernel bootinfo;
 
 /* 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;

Index: src/sys/arch/alpha/alpha/prom.c
diff -u src/sys/arch/alpha/alpha/prom.c:1.48 src/sys/arch/alpha/alpha/prom.c:1.48.2.1
--- src/sys/arch/alpha/alpha/prom.c:1.48	Mon Feb  6 02:14:12 2012
+++ src/sys/arch/alpha/alpha/prom.c	Wed Nov 16 18:04:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: prom.c,v 1.48 2012/02/06 02:14:12 matt Exp $ */
+/* $NetBSD: prom.c,v 1.48.2.1 2016/11/16 18:04:39 snj 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.48.2.1 2016/11/16 18:04:39 snj Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -95,7 +95,7 @@ init_bootstrap_console(void)
 
 	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_getenv(int id, char *buf, int len)
 
 	prom_enter();
 	ret.bits = prom_getenv_disp(id, to, len);
-	memcpy(buf, to, len);
-	prom_leave();
-
 	if (ret.u.status & 0x4)
 		ret.u.retval = 0;
-	buf[ret.u.retval] = '\0';
+	len = min(len - 1, ret.u.retval);
+	memcpy(buf, to, len);
+	buf[len] = '\0';
+	prom_leave();
 
-	return (ret.bits);
+	return len;
 }
 
 void

Index: src/sys/arch/alpha/stand/common/booted_dev.c
diff -u src/sys/arch/alpha/stand/common/booted_dev.c:1.3 src/sys/arch/alpha/stand/common/booted_dev.c:1.3.174.1
--- src/sys/arch/alpha/stand/common/booted_dev.c:1.3	Sat Nov 13 21:38:20 1999
+++ src/sys/arch/alpha/stand/common/booted_dev.c	Wed Nov 16 18:04:39 2016
@@ -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.3.174.1 2016/11/16 18:04:39 snj Exp $ */
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -53,9 +53,8 @@ booted_dev_open(void)
 	 * 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);
 

Index: src/sys/arch/alpha/stand/common/prom.c
diff -u src/sys/arch/alpha/stand/common/prom.c:1.14 src/sys/arch/alpha/stand/common/prom.c:1.14.18.1
--- src/sys/arch/alpha/stand/common/prom.c:1.14	Wed Mar 18 10:22:22 2009
+++ src/sys/arch/alpha/stand/common/prom.c	Wed Nov 16 18:04:39 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: prom.c,v 1.14 2009/03/18 10:22:22 cegger Exp $ */
+/* $NetBSD: prom.c,v 1.14.18.1 2016/11/16 18:04:39 snj Exp $ */
 
 /*  
  * Mach Operating System
@@ -57,7 +57,7 @@ init_prom_calls(void)
 	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';
 }
 

Reply via email to