]> git.proxmox.com Git - grub2.git/commitdiff
* grub-core/fs/iso9660.c: Replace strncat with memcpy.
authorVladimir Serbinenko <phcoder@gmail.com>
Sat, 26 Oct 2013 10:49:51 +0000 (12:49 +0200)
committerVladimir Serbinenko <phcoder@gmail.com>
Sat, 26 Oct 2013 10:49:51 +0000 (12:49 +0200)
* include/grub/misc.h: Remove strncat.
* grub-core/lib/posix_wrap/string.h: Likewise.

ChangeLog
grub-core/fs/iso9660.c
grub-core/lib/posix_wrap/string.h
include/grub/misc.h

index cc7c43fc17289aebbd081cd88643293ebfbb82e8..1b4f29d65f081d646d5a595e8669eb79ad508512 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        * tests/date_unit_test.c: New test.
index 731c024dd6668729341ea5b2d9ea987b97ab67f0..69e61ca023145ce491caa90ebaf0068e4b962168 100644 (file)
@@ -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).  */
index 53ef0a9a7676b42b2ca724d093f40c4f48a194d4..b508a51117e04eedfcd9b02cfa88a36dac7bdc5b 100644 (file)
@@ -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)
 {
index 7bef173b59fcfc2ca2ad411ce2b620e0065d0ac9..6707fe3848b58dc081b26e8fc963e71c204860f5 100644 (file)
@@ -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__