[前][次][番号順一覧][スレッド一覧]

ruby-changes:33112

From: nobu <ko1@a...>
Date: Thu, 27 Feb 2014 16:10:19 +0900 (JST)
Subject: [ruby-changes:33112] nobu:r45191 (trunk): use strlcat

nobu	2014-02-27 16:10:13 +0900 (Thu, 27 Feb 2014)

  New Revision: 45191

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=45191

  Log:
    use strlcat
    
    * addr2line.c (follow_debuglink): use strlcat instead of strncat.
    
    * dln.c (aix_loaderror): ditto.

  Modified files:
    trunk/addr2line.c
    trunk/dln.c
Index: addr2line.c
===================================================================
--- addr2line.c	(revision 45190)
+++ addr2line.c	(revision 45191)
@@ -444,10 +444,8 @@ follow_debuglink(char *debuglink, int nu https://github.com/ruby/ruby/blob/trunk/addr2line.c#L444
     subdir = (char *)alloca(strlen(binary_filename) + 1);
     strcpy(subdir, binary_filename);
     strcpy(binary_filename, global_debug_dir);
-    strncat(binary_filename, subdir,
-	    PATH_MAX - strlen(binary_filename) - 1);
-    strncat(binary_filename, debuglink,
-	    PATH_MAX - strlen(binary_filename) - 1);
+    strlcat(binary_filename, subdir, PATH_MAX);
+    strlcat(binary_filename, debuglink, PATH_MAX);
 
     munmap(current_line->mapped, current_line->mapped_size);
     close(current_line->fd);
Index: dln.c
===================================================================
--- dln.c	(revision 45190)
+++ dln.c	(revision 45191)
@@ -1180,7 +1180,7 @@ aix_loaderror(const char *pathname) https://github.com/ruby/ruby/blob/trunk/dln.c#L1180
 {
   char *message[1024], errbuf[1024];
   int i;
-#define ERRBUF_APPEND(s) strncat(errbuf, (s), sizeof(errbuf)-strlen(errbuf)-1)
+#define ERRBUF_APPEND(s) strlcat(errbuf, (s), sizeof(errbuf))
   snprintf(errbuf, sizeof(errbuf), "load failed - %s. ", pathname);
 
   if (loadquery(L_GETMESSAGES, &message[0], sizeof(message)) != -1) {

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]