ref: 66ab4ac223a51a51ac431b60481183bc44c70215
parent: 96d6f4433550c4e48c33d94f6e272fae4b4e4ffb
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Feb 24 23:25:36 EST 2019
pc, pc64: fix %.*s format in multibootargs
--- a/sys/src/9/pc/bootargs.c
+++ b/sys/src/9/pc/bootargs.c
@@ -20,8 +20,9 @@
{
extern ulong multibootptr;
ulong *multiboot;
- char *cp, *ep;
+ char *cp, *ep, *s;
ulong *m, l;
+ int i, n;
if(multibootptr == 0)
return;
@@ -77,12 +78,17 @@
/* plan9.ini passed as the first module */
if((multiboot[0] & (1<<3)) != 0 && multiboot[5] > 0 && multiboot[6] != 0){
m = KADDR(multiboot[6]);
- cp = seprint(cp, ep, "%.*s\n", (int)(m[1] - m[0]), (char*)KADDR(m[0]));
+ s = (char*)KADDR(m[0]);
+ if(m[1] > m[0]){
+ n = utfnlen(s, m[1] - m[0]);
+ if(n > 0)
+ cp = seprint(cp, ep, "%.*s\n", n, s);
+ }
}
/* command line */
if((multiboot[0] & (1<<2)) != 0 && multiboot[4] != 0){
- int i, n = tokenize(KADDR(multiboot[4]), confval, MAXCONF);
+ n = tokenize(KADDR(multiboot[4]), confval, MAXCONF);
for(i=0; i<n; i++)
cp = seprint(cp, ep, "%s\n", confval[i]);
}