Explicitly pack vboot_struct structures, since they're going on disk.

Review URL: http://codereview.chromium.org/2829004
diff --git a/vboot_firmware/include/load_firmware_fw.h b/vboot_firmware/include/load_firmware_fw.h
index af97116..c6693c3 100644
--- a/vboot_firmware/include/load_firmware_fw.h
+++ b/vboot_firmware/include/load_firmware_fw.h
@@ -11,9 +11,10 @@
 
 #include <stdint.h>
 
-/* Maximum size of kernel_sign_key_blob in bytes, for implementations
- * which must preallocate a transfer buffer between boot phases */
-#define LOAD_FIRMWARE_KEY_BLOB_MAX 2104
+/* Recommended size of kernel_sign_key_blob in bytes, for
+ * implementations which must preallocate a transfer buffer between
+ * boot phases */
+#define LOAD_FIRMWARE_KEY_BLOB_REC_SIZE 2104
 
 /* Return codes for LoadFirmware() */
 #define LOAD_FIRMWARE_SUCCESS 0   /* Success */
diff --git a/vboot_firmware/lib/cgptlib/cgptlib_internal.c b/vboot_firmware/lib/cgptlib/cgptlib_internal.c
index 4f02293..7faf383 100644
--- a/vboot_firmware/lib/cgptlib/cgptlib_internal.c
+++ b/vboot_firmware/lib/cgptlib/cgptlib_internal.c
@@ -102,16 +102,16 @@
 }
 
 
-/* Return 1 if the entry is unused, 0 if it is used. */
+/* Return non-zero if the entry is unused, 0 if it is used. */
 int IsUnusedEntry(const GptEntry* e) {
   static Guid zero = {{{0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}}}};
-  return (Memcmp(&zero, (const uint8_t*)(&e->type), sizeof(zero)) ? 0 : 1);
+  return !Memcmp(&zero, (const uint8_t*)(&e->type), sizeof(zero));
 }
 
-/* Returns 1 if the entry is a Chrome OS kernel partition, else 0. */
+/* Returns non-zero if the entry is a Chrome OS kernel partition, else 0. */
 int IsKernelEntry(const GptEntry* e) {
   static Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL;
-  return (Memcmp(&e->type, &chromeos_kernel, sizeof(Guid)) ? 0 : 1);
+  return !Memcmp(&e->type, &chromeos_kernel, sizeof(Guid));
 }
 
 
diff --git a/vboot_firmware/lib/include/vboot_struct.h b/vboot_firmware/lib/include/vboot_struct.h
index c77fa4b..98366fb 100644
--- a/vboot_firmware/lib/include/vboot_struct.h
+++ b/vboot_firmware/lib/include/vboot_struct.h
@@ -19,7 +19,7 @@
                            * in bits) */
   uint64_t algorithm;      /* Signature algorithm used by the key */
   uint64_t key_version;    /* Key version */
-} VbPublicKey;
+} __attribute__((packed)) VbPublicKey;
 
 
 /* Signature data (a secure hash, possibly signed) */
@@ -28,7 +28,7 @@
                          * struct */
   uint64_t sig_size;    /* Size of signature data in bytes */
   uint64_t data_size;   /* Size of the data block which was signed in bytes */
-} VbSignature;
+} __attribute__((packed)) VbSignature;
 
 
 #define KEY_BLOCK_MAGIC "CHROMEOS"
@@ -61,7 +61,7 @@
                                       * For use with unsigned data keys */
   uint64_t key_block_flags;          /* Flags for key (KEY_BLOCK_FLAG_*) */
   VbPublicKey data_key;              /* Key to verify the chunk of data */
-} VbKeyBlockHeader;
+} __attribute__((packed)) VbKeyBlockHeader;
 /* This should be followed by:
  *   1) The data_key key data, pointed to by data_key.key_offset.
  *   2) The checksum data for (VBKeyBlockHeader + data_key data), pointed to
@@ -86,7 +86,7 @@
   uint64_t firmware_version;         /* Firmware version */
   VbPublicKey kernel_subkey;         /* Key to verify kernel key block */
   VbSignature body_signature;        /* Signature for the firmware body */
-} VbFirmwarePreambleHeader;
+} __attribute__((packed)) VbFirmwarePreambleHeader;
 /* This should be followed by:
  *   1) The kernel_subkey key data, pointed to by kernel_subkey.key_offset.
  *   2) The signature data for the firmware body, pointed to by
@@ -114,7 +114,7 @@
                                       * loaded at body_load_address */
   uint64_t bootloader_size;          /* Size of bootloader in bytes */
   VbSignature body_signature;        /* Signature for the kernel body */
-} VbKernelPreambleHeader;
+} __attribute__((packed)) VbKernelPreambleHeader;
 /* This should be followed by:
  *   2) The signature data for the kernel body, pointed to by
  *      body_signature.sig_offset.
diff --git a/vboot_firmware/stub/load_firmware_stub.c b/vboot_firmware/stub/load_firmware_stub.c
index 5bca57d..1570f70 100644
--- a/vboot_firmware/stub/load_firmware_stub.c
+++ b/vboot_firmware/stub/load_firmware_stub.c
@@ -83,8 +83,8 @@
   p.verification_block_1 = verification_headerB;
 
   /* Allocate a key blob buffer */
-  p.kernel_sign_key_blob = Malloc(LOAD_FIRMWARE_KEY_BLOB_MAX);
-  p.kernel_sign_key_size = LOAD_FIRMWARE_KEY_BLOB_MAX;
+  p.kernel_sign_key_blob = Malloc(LOAD_FIRMWARE_KEY_BLOB_REC_SIZE);
+  p.kernel_sign_key_size = LOAD_FIRMWARE_KEY_BLOB_REC_SIZE;
 
   /* Call LoadFirmware() */
   rv = LoadFirmware(&p);