* grub-core/fs/iso9660.c: Replace strncat with memcpy.

* include/grub/misc.h: Remove strncat.
	* grub-core/lib/posix_wrap/string.h: Likewise.
This commit is contained in:
Vladimir Serbinenko 2013-10-26 12:49:51 +02:00
parent 6d1fc99ab5
commit 2a8a75855c
4 changed files with 16 additions and 36 deletions

View file

@ -1,3 +1,9 @@
2013-10-26 Vladimir Serbinenko <phcoder@gmail.com>
* 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 <phcoder@gmail.com> 2013-10-26 Vladimir Serbinenko <phcoder@gmail.com>
* tests/date_unit_test.c: New test. * tests/date_unit_test.c: New test.

View file

@ -536,8 +536,8 @@ add_part (struct iterate_dir_ctx *ctx,
if (! ctx->symlink) if (! ctx->symlink)
return; return;
ctx->symlink[size] = 0; grub_memcpy (ctx->symlink + size, part, len2);
grub_strncat (ctx->symlink, part, len2); ctx->symlink[size + len2] = 0;
} }
static grub_err_t static grub_err_t
@ -558,20 +558,19 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry,
ctx->filename = (char *) ".."; ctx->filename = (char *) "..";
else if (entry->len >= 5) else if (entry->len >= 5)
{ {
grub_size_t size = 1, csize = 1; grub_size_t off = 0, csize = 1;
char *old; char *old;
csize = size = entry->len - 5; csize = entry->len - 5;
old = ctx->filename; old = ctx->filename;
if (ctx->filename_alloc) if (ctx->filename_alloc)
{ {
size += grub_strlen (ctx->filename); off = grub_strlen (ctx->filename);
ctx->filename = grub_realloc (ctx->filename, size + 1); ctx->filename = grub_realloc (ctx->filename, csize + off + 1);
} }
else else
{ {
ctx->filename_alloc = 1; off = 0;
ctx->filename = grub_zalloc (size + 1); ctx->filename = grub_zalloc (csize + 1);
ctx->filename[0] = 0;
} }
if (!ctx->filename) if (!ctx->filename)
{ {
@ -579,8 +578,8 @@ susp_iterate_dir (struct grub_iso9660_susp_entry *entry,
return grub_errno; return grub_errno;
} }
ctx->filename_alloc = 1; ctx->filename_alloc = 1;
grub_strncat (ctx->filename, (char *) &entry->data[1], csize); grub_memcpy (ctx->filename + off, (char *) &entry->data[1], csize);
ctx->filename[size] = '\0'; ctx->filename[off + csize] = '\0';
} }
} }
/* The mode information (st_mode). */ /* The mode information (st_mode). */

View file

@ -93,12 +93,6 @@ strcat (char *dest, const char *src)
return grub_strcat (dest, 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 static inline int
strcoll (const char *s1, const char *s2) strcoll (const char *s1, const char *s2)
{ {

View file

@ -104,25 +104,6 @@ grub_strcat (char *dest, const char *src)
return dest; 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. */ /* Prototypes for aliases. */
#ifndef GRUB_UTIL #ifndef GRUB_UTIL
#ifdef __APPLE__ #ifdef __APPLE__