Ensure buffer is null terminated in d2charsave_init_from_d2s()

This commit is contained in:
RElesgoe 2016-08-28 02:00:16 -07:00
parent 3f892f03c2
commit a521a8bb4f

View file

@ -82,6 +82,7 @@ namespace pvpgn
// charname
std::memset(buffer + D2CHARSAVE_CHARNAME_OFFSET_109, '\0', MAX_CHARNAME_LEN); // clear first
std::strncpy((char *)buffer + D2CHARSAVE_CHARNAME_OFFSET_109, charname, MAX_CHARNAME_LEN);
std::memset(buffer + D2CHARSAVE_CHARNAME_OFFSET_109 + MAX_CHARNAME_LEN - 1, '\0', 1);
// checksum
checksum = d2charsave_checksum((unsigned char *)buffer, size, D2CHARSAVE_CHECKSUM_OFFSET);