[PATCH:libX11 5/7] XlcDL.c: replace strcpy+strcat sequences with snprintf

Alan Coopersmith alan.coopersmith at oracle.com
Fri Jan 1 18:15:00 PST 2016


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/xlibi18n/XlcDL.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/xlibi18n/XlcDL.c b/src/xlibi18n/XlcDL.c
index a236038..519103b 100644
--- a/src/xlibi18n/XlcDL.c
+++ b/src/xlibi18n/XlcDL.c
@@ -267,18 +267,20 @@ __lc_path(const char *dl_name, const char *lc_dir)
 	char *slash_p;
 	slash_p = strrchr(lc_dir, '/');
 	*slash_p = '\0';
-	strcpy(path, lc_dir); strcat(path, "/");
 #if defined POSTLOCALELIBDIR
-	strcat(path, POSTLOCALELIBDIR); strcat(path, "/");
+	snprintf(path, len + 1, "%s/%s/%s.so.2",
+		 lc_dir, POSTLOCALELIBDIR, dl_name);
+#else
+	snprintf(path, len + 1, "%s/%s.so.2", lc_dir, dl_name);
 #endif
-	strcat(path, dl_name); strcat(path, ".so.2");
 	*slash_p = '/';
     } else {
-	strcpy(path, lc_dir); strcat(path, "/");
 #if defined POSTLOCALELIBDIR
-	strcat(path, POSTLOCALELIBDIR); strcat(path, "/");
+	snprintf(path, len + 1, "%s/%s/%s.so.2",
+		 lc_dir, POSTLOCALELIBDIR, dl_name);
+#else
+	snprintf(path, len + 1, "%s/%s.so.2", lc_dir, dl_name);
 #endif
-	strcat(path, dl_name); strcat(path, ".so.2");
     }
     return path;
 }
-- 
2.6.1



More information about the xorg-devel mailing list