You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2019/05/14 19:25:47 UTC

[trafficserver] branch master updated: gcc9: sprintf and strncat fixes in plugins

This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new fcebeae  gcc9: sprintf and strncat fixes in plugins
fcebeae is described below

commit fcebeae51454d45c608b1a105b8df8cca70cbbe9
Author: Bryan Call <bc...@apache.org>
AuthorDate: Tue May 14 10:25:22 2019 -0700

    gcc9: sprintf and strncat fixes in plugins
---
 example/thread_pool/psi.c  | 4 ++--
 plugins/s3_auth/s3_auth.cc | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/example/thread_pool/psi.c b/example/thread_pool/psi.c
index 4793c69..13e5d29 100644
--- a/example/thread_pool/psi.c
+++ b/example/thread_pool/psi.c
@@ -465,7 +465,7 @@ psi_include(TSCont contp, void *edata ATS_UNUSED)
   /* For security reason, we do not allow to include files that are
      not in the directory <plugin_path>/include.
      Also include file cannot contain any path. */
-  sprintf(inc_file, "%s/%s", psi_directory, _basename(data->psi_filename));
+  snprintf(inc_file, sizeof(inc_file), "%s/%s", psi_directory, _basename(data->psi_filename));
 
   /* Read the include file and copy content into iobuffer */
   if ((filep = TSfopen(inc_file, "r")) != NULL) {
@@ -963,7 +963,7 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
   }
 
   /* Initialize the psi directory = <plugin_path>/include */
-  sprintf(psi_directory, "%s/%s", TSPluginDirGet(), PSI_PATH);
+  snprintf(psi_directory, sizeof(psi_directory), "%s/%s", TSPluginDirGet(), PSI_PATH);
 
   /* create an TSTextLogObject to log any psi include */
   retval = TSTextLogObjectCreate("psi", TS_LOG_MODE_ADD_TIMESTAMP, &log);
diff --git a/plugins/s3_auth/s3_auth.cc b/plugins/s3_auth/s3_auth.cc
index 77e86fb..c8debe8 100644
--- a/plugins/s3_auth/s3_auth.cc
+++ b/plugins/s3_auth/s3_auth.cc
@@ -652,10 +652,10 @@ S3Request::set_header(const char *header, int header_len, const char *val, int v
 static size_t
 str_concat(char *dst, size_t dst_len, const char *src, size_t src_len)
 {
-  size_t to_copy = (src_len < dst_len) ? src_len : dst_len;
+  size_t to_copy = std::min(dst_len, src_len);
 
   if (to_copy > 0) {
-    (void)strncat(dst, src, to_copy);
+    strncat(dst, src, to_copy);
   }
 
   return to_copy;