Commit 0d7697f9 authored by Petri Hintukainen's avatar Petri Hintukainen

dstring length can't be < 0

parent 3dd2f2ec
......@@ -37,11 +37,18 @@
*/
/* fixed-length dstring, ECMA 1/7.2.12 */
static int _decode_dstring(const uint8_t *p, int field_length, uint8_t *str)
static size_t _decode_dstring(const uint8_t *p, size_t field_length, uint8_t *str)
{
int length = _get_u8(p + field_length - 1);
if (length > field_length - 1) {
length = field_length - 1;
size_t length;
if (field_length < 1) {
return 0;
}
field_length--;
length = _get_u8(p + field_length);
if (length > field_length) {
length = field_length;
}
memcpy(str, p, length);
return length;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment