Module Name: src
Committed By: christos
Date: Fri Jun 28 14:48:17 UTC 2013
Modified Files:
src/sys/dev/ic: opl.c
Log Message:
avoid undefined behavior
http://m00nbsd.net/ae123a9bae03f7dde5c6d654412daf5a.html
To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/dev/ic/opl.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/dev/ic/opl.c
diff -u src/sys/dev/ic/opl.c:1.39 src/sys/dev/ic/opl.c:1.40
--- src/sys/dev/ic/opl.c:1.39 Mon Apr 9 06:18:16 2012
+++ src/sys/dev/ic/opl.c Fri Jun 28 10:48:17 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: opl.c,v 1.39 2012/04/09 10:18:16 plunky Exp $ */
+/* $NetBSD: opl.c,v 1.40 2013/06/28 14:48:17 christos Exp $ */
/*
* Copyright (c) 1998, 2008 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: opl.c,v 1.39 2012/04/09 10:18:16 plunky Exp $");
+__KERNEL_RCSID(0, "$NetBSD: opl.c,v 1.40 2013/06/28 14:48:17 christos Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -158,8 +158,9 @@ opl_attach(struct opl_softc *sc)
mutex_exit(sc->lock);
sc->syn.mets = &opl3_midi;
- snprintf(sc->syn.name, sizeof(sc->syn.name), "%sYamaha OPL%d",
- sc->syn.name, sc->model);
+ size_t len = strlen(sc->syn.name);
+ snprintf(sc->syn.name + len, sizeof(sc->syn.name) - len, "Yamaha OPL%d",
+ sc->model);
sc->syn.data = sc;
sc->syn.nvoice = sc->model == OPL_2 ? OPL2_NVOICE : OPL3_NVOICE;
sc->syn.lock = sc->lock;