trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject svn commit: r1171360 - in /trafficserver/traffic/trunk/proxy: InkAPI.cc api/ts/ts.h.in
Date Fri, 16 Sep 2011 02:11:56 GMT
Author: igalic
Date: Fri Sep 16 02:11:56 2011
New Revision: 1171360

URL: http://svn.apache.org/viewvc?rev=1171360&view=rev
Log:
TS-953: Add _TSstrlcat/cpy for easy access from C++ core/plugins

Modified:
    trafficserver/traffic/trunk/proxy/InkAPI.cc
    trafficserver/traffic/trunk/proxy/api/ts/ts.h.in

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1171360&r1=1171359&r2=1171360&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Fri Sep 16 02:11:56 2011
@@ -1623,7 +1623,7 @@ api_init()
     memset(state_arg_table, 0, sizeof(state_arg_table));
 
     // Setup the version string for returning to plugins
-    ink_strncpy(traffic_server_version, appVersionInfo.VersionStr, sizeof(traffic_server_version));
+    ink_strlcpy(traffic_server_version, appVersionInfo.VersionStr, sizeof(traffic_server_version));
     // Extract the elements.
     // coverity[secure_coding]
     if (sscanf(traffic_server_version, "%d.%d.%d", &ts_major_version, &ts_minor_version,
&ts_patch_version) != 3) {
@@ -1660,6 +1660,18 @@ _TSstrdup(const char *str, int64_t lengt
   return _xstrdup(str, length, path);
 }
 
+size_t
+_TSstrlcpy(char *dst, const char *str, size_t siz)
+{
+  return ink_strlcpy(dst, str, siz);
+}
+
+size_t
+_TSstrlcat(char *dst, const char *str, size_t siz)
+{
+  return ink_strlcat(dst, str, siz);
+}
+
 void
 _TSfree(void *ptr)
 {
@@ -5498,8 +5510,7 @@ TSHttpTxnSetHttpRetBody(TSHttpTxn txnp, 
   s->return_xbuf[0] = 0;
   s->return_xbuf_plain = false;
   if (body_msg) {
-    strncpy(s->return_xbuf, body_msg, HTTP_TRANSACT_STATE_MAX_XBUF_SIZE - 1);
-    s->return_xbuf[HTTP_TRANSACT_STATE_MAX_XBUF_SIZE - 1] = 0;
+    ink_strlcpy(s->return_xbuf, body_msg, HTTP_TRANSACT_STATE_MAX_XBUF_SIZE);
     s->return_xbuf_size = strlen(s->return_xbuf);
     s->return_xbuf_plain = plain_msg_flag;
   }
@@ -7008,7 +7019,7 @@ TSRedirectUrlSet(TSHttpTxn txnp, const c
   }
 
   sm->redirect_url = (char*)ats_malloc(url_len + 1);
-  ink_strncpy(sm->redirect_url, (char*)url, url_len + 1);
+  ink_strlcpy(sm->redirect_url, (char*)url, url_len + 1);
   sm->redirect_url_len = url_len;
   // have to turn redirection on for this transaction if user wants to redirect to another
URL
   if (sm->enable_redirection == false) {

Modified: trafficserver/traffic/trunk/proxy/api/ts/ts.h.in
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/api/ts/ts.h.in?rev=1171360&r1=1171359&r2=1171360&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/api/ts/ts.h.in (original)
+++ trafficserver/traffic/trunk/proxy/api/ts/ts.h.in Fri Sep 16 02:11:56 2011
@@ -931,11 +931,15 @@ extern "C"
 #define TSrealloc(p,s)   _TSrealloc ((p), (s), TS_RES_MEM_PATH)
 #define TSstrdup(p)      _TSstrdup ((p), -1, TS_RES_MEM_PATH)
 #define TSstrndup(p,n)   _TSstrdup ((p), (n), TS_RES_MEM_PATH)
+#define TSstrlcpy(d,s,l) _TSstrlcpy ((d), (s), (l))
+#define TSstrlcat(d,s,l) _TSstrlcat ((d), (s), (l))
 #define TSfree(p)        _TSfree (p)
 
   tsapi void* _TSmalloc(size_t size, const char* path);
   tsapi void* _TSrealloc(void* ptr, size_t size, const char* path);
   tsapi char* _TSstrdup(const char* str, int64_t length, const char* path);
+  tsapi size_t _TSstrlcpy(char *dst, const char *str, size_t siz);
+  tsapi size_t _TSstrlcat(char *dst, const char *str, size_t siz);
   tsapi void _TSfree(void* ptr);
 
   /* --------------------------------------------------------------------------



Mime
View raw message