Page MenuHomeFreeBSD

D31727.id94381.diff
No OneTemporary

D31727.id94381.diff

diff --git a/sys/geom/gate/g_gate.c b/sys/geom/gate/g_gate.c
--- a/sys/geom/gate/g_gate.c
+++ b/sys/geom/gate/g_gate.c
@@ -467,7 +467,8 @@
struct g_geom *gp;
struct g_provider *pp, *ropp;
struct g_consumer *cp;
- char name[NAME_MAX];
+ char name[NAME_MAX + 1];
+ char readprov[NAME_MAX + 1];
int error = 0, unit;
if (ggio->gctl_mediasize <= 0) {
@@ -522,9 +523,10 @@
sc->sc_unit = g_gate_getunit(ggio->gctl_unit, &error);
if (sc->sc_unit < 0)
goto fail1;
- if (ggio->gctl_unit == G_GATE_NAME_GIVEN)
- snprintf(name, sizeof(name), "%s", ggio->gctl_name);
- else {
+ if (ggio->gctl_unit == G_GATE_NAME_GIVEN) {
+ memset(name, 0, sizeof(name));
+ strncpy(name, ggio->gctl_name, MIN(sizeof(name) - 1, sizeof(ggio->gctl_name)));
+ } else {
snprintf(name, sizeof(name), "%s%d", G_GATE_PROVIDER_NAME,
sc->sc_unit);
}
@@ -547,10 +549,11 @@
if (ggio->gctl_readprov[0] == '\0') {
ropp = NULL;
} else {
- ropp = g_provider_by_name(ggio->gctl_readprov);
+ memset(readprov, 0, sizeof(readprov));
+ strncpy(readprov, ggio->gctl_readprov, MIN(sizeof(readprov) - 1, sizeof(ggio->gctl_readprov)));
+ ropp = g_provider_by_name(readprov);
if (ropp == NULL) {
- G_GATE_DEBUG(1, "Provider %s doesn't exist.",
- ggio->gctl_readprov);
+ G_GATE_DEBUG(1, "Provider %s doesn't exist.", readprov);
error = EINVAL;
goto fail2;
}
@@ -632,6 +635,7 @@
static int
g_gate_modify(struct g_gate_softc *sc, struct g_gate_ctl_modify *ggio)
{
+ char readprov[NAME_MAX + 1];
struct g_provider *pp;
struct g_consumer *cp;
int done, error;
@@ -667,11 +671,12 @@
} else
mtx_unlock(&sc->sc_read_mtx);
if (ggio->gctl_readprov[0] != '\0') {
- pp = g_provider_by_name(ggio->gctl_readprov);
+ memset(readprov, 0, sizeof(readprov));
+ strncpy(readprov, ggio->gctl_readprov, MIN(sizeof(readprov) - 1, sizeof(ggio->gctl_readprov)));
+ pp = g_provider_by_name(readprov);
if (pp == NULL) {
g_topology_unlock();
- G_GATE_DEBUG(1, "Provider %s doesn't exist.",
- ggio->gctl_readprov);
+ G_GATE_DEBUG(1, "Provider %s doesn't exist.", readprov);
return (EINVAL);
}
cp = g_new_consumer(sc->sc_provider->geom);

File Metadata

Mime Type
text/plain
Expires
Sat, Feb 14, 4:06 AM (19 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28686205
Default Alt Text
D31727.id94381.diff (2 KB)

Event Timeline