nusb: fix loaddevstr() (thanks erik quanstro and richard miller)
loaddevstr() should request 256 bytes, as per standard and respect the length embedded in the string.
This commit is contained in:
parent
7cdd1c46c5
commit
f88d0c372d
|
@ -186,25 +186,26 @@ mkstr(uchar *b, int n)
|
||||||
Rune r;
|
Rune r;
|
||||||
char *us;
|
char *us;
|
||||||
char *s;
|
char *s;
|
||||||
char *e;
|
|
||||||
|
|
||||||
|
if(n > 0 && n > b[0])
|
||||||
|
n = b[0];
|
||||||
if(n <= 2 || (n & 1) != 0)
|
if(n <= 2 || (n & 1) != 0)
|
||||||
return strdup("none");
|
return strdup("none");
|
||||||
n = (n - 2)/2;
|
n = (n - 2)/2;
|
||||||
b += 2;
|
b += 2;
|
||||||
us = s = emallocz(n*UTFmax+1, 0);
|
us = s = emallocz(n*UTFmax+1, 0);
|
||||||
e = s + n*UTFmax+1;
|
|
||||||
for(; --n >= 0; b += 2){
|
for(; --n >= 0; b += 2){
|
||||||
r = GET2(b);
|
r = GET2(b);
|
||||||
s = seprint(s, e, "%C", r);
|
s += runetochar(s, &r);
|
||||||
}
|
}
|
||||||
|
*s = 0;
|
||||||
return us;
|
return us;
|
||||||
}
|
}
|
||||||
|
|
||||||
char*
|
char*
|
||||||
loaddevstr(Dev *d, int sid)
|
loaddevstr(Dev *d, int sid)
|
||||||
{
|
{
|
||||||
uchar buf[128];
|
uchar buf[256];
|
||||||
int langid;
|
int langid;
|
||||||
int type;
|
int type;
|
||||||
int nr;
|
int nr;
|
||||||
|
|
Loading…
Reference in a new issue