Bug 1192982 - increase buffer size, memset it to 0 and then do the right way strncpy. r=jaas

This commit is contained in:
Bogdan Postelnicu 2015-11-27 06:24:00 +01:00
Родитель cbe699d03c
Коммит a3215ffb22
1 изменённых файлов: 7 добавлений и 2 удалений

Просмотреть файл

@ -428,8 +428,13 @@ static void clearIdentifiers()
static void addRange(InstanceData* instanceData, const char* range)
{
char rangestr[16];
strncpy(rangestr, range, sizeof(rangestr));
/*
increased rangestr size from 16 to 17, the 17byte is only for
null terminated value, maybe for actual capacity it needs 16 bytes
*/
char rangestr[17];
memset(rangestr, 0, sizeof(rangestr));
strncpy(rangestr, range, sizeof(rangestr) - sizeof(char));
const char* str1 = strtok(rangestr, ",");
const char* str2 = str1 ? strtok(nullptr, ",") : nullptr;
if (str1 && str2) {