Crash when opening JPEG file with corrupted metadata, fixes #3602

This commit is contained in:
heckflosse
2017-01-09 15:34:18 +01:00
parent 1c3b3687f8
commit 1998e2c6d2

View File

@@ -445,11 +445,16 @@ public:
UserCommentInterpreter () {}
virtual std::string toString (Tag* t)
{
char *buffer = new char[t->getCount()];
int count = t->getCount();
if(count <= 8) {
return "";
}
if (!strncmp((char*)t->getValue(), "ASCII\0\0\0", 8)) {
strncpy (buffer, (char*)t->getValue() + 8, t->getCount() - 8);
buffer[t->getCount() - 8] = '\0';
char *buffer = new char[count - 7];
if (!strncmp((char*)t->getValue(), "ASCII\0\0\0", 8)) { // TODO: this compares only up to the first \0, remaining \0\0 are ignored
strncpy (buffer, (char*)t->getValue() + 8, count - 8);
buffer[count - 8] = '\0';
} else {
buffer[0] = 0;
}