Avoid integer cast issues when deserializing tags
`buffer` contains signed chars, so if a tag length is greater than 128 then it is treated as a negative value when deserializing. The negative signed char is then implicitly cast to a large unsigned integer. Explicitly cast the values to signed chars Co-authored-by: Rahul Zhade <zhade3@github.com>
This commit is contained in:
parent
2eda6161d6
commit
e541c9b64b
|
@ -60,7 +60,7 @@ struct Scanner {
|
||||||
Tag &tag = tags[j];
|
Tag &tag = tags[j];
|
||||||
tag.type = static_cast<TagType>(buffer[i++]);
|
tag.type = static_cast<TagType>(buffer[i++]);
|
||||||
if (tag.type == CUSTOM) {
|
if (tag.type == CUSTOM) {
|
||||||
unsigned name_length = buffer[i++];
|
unsigned name_length = (unsigned char)buffer[i++];
|
||||||
tag.custom_tag_name.assign(&buffer[i], &buffer[i + name_length]);
|
tag.custom_tag_name.assign(&buffer[i], &buffer[i + name_length]);
|
||||||
i += name_length;
|
i += name_length;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue