Skip to content

Commit c958d1d

Browse files
committed
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.
1 parent d0ca14e commit c958d1d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

connectivity/drivers/cellular/GEMALTO/CINTERION/GEMALTO_CINTERION_CellularStack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ nsapi_error_t GEMALTO_CINTERION_CellularStack::socket_open_defer(CellularSocket
186186
}
187187
}
188188
if (strcmp(paramTag, "conId") == 0) {
189-
char buf[10];
190-
std::sprintf(buf, "%d", _cid);
189+
char buf[12];
190+
std::snprintf(buf, sizeof(buf), "%d", _cid);
191191
if (strcmp(paramValue, buf) == 0) {
192192
foundConIdType = true;
193193
}

0 commit comments

Comments
 (0)