Geoip: Fix possible buffer overflow.

This commit is contained in:
Arkshine 2014-08-01 12:59:56 +02:00
parent 17e0ab99e6
commit 67bfe6bb36

View File

@ -102,7 +102,7 @@ const char *lookupString(const char *ip, const char **path, int *length)
}
// Let's avoid a crash in case we go over the buffer size.
size_t maxLength = ke::Min((size_t)result.data_size, sizeof(buffer));
size_t maxLength = ke::Min((size_t)result.data_size, sizeof(buffer)-1);
// Strings from database are not null terminated.
memcpy(buffer, result.utf8_string, maxLength);