dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

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

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