Fix potentially overrunning write of sprintf

Format string "%d" requires 12 bytes (including the null terminator).
Also, use snprintf instead of sprintf to prevent buffer overflow.
pull/15404/head
Mingjie Shen 2023-04-19 16:50:00 -04:00
parent d0ca14e4fe
commit c958d1d5b9
1 changed files with 2 additions and 2 deletions

View File

@ -186,8 +186,8 @@ retry_open:
}
}
if (strcmp(paramTag, "conId") == 0) {
char buf[10];
std::sprintf(buf, "%d", _cid);
char buf[12];
std::snprintf(buf, sizeof(buf), "%d", _cid);
if (strcmp(paramValue, buf) == 0) {
foundConIdType = true;
}