ports/devel/gettext/patches/patch-gettext-runtime_intl_gnulib-lib_relocatable_c

46 lines
1.5 KiB
Text

Index: gettext-runtime/intl/gnulib-lib/relocatable.c
--- gettext-runtime/intl/gnulib-lib/relocatable.c.orig
+++ gettext-runtime/intl/gnulib-lib/relocatable.c
@@ -524,13 +524,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;
}
}
@@ -538,15 +542,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;
}
}