From: Vladimir Serbinenko Date: Sat, 26 Oct 2013 10:49:51 +0000 (+0200) Subject: * grub-core/fs/iso9660.c: Replace strncat with memcpy. X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=2a8a75855c03f61c234845f9e0f6a9e9ed2b8c54;p=grub2.git * grub-core/fs/iso9660.c: Replace strncat with memcpy. * include/grub/misc.h: Remove strncat. * grub-core/lib/posix_wrap/string.h: Likewise. --- diff --git a/ChangeLog b/ChangeLog index cc7c43fc1..1b4f29d65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2013-10-26 Vladimir Serbinenko + + * grub-core/fs/iso9660.c: Replace strncat with memcpy. + * include/grub/misc.h: Remove strncat. + * grub-core/lib/posix_wrap/string.h: Likewise. + 2013-10-26 Vladimir Serbinenko * tests/date_unit_test.c: New test. diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index 731c024dd..69e61ca02 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -536,8 +536,8 @@ add_part (struct iterate_dir_ctx *ctx, if (! ctx->symlink) return; - ctx->symlink[size] = 0; - grub_strncat (ctx->symlink, part, len2); + grub_memcpy (ctx->symlink + size, part, len2); + ctx->symlink[size + len2] = 0; } static grub_err_t @@ -558,20 +558,19 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, ctx->filename = (char *) ".."; else if (entry->len >= 5) { - grub_size_t size = 1, csize = 1; + grub_size_t off = 0, csize = 1; char *old; - csize = size = entry->len - 5; + csize = entry->len - 5; old = ctx->filename; if (ctx->filename_alloc) { - size += grub_strlen (ctx->filename); - ctx->filename = grub_realloc (ctx->filename, size + 1); + off = grub_strlen (ctx->filename); + ctx->filename = grub_realloc (ctx->filename, csize + off + 1); } else { - ctx->filename_alloc = 1; - ctx->filename = grub_zalloc (size + 1); - ctx->filename[0] = 0; + off = 0; + ctx->filename = grub_zalloc (csize + 1); } if (!ctx->filename) { @@ -579,8 +578,8 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry, return grub_errno; } ctx->filename_alloc = 1; - grub_strncat (ctx->filename, (char *) &entry->data[1], csize); - ctx->filename[size] = '\0'; + grub_memcpy (ctx->filename + off, (char *) &entry->data[1], csize); + ctx->filename[off + csize] = '\0'; } } /* The mode information (st_mode). */ diff --git a/grub-core/lib/posix_wrap/string.h b/grub-core/lib/posix_wrap/string.h index 53ef0a9a7..b508a5111 100644 --- a/grub-core/lib/posix_wrap/string.h +++ b/grub-core/lib/posix_wrap/string.h @@ -93,12 +93,6 @@ strcat (char *dest, const char *src) return grub_strcat (dest, src); } -static inline char * -strncat (char *dest, const char *src, grub_size_t n) -{ - return grub_strncat (dest, src, n); -} - static inline int strcoll (const char *s1, const char *s2) { diff --git a/include/grub/misc.h b/include/grub/misc.h index 7bef173b5..6707fe384 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -104,25 +104,6 @@ grub_strcat (char *dest, const char *src) return dest; } -static inline char * -grub_strncat (char *dest, const char *src, int c) -{ - char *p = dest; - - while (*p) - p++; - - while (c-- && (*p = *src) != '\0') - { - p++; - src++; - } - - *p = '\0'; - - return dest; -} - /* Prototypes for aliases. */ #ifndef GRUB_UTIL #ifdef __APPLE__