Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/dkwedge use a bounded copy. NFCI
details: https://anonhg.NetBSD.org/src/rev/4cda177e1848
branches: trunk
changeset: 350745:4cda177e1848
user: maya <maya%NetBSD.org@localhost>
date: Thu Jan 19 00:44:40 2017 +0000
description:
use a bounded copy. NFCI
diffstat:
sys/dev/dkwedge/dk.c | 16 +++++++++-------
sys/dev/dkwedge/dkwedge_apple.c | 8 ++++----
sys/dev/dkwedge/dkwedge_gpt.c | 14 +++++++-------
sys/dev/dkwedge/dkwedge_mbr.c | 8 ++++----
4 files changed, 24 insertions(+), 22 deletions(-)
diffs (163 lines):
diff -r cfc3ce377fa5 -r 4cda177e1848 sys/dev/dkwedge/dk.c
--- a/sys/dev/dkwedge/dk.c Wed Jan 18 22:38:00 2017 +0000
+++ b/sys/dev/dkwedge/dk.c Thu Jan 19 00:44:40 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dk.c,v 1.93 2016/12/24 16:39:55 mlelstv Exp $ */
+/* $NetBSD: dk.c,v 1.94 2017/01/19 00:44:40 maya Exp $ */
/*-
* Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.93 2016/12/24 16:39:55 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.94 2017/01/19 00:44:40 maya Exp $");
#ifdef _KERNEL_OPT
#include "opt_dkwedge.h"
@@ -686,7 +686,7 @@
mutex_exit(&pdk->dk_openlock);
return;
}
- strcpy(dkw.dkw_parent, pdk->dk_name);
+ strlcpy(dkw.dkw_parent, pdk->dk_name, sizeof(dkw.dkw_parent));
strlcpy(dkw.dkw_devname, device_xname(sc->sc_dev),
sizeof(dkw.dkw_devname));
mutex_exit(&pdk->dk_openlock);
@@ -733,10 +733,11 @@
sizeof(dkw.dkw_devname));
memcpy(dkw.dkw_wname, sc->sc_wname, sizeof(dkw.dkw_wname));
dkw.dkw_wname[sizeof(dkw.dkw_wname) - 1] = '\0';
- strcpy(dkw.dkw_parent, sc->sc_parent->dk_name);
+ strlcpy(dkw.dkw_parent, sc->sc_parent->dk_name,
+ sizeof(dkw.dkw_parent));
dkw.dkw_offset = sc->sc_offset;
dkw.dkw_size = sc->sc_size;
- strcpy(dkw.dkw_ptype, sc->sc_ptype);
+ strlcpy(dkw.dkw_ptype, sc->sc_ptype, sizeof(dkw.dkw_ptype));
error = uiomove(&dkw, sizeof(dkw), &uio);
if (error)
@@ -1497,10 +1498,11 @@
sizeof(dkw->dkw_devname));
memcpy(dkw->dkw_wname, sc->sc_wname, sizeof(dkw->dkw_wname));
dkw->dkw_wname[sizeof(dkw->dkw_wname) - 1] = '\0';
- strcpy(dkw->dkw_parent, sc->sc_parent->dk_name);
+ strlcpy(dkw->dkw_parent, sc->sc_parent->dk_name,
+ sizeof(dkw->dkw_parent));
dkw->dkw_offset = sc->sc_offset;
dkw->dkw_size = sc->sc_size;
- strcpy(dkw->dkw_ptype, sc->sc_ptype);
+ strlcpy(dkw->dkw_ptype, sc->sc_ptype, sizeof(dkw->dkw_ptype));
break;
}
diff -r cfc3ce377fa5 -r 4cda177e1848 sys/dev/dkwedge/dkwedge_apple.c
--- a/sys/dev/dkwedge/dkwedge_apple.c Wed Jan 18 22:38:00 2017 +0000
+++ b/sys/dev/dkwedge/dkwedge_apple.c Thu Jan 19 00:44:40 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkwedge_apple.c,v 1.2 2015/01/24 02:58:56 christos Exp $ */
+/* $NetBSD: dkwedge_apple.c,v 1.3 2017/01/19 00:44:40 maya Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_apple.c,v 1.2 2015/01/24 02:58:56 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_apple.c,v 1.3 2017/01/19 00:44:40 maya Exp $");
#include <sys/param.h>
#ifdef _KERNEL
@@ -217,8 +217,8 @@
struct dkwedge_info dkw;
- strcpy(dkw.dkw_ptype, ptype);
- strcpy(dkw.dkw_parent, pdk->dk_name);
+ strlcpy(dkw.dkw_ptype, ptype, sizeof(dkw.dkw_ptype));
+ strlcpy(dkw.dkw_parent, pdk->dk_name, sizeof(dkw.dkw_parent));
dkw.dkw_offset = ae->pmPyPartStart;
dkw.dkw_size = ae->pmPartBlkCnt;
strlcpy(dkw.dkw_wname, ae->pmPartName, sizeof(dkw.dkw_wname));
diff -r cfc3ce377fa5 -r 4cda177e1848 sys/dev/dkwedge/dkwedge_gpt.c
--- a/sys/dev/dkwedge/dkwedge_gpt.c Wed Jan 18 22:38:00 2017 +0000
+++ b/sys/dev/dkwedge/dkwedge_gpt.c Thu Jan 19 00:44:40 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkwedge_gpt.c,v 1.17 2016/04/28 00:35:24 christos Exp $ */
+/* $NetBSD: dkwedge_gpt.c,v 1.18 2017/01/19 00:44:40 maya Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.17 2016/04/28 00:35:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_gpt.c,v 1.18 2017/01/19 00:44:40 maya Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -239,16 +239,16 @@
/* figure out the type */
ptype = gpt_ptype_guid_to_str(&ptype_guid);
- strcpy(dkw.dkw_ptype, ptype);
+ strlcpy(dkw.dkw_ptype, ptype, sizeof(dkw.dkw_ptype));
- strcpy(dkw.dkw_parent, pdk->dk_name);
+ strlcpy(dkw.dkw_parent, pdk->dk_name, sizeof(dkw.dkw_parent));
dkw.dkw_offset = le64toh(ent->ent_lba_start);
dkw.dkw_size = le64toh(ent->ent_lba_end) - dkw.dkw_offset + 1;
/* XXX Make sure it falls within the disk's data area. */
if (ent->ent_name[0] == 0x0000)
- strcpy(dkw.dkw_wname, ent_guid_str);
+ strlcpy(dkw.dkw_wname, ent_guid_str, sizeof(dkw.dkw_wname));
else {
c = dkw.dkw_wname;
r = sizeof(dkw.dkw_wname) - 1;
@@ -268,8 +268,8 @@
if ((error = dkwedge_add(&dkw)) == EEXIST &&
strcmp(dkw.dkw_wname, ent_guid_str) != 0) {
char orig[sizeof(dkw.dkw_wname)];
- strcpy(orig, dkw.dkw_wname);
- strcpy(dkw.dkw_wname, ent_guid_str);
+ strlcpy(orig, dkw.dkw_wname, sizeof(orig));
+ strlcpy(dkw.dkw_wname, ent_guid_str, sizeof(dkw.dkw_wname));
error = dkwedge_add(&dkw);
if (!error)
aprint_error("%s: wedge named '%s' already "
diff -r cfc3ce377fa5 -r 4cda177e1848 sys/dev/dkwedge/dkwedge_mbr.c
--- a/sys/dev/dkwedge/dkwedge_mbr.c Wed Jan 18 22:38:00 2017 +0000
+++ b/sys/dev/dkwedge/dkwedge_mbr.c Thu Jan 19 00:44:40 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dkwedge_mbr.c,v 1.9 2015/12/02 01:09:49 christos Exp $ */
+/* $NetBSD: dkwedge_mbr.c,v 1.10 2017/01/19 00:44:40 maya Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dkwedge_mbr.c,v 1.9 2015/12/02 01:09:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dkwedge_mbr.c,v 1.10 2017/01/19 00:44:40 maya Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -124,9 +124,9 @@
dp[i].mbrp_type);
continue;
}
- strcpy(dkw.dkw_ptype, ptype);
+ strlcpy(dkw.dkw_ptype, ptype, sizeof(dkw.dkw_ptype));
- strcpy(dkw.dkw_parent, a->pdk->dk_name);
+ strlcpy(dkw.dkw_parent, a->pdk->dk_name, sizeof(dkw.dkw_parent));
dkw.dkw_offset = le32toh(dp[i].mbrp_start);
dkw.dkw_size = le32toh(dp[i].mbrp_size);
Home |
Main Index |
Thread Index |
Old Index