# HG changeset patch # User alberth # Date 1372580991 0 # Node ID 4710e1baf8f7e5d324d56b0a86295858f9dddc73 # Parent 9f2dff69f042ae04753304009c836636a590afaf (svn r25527) -Fix[FS#5621]: strndup should not examine strings beyond its upper limit. diff --git a/src/string.cpp b/src/string.cpp --- a/src/string.cpp +++ b/src/string.cpp @@ -560,10 +560,9 @@ } #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(len + 1); memcpy(tmp, s, len); return tmp;