From d89f3d25c3e680b9ab80cf4e6c9c26e2ac49d957 Mon Sep 17 00:00:00 2001 From: Aleric Inglewood Date: Mon, 21 Aug 2023 19:39:43 +0200 Subject: [PATCH] Bug / compile error - fix. path is treated as a null-terminated string, which is only guaranteed when the buffer that strncpy copies to is at least one larger than the maximum number of characters copied (the third argument). Without this patch, g++ 13.2.1 gives a warning turned into an error. --- indra/llcommon/llapp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indra/llcommon/llapp.cpp b/indra/llcommon/llapp.cpp index 284bfb2afa..b910b9903b 100644 --- a/indra/llcommon/llapp.cpp +++ b/indra/llcommon/llapp.cpp @@ -828,11 +828,11 @@ bool unix_post_minidump_callback(const char *dump_dir, auto dirPathLength = strlen(dump_dir); auto idLength = strlen(minidump_id); - // The path must not be truncated. - llassert((dirPathLength + idLength + 5) <= LLApp::MAX_MINDUMP_PATH_LENGTH); + // The path must not be truncated, and we need to have room left for a terminating zero. + llassert((dirPathLength + idLength + 5) < LLApp::MAX_MINDUMP_PATH_LENGTH); char * path = LLApp::instance()->getMiniDumpFilename(); - auto remaining = LLApp::MAX_MINDUMP_PATH_LENGTH; + auto remaining = LLApp::MAX_MINDUMP_PATH_LENGTH - 1; strncpy(path, dump_dir, remaining); remaining -= dirPathLength; path += dirPathLength;