[syslinux:master] utils/isohybrid.c: Encode GPT partition names as UTF-16LE

syslinux-bot for Thomas Schmitt scdbackup at gmx.net
Mon Jun 23 20:09:04 PDT 2014


Commit-ID:  8059839edcfe819ca9cd135c67a905eb53943204
Gitweb:     http://www.syslinux.org/commit/8059839edcfe819ca9cd135c67a905eb53943204
Author:     Thomas Schmitt <scdbackup at gmx.net>
AuthorDate: Sun, 22 Jun 2014 22:24:17 +0200
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Mon, 23 Jun 2014 19:48:54 -0700

utils/isohybrid.c: Encode GPT partition names as UTF-16LE

The worst sin of isohybrid.c was to compose GPT partition names by
8-bit characters and to memcpy() them as if they were 16 bit wide.
GPT names are encoded as UTF-16LE. It is trivial to create this encoding
from 7-bit ASCII.

This change introduces two byte arrays with the desired UTF-16LE names
which replace the string constants "ISOHybrid ISO" and "ISOHybrid".

Signed-off-by: H. Peter Anvin <hpa at zytor.com>

---
 utils/isohybrid.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/utils/isohybrid.c b/utils/isohybrid.c
index 05afd29..c5b4281 100644
--- a/utils/isohybrid.c
+++ b/utils/isohybrid.c
@@ -749,6 +749,11 @@ initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary)
     struct gpt_part_header *part;
     int hole = 0;
     int gptsize = 128 / 4 + 2;
+    char part_name_iso[] = {'I', 0, 'S', 0, 'O', 0, 'H', 0, 'y', 0,
+                            'b', 0, 'r', 0, 'i', 0, 'd', 0, ' ', 0,
+                            'I', 0, 'S', 0, 'O', 0,   0, 0};
+    char part_name_bootimg[]= {'I', 0, 'S', 0, 'O', 0, 'H', 0, 'y', 0,
+                               'b', 0, 'r', 0, 'i', 0, 'd', 0,   0, 0};
 
     if (mac_lba) {
 	/* 2048 bytes per partition, plus round to 2048 boundary */
@@ -793,7 +798,7 @@ initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary)
     memcpy(part->partTypeGUID, basic_partition, sizeof(uuid_t));
     part->firstLBA = lendian_64(0);
     part->lastLBA = lendian_64(psize);
-    memcpy(part->name, "ISOHybrid ISO", 28);
+    memcpy(part->name, part_name_iso, 28);
 
     gpt += sizeof(struct gpt_part_header);
     part++;
@@ -802,7 +807,7 @@ initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary)
     memcpy(part->partTypeGUID, basic_partition, sizeof(uuid_t));
     part->firstLBA = lendian_64(efi_lba * 4);
     part->lastLBA = lendian_64(part->firstLBA + efi_count - 1);
-    memcpy(part->name, "ISOHybrid", 20);
+    memcpy(part->name, part_name_bootimg, 20);
 
     gpt += sizeof(struct gpt_part_header);
 
@@ -815,7 +820,7 @@ initialise_gpt(uint8_t *gpt, uint32_t current, uint32_t alternate, int primary)
 	memcpy(part->partTypeGUID, hfs_partition, sizeof(uuid_t));
 	part->firstLBA = lendian_64(mac_lba * 4);
 	part->lastLBA = lendian_64(part->firstLBA + mac_count - 1);
-	memcpy(part->name, "ISOHybrid", 20);
+	memcpy(part->name, part_name_bootimg, 20);
 
 	part--;
     }


More information about the Syslinux-commits mailing list