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:
Phil Turnbull 2018-08-07 12:29:06 -04:00
parent 2eda6161d6
commit e541c9b64b
No known key found for this signature in database
GPG Key ID: D81B30C00789D262
1 changed files with 1 additions and 1 deletions

View File

@ -60,7 +60,7 @@ struct Scanner {
Tag &tag = tags[j];
tag.type = static_cast<TagType>(buffer[i++]);
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]);
i += name_length;
}