diff options
author | Mikhail Chalov <mcchalov@amazon.com> | 2022-07-19 19:06:55 +0000 |
---|---|---|
committer | Daniel Black <daniel@mariadb.org> | 2022-07-26 16:28:59 +1000 |
commit | 19af1890b56c6c147c296479bb6a4ad00fa59dbb (patch) | |
tree | 0c2ba4eeaff5dd902a2072a7167bb208ddef4ad1 /storage/connect/tabtbl.cpp | |
parent | 95eb5e5a12c4b8125b38dfb54366fe4873e21394 (diff) | |
download | mariadb-git-19af1890b56c6c147c296479bb6a4ad00fa59dbb.tar.gz |
Use memory safe snprintf() in Connect Engine
This commit replaces sprintf(buf, ...) with
snprintf(buf, sizeof(buf), ...),
specifically in the "easy" cases where buf is allocated with a size
known at compile time.
The changes make sure we are not write outside array/string bounds which
will lead to undefined behaviour. In case the code is trying to write
outside bounds - safe version of functions simply cut the string
messages so we process this gracefully.
All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the BSD-new
license. I am contributing on behalf of my employer Amazon Web Services,
Inc.
bsonudf.cpp warnings cleanup by Daniel Black
Reviewer: Daniel Black
Diffstat (limited to 'storage/connect/tabtbl.cpp')
-rw-r--r-- | storage/connect/tabtbl.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index b6277088bac..b2240bffa2c 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -691,7 +691,7 @@ bool TDBTBM::OpenTables(PGLOBAL g) // pthread_attr_setdetachstate(&tp->attr, PTHREAD_CREATE_JOINABLE); if ((k = pthread_create(&tp->Tid, &tp->attr, ThreadOpen, tp))) { - sprintf(g->Message, "pthread_create error %d", k); + snprintf(g->Message, sizeof(g->Message), "pthread_create error %d", k); Nbc++; continue; } // endif k |