aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2022-10-21 10:48:46 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-11-14 19:38:23 +0000
commit46ad931370e37b1e3abe5db9d52d57a3ec83151d (patch)
treee7025076bf871883cd172ec9dfeec9eaca8660c8
parent243cfcdf6f1f270a539916904aae3ff515e27fb2 (diff)
replace sprintf by snprintf
The function sprintf is deprecated and easily replaced by the secure snprintf version. Change-Id: I6b97d71ae179f9a6627fd5e39451e7a2f2322497 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 15436a08f9cde34f2594b192314ad842906f9ed1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/libshiboken/signature/signature.cpp6
-rw-r--r--sources/shiboken6/tests/libsample/sometime.cpp2
2 files changed, 4 insertions, 4 deletions
diff --git a/sources/shiboken6/libshiboken/signature/signature.cpp b/sources/shiboken6/libshiboken/signature/signature.cpp
index 6bd03be2e..6c28c758b 100644
--- a/sources/shiboken6/libshiboken/signature/signature.cpp
+++ b/sources/shiboken6/libshiboken/signature/signature.cpp
@@ -546,13 +546,13 @@ static PyObject *adjustFuncName(const char *func_name)
if (prop_name) {
auto _prop_name = String::toCString(prop_name);
if (is_class_prop)
- sprintf(_buf, "%s.__dict__['%s'].fset", _path, _prop_name);
+ snprintf(_buf, sizeof(_buf), "%s.__dict__['%s'].fset", _path, _prop_name);
else
- sprintf(_buf, "%s.%s.fset", _path, _prop_name);
+ snprintf(_buf, sizeof(_buf), "%s.%s.fset", _path, _prop_name);
}
else {
auto _name = String::toCString(name);
- sprintf(_buf, "%s.%s", _path, _name);
+ snprintf(_buf, sizeof(_buf), "%s.%s", _path, _name);
}
return String::fromCString(_buf);
}
diff --git a/sources/shiboken6/tests/libsample/sometime.cpp b/sources/shiboken6/tests/libsample/sometime.cpp
index 22c894c9a..8a3802deb 100644
--- a/sources/shiboken6/tests/libsample/sometime.cpp
+++ b/sources/shiboken6/tests/libsample/sometime.cpp
@@ -46,7 +46,7 @@ Time::toString() const
if (m_is_null)
return Str();
char buffer[13];
- sprintf(buffer, "%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_msec);
+ snprintf(buffer, sizeof(buffer), "%02d:%02d:%02d.%03d", m_hour, m_minute, m_second, m_msec);
return Str(buffer);
}