nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0073-Replace-few-instances-of-memcmp-memcpy-in-the-code-t.patch

f725e3
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
f725e3
From: Vladimir Serbinenko <phcoder@gmail.com>
f725e3
Date: Fri, 4 Apr 2014 07:58:42 +0200
f725e3
Subject: [PATCH] Replace few instances of memcmp/memcpy in the code that
f725e3
 should be grub_memcmp/grub_memcpy.
f725e3
f725e3
---
f725e3
 grub-core/commands/acpihalt.c  | 4 ++--
f725e3
 grub-core/commands/legacycfg.c | 4 ++--
f725e3
 grub-core/lib/relocator.c      | 2 +-
f725e3
 grub-core/loader/i386/bsd.c    | 4 ++--
f725e3
 ChangeLog                      | 5 +++++
f725e3
 5 files changed, 12 insertions(+), 7 deletions(-)
f725e3
f725e3
diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c
f725e3
index 09421a6c69d..83bdfe1f23c 100644
f725e3
--- a/grub-core/commands/acpihalt.c
f725e3
+++ b/grub-core/commands/acpihalt.c
f725e3
@@ -214,8 +214,8 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
f725e3
 	  }
f725e3
 	case GRUB_ACPI_OPCODE_NAME:
f725e3
 	  ptr++;
f725e3
-	  if ((!scope || memcmp (scope, "\\", scope_len) == 0) &&
f725e3
-	      (memcmp (ptr, "_S5_", 4) == 0 || memcmp (ptr, "\\_S5_", 4) == 0))
f725e3
+	  if ((!scope || grub_memcmp (scope, "\\", scope_len) == 0) &&
f725e3
+	      (grub_memcmp (ptr, "_S5_", 4) == 0 || grub_memcmp (ptr, "\\_S5_", 4) == 0))
f725e3
 	    {
f725e3
 	      int ll;
f725e3
 	      grub_uint8_t *ptr2 = ptr;
f725e3
diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
f725e3
index e42a9d83ebb..2c09fb7dd78 100644
f725e3
--- a/grub-core/commands/legacycfg.c
f725e3
+++ b/grub-core/commands/legacycfg.c
f725e3
@@ -580,7 +580,7 @@ check_password_md5_real (const char *entered,
f725e3
   GRUB_MD_MD5->write (ctx, entered, enteredlen);
f725e3
   digest = GRUB_MD_MD5->read (ctx);
f725e3
   GRUB_MD_MD5->final (ctx);
f725e3
-  memcpy (alt_result, digest, MD5_HASHLEN);
f725e3
+  grub_memcpy (alt_result, digest, MD5_HASHLEN);
f725e3
   
f725e3
   GRUB_MD_MD5->init (ctx);
f725e3
   GRUB_MD_MD5->write (ctx, entered, enteredlen);
f725e3
@@ -596,7 +596,7 @@ check_password_md5_real (const char *entered,
f725e3
 
f725e3
   for (i = 0; i < 1000; i++)
f725e3
     {
f725e3
-      memcpy (alt_result, digest, 16);
f725e3
+      grub_memcpy (alt_result, digest, 16);
f725e3
 
f725e3
       GRUB_MD_MD5->init (ctx);
f725e3
       if ((i & 1) != 0)
f725e3
diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c
f725e3
index cb11ea5fa27..f759c7f41f4 100644
f725e3
--- a/grub-core/lib/relocator.c
f725e3
+++ b/grub-core/lib/relocator.c
f725e3
@@ -652,7 +652,7 @@ malloc_in_range (struct grub_relocator *rel,
f725e3
     for (i = 0; i < (BITS_IN_BYTE * sizeof (grub_addr_t) / DIGITSORT_BITS);
f725e3
 	 i++)
f725e3
       {
f725e3
-	memset (counter, 0, (1 + (1 << DIGITSORT_BITS)) * sizeof (counter[0]));
f725e3
+	grub_memset (counter, 0, (1 + (1 << DIGITSORT_BITS)) * sizeof (counter[0]));
f725e3
 	for (j = 0; j < N; j++)
f725e3
 	  counter[((events[j].pos >> (DIGITSORT_BITS * i)) 
f725e3
 		   & DIGITSORT_MASK) + 1]++;
f725e3
diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c
f725e3
index 19985f03e65..41ef9109ee1 100644
f725e3
--- a/grub-core/loader/i386/bsd.c
f725e3
+++ b/grub-core/loader/i386/bsd.c
f725e3
@@ -1082,7 +1082,7 @@ grub_netbsd_add_boot_disk_and_wedge (void)
f725e3
 
f725e3
     grub_crypto_hash (GRUB_MD_MD5, hash,
f725e3
 		      buf.raw, GRUB_DISK_SECTOR_SIZE);
f725e3
-    memcpy (biw.matchhash, hash, 16);
f725e3
+    grub_memcpy (biw.matchhash, hash, 16);
f725e3
 
f725e3
     grub_bsd_add_meta (NETBSD_BTINFO_BOOTWEDGE, &biw, sizeof (biw));
f725e3
   }
f725e3
@@ -1100,7 +1100,7 @@ grub_netbsd_add_boot_disk_and_wedge (void)
f725e3
 	bid.labelsector = partmapsector;
f725e3
 	bid.label.type = buf.label.type;
f725e3
 	bid.label.checksum = buf.label.checksum;
f725e3
-	memcpy (bid.label.packname, buf.label.packname, 16);
f725e3
+	grub_memcpy (bid.label.packname, buf.label.packname, 16);
f725e3
       }
f725e3
     else
f725e3
       {
f725e3
diff --git a/ChangeLog b/ChangeLog
f725e3
index 4a484092a6f..f18cdba90ce 100644
f725e3
--- a/ChangeLog
f725e3
+++ b/ChangeLog
f725e3
@@ -1,3 +1,8 @@
f725e3
+2014-04-04  Vladimir Serbinenko  <phcoder@gmail.com>
f725e3
+
f725e3
+	Replace few instances of memcmp/memcpy in the code that should be
f725e3
+	grub_memcmp/grub_memcpy.
f725e3
+
f725e3
 2014-04-03  Vladimir Serbinenko  <phcoder@gmail.com>
f725e3
 
f725e3
 	* grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Support NVMe