From 057098bfdcdbdc5bbd26fb51a7f8a37e6f8a2547 Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 27 Feb 2014 07:10:13 +0000 Subject: [PATCH] use strlcat * addr2line.c (follow_debuglink): use strlcat instead of strncat. * dln.c (aix_loaderror): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- addr2line.c | 6 ++---- dln.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/addr2line.c b/addr2line.c index f936694724..92ff6b152b 100644 --- a/addr2line.c +++ b/addr2line.c @@ -444,10 +444,8 @@ follow_debuglink(char *debuglink, int num_traces, void **traces, char **syms, 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); diff --git a/dln.c b/dln.c index e6b20d54e3..a3317984e7 100644 --- a/dln.c +++ b/dln.c @@ -1180,7 +1180,7 @@ aix_loaderror(const char *pathname) { 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) {