[syslinux] SDI support works correctly (sdi.c32)

Remi Lefevre rlefevre at gmail.com
Wed Sep 3 06:45:30 PDT 2008


If you are sure that the checksum is valid for all SDI images,
I have nothing wrong with it. Peter will decide.

The following patch add missing fields in SDI header and checks its checksum:

(no git here, sorry, it's for current git extract
syslinux.git-89eb9d475b5073863660a489ebf529b5923ee275)

--- com32/modules/sdi.c.ini     2008-09-03 15:32:27.000000000 +0200
+++ com32/modules/sdi.c 2008-09-03 15:32:00.000000000 +0200
@@ -39,12 +39,25 @@
 # define dprintf(f, ...) ((void)0)
 #endif

+typedef uint8_t guid_t[16];
+
 struct SDIHeader {
   uint32_t Signature;
   char     Version[4];
   uint64_t SDIReserved;
   uint64_t BootCodeOffset;
   uint64_t BootCodeSize;
+  uint64_t VendorID;
+  uint64_t DeviceID;
+  guid_t   DeviceModel;
+  uint64_t DeviceRole;
+  uint64_t Reserved1;
+  guid_t   RuntimeGUID;
+  uint64_t RuntimeOEMrev;
+  uint64_t Reserved2;
+  uint64_t PageAlignment;   /* BLOB alignment value in pages */
+  uint64_t Reserved3[48];
+  uint64_t Checksum;
 };

 #define SDI_LOAD_ADDR   (16 << 20) /* 16 MB */
@@ -139,6 +152,21 @@
   return -1;
 }

+/*
+ * Check that the sum of all bytes from first 512 bytes (SDI header)
+ * is 0 modulo 256.
+ */
+int has_valid_header(unsigned char *header)
+{
+    unsigned char checksum;
+    unsigned int i;
+
+    checksum = 0;
+    for (i = 0; i < sizeof(struct SDIHeader); i++)
+        checksum += header[i];
+    return (!checksum);
+}
+
 int main(int argc, char *argv[])
 {
   void *data;
@@ -160,6 +188,11 @@
   }
   fputs("ok\n", stdout);

+  if (!has_valid_header(data)) {
+      error("SDI header is corrupted");
+      return 1;
+  }
+
   boot_sdi(data, data_len);
   error("Invalid SDI file or insufficient memory\n");
   return 1;




More information about the Syslinux mailing list