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

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