1
0
Fork 0

(svn r25527) -Fix[FS#5621]: strndup should not examine strings beyond its upper limit.

release/1.4
alberth 2013-06-30 08:29:51 +00:00
parent 92f276f26d
commit 631540c400
1 changed files with 1 additions and 2 deletions

View File

@ -560,10 +560,9 @@ size_t Utf8TrimString(char *s, size_t maxlen)
}
#ifdef DEFINE_STRNDUP
#include "core/math_func.hpp"
char *strndup(const char *s, size_t len)
{
len = min(strlen(s), len);
len = ttd_strnlen(s, len);
char *tmp = CallocT<char>(len + 1);
memcpy(tmp, s, len);
return tmp;