Fix SMB string handling.

This commit is contained in:
Vlad Grigorescu 2014-10-08 17:23:32 -04:00
parent 10db1b552d
commit 466a1e55e8

View file

@ -47,7 +47,6 @@ function uint8s_to_stringval(s: uint8[]): StringVal
// If the last 2 bytes are nulls, cut them with the length. // If the last 2 bytes are nulls, cut them with the length.
length = length-2; length = length-2;
} }
StringVal *output = new StringVal(length, buf); StringVal *output = new StringVal(length, buf);
delete [] buf; delete [] buf;
return output; return output;
@ -71,7 +70,7 @@ function extract_string(s: SMB_string) : StringVal
buf[i] = t; buf[i] = t;
} }
if ( length > 0 && buf[length] == 0x00 ) if ( length > 0 && buf[length-1] == 0x00 )
length--; length--;
StringVal *ret = new StringVal(length, buf); StringVal *ret = new StringVal(length, buf);