summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/vendorcode/google/chromeos/fmap.c13
-rw-r--r--src/vendorcode/google/chromeos/fmap.h2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/vendorcode/google/chromeos/fmap.c b/src/vendorcode/google/chromeos/fmap.c
index 50b0248783..21d439e07d 100644
--- a/src/vendorcode/google/chromeos/fmap.c
+++ b/src/vendorcode/google/chromeos/fmap.c
@@ -26,10 +26,15 @@
static int is_fmap_signature_valid(const struct fmap *fmap)
{
- if (memcmp(fmap, FMAP_SIGNATURE, sizeof(FMAP_SIGNATURE) - 1)) {
- printk(BIOS_ERR, "No FMAP found at %p.\n", fmap);
- return 1;
- }
+ const char reversed_sig[] = FMAP_REVERSED_SIGNATURE;
+ const char *p2 = reversed_sig + sizeof(FMAP_REVERSED_SIGNATURE) - 2;
+ const char *p1 = (char *)fmap;
+
+ while (p2 >= reversed_sig)
+ if (*p1++ != *p2--) {
+ printk(BIOS_ERR, "No FMAP found at %p.\n", fmap);
+ return 1;
+ }
printk(BIOS_DEBUG, "FMAP: Found \"%s\" version %d.%d at %p.\n",
fmap->name, fmap->ver_major, fmap->ver_minor, fmap);
diff --git a/src/vendorcode/google/chromeos/fmap.h b/src/vendorcode/google/chromeos/fmap.h
index a3d2abd582..05d3fb6e1d 100644
--- a/src/vendorcode/google/chromeos/fmap.h
+++ b/src/vendorcode/google/chromeos/fmap.h
@@ -38,7 +38,7 @@
#include <stdint.h>
-#define FMAP_SIGNATURE "__FMAP__"
+#define FMAP_REVERSED_SIGNATURE "__PAMF__" /* avoid magic number in .rodata */
#define FMAP_VER_MAJOR 1 /* this header's FMAP minor version */
#define FMAP_VER_MINOR 1 /* this header's FMAP minor version */
#define FMAP_STRLEN 32 /* maximum length for strings, */