Merge pull request #24630 from taosdata/fix/xsren/printSlowLogStackOverflow3.0

fix: printSlowLog heap over flow
This commit is contained in:
dapan1121 2024-01-29 10:11:24 +08:00 committed by GitHub
commit d4a2553ace
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 0 deletions

View File

@ -573,6 +573,9 @@ void taosPrintSlowLog(const char *format, ...) {
len += vsnprintf(buffer + len, LOG_MAX_LINE_DUMP_BUFFER_SIZE - 2 - len, format, argpointer);
va_end(argpointer);
if (len < 0 || len > LOG_MAX_LINE_DUMP_BUFFER_SIZE - 2) {
len = LOG_MAX_LINE_DUMP_BUFFER_SIZE - 2;
}
buffer[len++] = '\n';
buffer[len] = 0;