factotum: fix mschap password (utf-8 to utf-16) conversion
using strlen() gives the number of bytes in the utf-8 string. could use utflen() instead, but decided to just go in a loop and get rid of the counters all together. UTF-16 surrogates are not handled.
This commit is contained in:
parent
0b3ad2b562
commit
c501fe6936
1 changed files with 4 additions and 7 deletions
|
@ -390,16 +390,13 @@ static void
|
||||||
doNTchap(char *pass, uchar chal[ChapChallen], uchar reply[MSchapResplen])
|
doNTchap(char *pass, uchar chal[ChapChallen], uchar reply[MSchapResplen])
|
||||||
{
|
{
|
||||||
Rune r;
|
Rune r;
|
||||||
int i, n;
|
|
||||||
uchar digest[MD4dlen];
|
uchar digest[MD4dlen];
|
||||||
uchar *w, unipass[256];
|
uchar *w, unipass[128*2]; // Standard says unlimited length, experience says 128 max
|
||||||
|
|
||||||
// Standard says unlimited length, experience says 128 max
|
w=unipass;
|
||||||
if ((n = strlen(pass)) > 128)
|
while(*pass != '\0' && w < &unipass[nelem(unipass)]){
|
||||||
n = 128;
|
|
||||||
|
|
||||||
for(i=0, w=unipass; i < n; i++) {
|
|
||||||
pass += chartorune(&r, pass);
|
pass += chartorune(&r, pass);
|
||||||
|
/* BUG: UTF-16 surrogates */
|
||||||
*w++ = r & 0xff;
|
*w++ = r & 0xff;
|
||||||
*w++ = r >> 8;
|
*w++ = r >> 8;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue