diff --git a/src/jrd/gds.cpp b/src/jrd/gds.cpp index 69e318a121..51ea40fdd4 100644 --- a/src/jrd/gds.cpp +++ b/src/jrd/gds.cpp @@ -3588,14 +3588,22 @@ static void safe_concat_path(TEXT *resultString, const TEXT *appendString) * **************************************/ size_t len = strlen(resultString); - if (resultString[len - 1] != PathUtils::dir_sep && len < MAXPATHLEN - 1) { + if (resultString[len - 1] != PathUtils::dir_sep && len < MAXPATHLEN - 1) + { resultString[len++] = PathUtils::dir_sep; resultString[len] = 0; } + size_t alen = strlen(appendString); if (len + alen > MAXPATHLEN - 1) + { alen = MAXPATHLEN - 1 - len; - fb_assert(len + alen <= MAXPATHLEN); + } + + fb_assert(len < MAXPATHLEN); + fb_assert(alen < MAXPATHLEN); + fb_assert(len + alen < MAXPATHLEN); + memcpy(&resultString[len], appendString, alen); resultString[len + alen] = 0; }