$OpenBSD: patch-gettext-runtime_intl_relocatable_c,v 1.3 2010/07/03 03:23:22 naddy Exp $ --- gettext-runtime/intl/relocatable.c.orig Sat Dec 12 16:08:01 2009 +++ gettext-runtime/intl/relocatable.c Tue Jun 29 00:13:57 2010 @@ -459,13 +459,17 @@ relocate (const char *pathname) if (pathname[orig_prefix_len] == '\0') { /* pathname equals orig_prefix. */ - char *result = (char *) xmalloc (strlen (curr_prefix) + 1); + char *result; + size_t len; + len = strlen (curr_prefix) + 1; + result = (char *) xmalloc (len); + #ifdef NO_XMALLOC if (result != NULL) #endif { - strcpy (result, curr_prefix); + strlcpy (result, curr_prefix, len); return result; } } @@ -473,15 +477,19 @@ relocate (const char *pathname) { /* pathname starts with orig_prefix. */ const char *pathname_tail = &pathname[orig_prefix_len]; - char *result = - (char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1); + char *result; + size_t len; + len = curr_prefix_len + strlen (pathname_tail) + 1; + result = (char *) xmalloc (len); + #ifdef NO_XMALLOC if (result != NULL) #endif { memcpy (result, curr_prefix, curr_prefix_len); - strcpy (result + curr_prefix_len, pathname_tail); + result[curr_prefix_len] = '\0'; + strlcat (result, pathname_tail, len); return result; } }