trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iga...@apache.org
Subject svn commit: r1171823 - in /trafficserver/traffic/trunk/lib/ts: Layout.cc Version.cc
Date Fri, 16 Sep 2011 22:10:57 GMT
Author: igalic
Date: Fri Sep 16 22:10:57 2011
New Revision: 1171823

URL: http://svn.apache.org/viewvc?rev=1171823&view=rev
Log:
TS-953: consolidate string copy/concat for lib/ts.

Modified:
    trafficserver/traffic/trunk/lib/ts/Layout.cc
    trafficserver/traffic/trunk/lib/ts/Version.cc

Modified: trafficserver/traffic/trunk/lib/ts/Layout.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/Layout.cc?rev=1171823&r1=1171822&r2=1171823&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/Layout.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/Layout.cc Fri Sep 16 22:10:57 2011
@@ -96,7 +96,7 @@ Layout::relative(char *buf, size_t bufsz
     ink_error("Provided buffer is too small: %d, required %d\n", bufsz, path_len);
   }
   else {
-    strcpy(buf, path);
+    ink_strlcpy(buf, path, bufsz);
   }
 }
 
@@ -130,7 +130,7 @@ Layout::relative_to(char *buf, size_t bu
     ink_error("Provided buffer is too small: %d, required %d\n", bufsz, path_len);
   }
   else {
-    strcpy(buf, path);
+    ink_strlcpy(buf, path, bufsz);
   }
 }
 
@@ -149,14 +149,14 @@ Layout::Layout(const char *_prefix)
         ink_error("TS_ROOT environment variable is too big: %d, max %d\n", len, PATH_NAME_MAX
-1);
         return;
       }
