NUL-terminate upload response buffer

This commit is contained in:
Asher Baker 2016-03-15 12:04:18 +00:00
parent 4f2715d3b9
commit 3085928ca1

View File

@ -309,7 +309,10 @@ bool UploadAndDeleteCrashDump(const char *path, char *response, int maxlen)
if (response) {
if (uploaded) {
g_pSM->Format(response, maxlen, "%s", data.GetBuffer());
int responseSize = data.GetSize();
if (responseSize >= maxlen) responseSize = maxlen - 1;
strncpy(response, data.GetBuffer(), responseSize);
response[responseSize] = '\0';
} else {
g_pSM->Format(response, maxlen, "%s (%d)", xfer->LastErrorMessage(), xfer->LastErrorCode());
}