ref: e3736b888701c79c9abb3de3fd28fe6ed5d3b168
parent: 89653dcc749a119ef2ee51b5e9812b7820951ec3
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Nov 19 12:17:04 EST 2017
kernel: make isaconfig() consistent, not inplace tokenizing the conf string
--- a/sys/src/9/mtx/main.c
+++ b/sys/src/9/mtx/main.c
@@ -360,14 +360,19 @@
int
isaconfig(char *class, int ctlrno, ISAConf *isa)
{
+ char cc[32], *p, *x;
int i;
- char cc[KNAMELEN], *p;
- sprint(cc, "%s%d", class, ctlrno);
-
+ snprint(cc, sizeof cc, "%s%d", class, ctlrno);
p = getconf(cc);
- if(p == 0)
+ if(p == nil)
return 0;
+
+ x = nil;
+ kstrdup(&x, p);
+ p = x;
+
+ isa->type = "";
isa->nopt = tokenize(p, isa->opt, NISAOPT);
for(i = 0; i < isa->nopt; i++){
p = isa->opt[i];
--- a/sys/src/9/omap/main.c
+++ b/sys/src/9/omap/main.c
@@ -314,7 +314,7 @@
int
isaconfig(char *class, int ctlrno, ISAConf *isa)
{
- char cc[32], *p;
+ char cc[32], *p, *x;
int i;
snprint(cc, sizeof cc, "%s%d", class, ctlrno);
@@ -321,6 +321,10 @@
p = getconf(cc);
if(p == nil)
return 0;
+
+ x = nil;
+ kstrdup(&x, p);
+ p = x;
isa->type = "";
isa->nopt = tokenize(p, isa->opt, NISAOPT);
--- a/sys/src/9/teg2/main.c
+++ b/sys/src/9/teg2/main.c
@@ -494,7 +494,7 @@
int
isaconfig(char *class, int ctlrno, ISAConf *isa)
{
- char cc[32], *p;
+ char cc[32], *p, *x;
int i;
snprint(cc, sizeof cc, "%s%d", class, ctlrno);
@@ -501,6 +501,10 @@
p = getconf(cc);
if(p == nil)
return 0;
+
+ x = nil;
+ kstrdup(&x, p);
+ p = x;
isa->type = "";
isa->nopt = tokenize(p, isa->opt, NISAOPT);