-      strcpy(path, env_path);
+      ink_strlcpy(path, env_path, sizeof(path));
       while (len > 1 && path[len - 1] == '/') {
         path[len - 1] = '\0';
         --len;
       }
     } else {
         // Use compile time --prefix
-      ink_strncpy(path, TS_BUILD_PREFIX, sizeof(path));
+      ink_strlcpy(path, TS_BUILD_PREFIX, sizeof(path));
     }
 
     if (access(path, R_OK) == -1) {

Modified: trafficserver/traffic/trunk/lib/ts/Version.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/lib/ts/Version.cc?rev=1171823&r1=1171822&r2=1171823&view=diff
==============================================================================
--- trafficserver/traffic/trunk/lib/ts/Version.cc (original)
+++ trafficserver/traffic/trunk/lib/ts/Version.cc Fri Sep 16 22:10:57 2011
@@ -28,16 +28,16 @@
 AppVersionInfo::AppVersionInfo()
 {
   defined = 0;
-  ink_strncpy(PkgStr, "?", sizeof(PkgStr));
-  ink_strncpy(AppStr, "?", sizeof(AppStr));
-  ink_strncpy(VersionStr, "?", sizeof(VersionStr));
-  ink_strncpy(BldNumStr, "?", sizeof(BldNumStr));
-  ink_strncpy(BldTimeStr, "?", sizeof(BldTimeStr));
-  ink_strncpy(BldDateStr, "?", sizeof(BldDateStr));
-  ink_strncpy(BldMachineStr, "?", sizeof(BldMachineStr));
-  ink_strncpy(BldPersonStr, "?", sizeof(BldPersonStr));
-  ink_strncpy(BldCompileFlagsStr, "?", sizeof(BldCompileFlagsStr));
-  ink_strncpy(FullVersionInfoStr, "?", sizeof(FullVersionInfoStr));
+  ink_strlcpy(PkgStr, "?", sizeof(PkgStr));
+  ink_strlcpy(AppStr, "?", sizeof(AppStr));
+  ink_strlcpy(VersionStr, "?", sizeof(VersionStr));
+  ink_strlcpy(BldNumStr, "?", sizeof(BldNumStr));
+  ink_strlcpy(BldTimeStr, "?", sizeof(BldTimeStr));
+  ink_strlcpy(BldDateStr, "?", sizeof(BldDateStr));
+  ink_strlcpy(BldMachineStr, "?", sizeof(BldMachineStr));
+  ink_strlcpy(BldPersonStr, "?", sizeof(BldPersonStr));
+  ink_strlcpy(BldCompileFlagsStr, "?", sizeof(BldCompileFlagsStr));
+  ink_strlcpy(FullVersionInfoStr, "?", sizeof(FullVersionInfoStr));
   // coverity[uninit_member]
 }
 
@@ -68,8 +68,8 @@ AppVersionInfo::setup(const char *pkg_na
   ///////////////////////////////////////////
   // now construct the version information //
   ///////////////////////////////////////////
-  ink_strncpy(PkgStr, pkg_name, sizeof(PkgStr));
-  ink_strncpy(AppStr, app_name, sizeof(AppStr));
+  ink_strlcpy(PkgStr, pkg_name, sizeof(PkgStr));
+  ink_strlcpy(AppStr, app_name, sizeof(AppStr));
   snprintf(VersionStr, sizeof(VersionStr), "%s", app_version);
   snprintf(BldNumStr, sizeof(BldNumStr), "%d%d%d", month, day, hour);
   snprintf(BldTimeStr, sizeof(BldTimeStr), "%s", build_time);
@@ -86,25 +86,25 @@ AppVersionInfo::setup(const char *pkg_na
   // the manager doesn't like empty strings, so prevent them //
   /////////////////////////////////////////////////////////////
   if (PkgStr[0] == '\0')
-    ink_strncpy(PkgStr, "?", sizeof(PkgStr));
+    ink_strlcpy(PkgStr, "?", sizeof(PkgStr));
   if (AppStr[0] == '\0')
-    ink_strncpy(AppStr, "?", sizeof(AppStr));
+    ink_strlcpy(AppStr, "?", sizeof(AppStr));
   if (VersionStr[0] == '\0')
-    ink_strncpy(VersionStr, "?", sizeof(VersionStr));
+    ink_strlcpy(VersionStr, "?", sizeof(VersionStr));
   if (BldNumStr[0] == '\0')
-    ink_strncpy(BldNumStr, "?", sizeof(BldNumStr));
+    ink_strlcpy(BldNumStr, "?", sizeof(BldNumStr));
   if (BldTimeStr[0] == '\0')
-    ink_strncpy(BldTimeStr, "?", sizeof(BldTimeStr));
+    ink_strlcpy(BldTimeStr, "?", sizeof(BldTimeStr));
   if (BldDateStr[0] == '\0')
-    ink_strncpy(BldDateStr, "?", sizeof(BldDateStr));
+    ink_strlcpy(BldDateStr, "?", sizeof(BldDateStr));
   if (BldMachineStr[0] == '\0')
-    ink_strncpy(BldMachineStr, "?", sizeof(BldMachineStr));
+    ink_strlcpy(BldMachineStr, "?", sizeof(BldMachineStr));
   if (BldPersonStr[0] == '\0')
-    ink_strncpy(BldPersonStr, "?", sizeof(BldPersonStr));
+    ink_strlcpy(BldPersonStr, "?", sizeof(BldPersonStr));
   if (BldCompileFlagsStr[0] == '\0')
-    ink_strncpy(BldCompileFlagsStr, "?", sizeof(BldCompileFlagsStr));
+    ink_strlcpy(BldCompileFlagsStr, "?", sizeof(BldCompileFlagsStr));
   if (FullVersionInfoStr[0] == '\0')
-    ink_strncpy(FullVersionInfoStr, "?", sizeof(FullVersionInfoStr));
+    ink_strlcpy(FullVersionInfoStr, "?", sizeof(FullVersionInfoStr));
 
   defined = 1;
 }



Mime
View raw message