Skip to contentSkip to conversation

makedumpfile, sadump: fix two GUID print bugs

PATCH In review HATAYAMA Daisuke 2 participants 4 messages Sep 13, 2013 – Sep 17, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover makedumpfile, sadump: fix two GUID print bugs

Hello Kumagai-san,

These are fixing the two bugs in printing GUID on sadump format. Could you apply these?

These patchs are built on top of v1.5.4.

---

HATAYAMA Daisuke (2):
sadump: correct buffer size for GUID EFI text representation
sadump: convert the first three fields of EFI GUID from little-endian into big-endian

 sadump_info.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
Signature · 7 lines
Thanks.
HATAYAMA, Daisuke

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#1 lore raw

PATCH 1/2 sadump: correct buffer size for GUID EFI text representation

While GUID EFI text representaion needs 36 bytes, all the buffers for GUID EFI passed to guid_to_str() are of 33 bytes, due to which last three characters in GUID are not displayed now.

This patch increases buffer size from 33 bytes to 36 bytes and make GUID fully visible.

---
 sadump_info.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
sadump_info.c +4 -2
index be6cf55..e563180 100644
@@ -23,6 +23,8 @@
 #include "print_info.h"
 #include "sadump_mod.h"
 
+#define SADUMP_EFI_GUID_TEXT_REPR_LEN 36
+
 #ifdef __x86__
 
 #define KEXEC_NOTE_HEAD_BYTES roundup(sizeof(Elf32_Nhdr), 4)
@@ -427,7 +429,7 @@ read_sadump_header(char *filename)
 	unsigned long bitmap_len, dumpable_bitmap_len;
 	enum sadump_format_type flag_sadump;
 	uint32_t smram_cpu_state_size = 0;
-	char guid[33];
+	char guid[SADUMP_EFI_GUID_TEXT_REPR_LEN+1];
 
 	if ((si->sph_memory = malloc(SADUMP_DEFAULT_BLOCK_SIZE)) == NULL) {
 		ERRMSG("Can't allocate memory for partition header buffer: "
@@ -664,7 +666,7 @@ read_sadump_header_diskset(int diskid, struct sadump_diskset_info *sdi)
 {
 	struct sadump_part_header *sph = NULL;
 	unsigned long offset = 0;
-	char guid[33];
+	char guid[SADUMP_EFI_GUID_TEXT_REPR_LEN+1];
 
 	if ((sph = malloc(si->sh_memory->block_size)) == NULL) {
 		ERRMSG("Can't allocate memory for partition header buffer. "

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#2 lore raw

PATCH 2/2 sadump: convert the first three fields of EFI GUID from little-endian into big-endian

In reply to HATAYAMA Daisuke

Although RFC 4122 recommends network byte order for all fields of UUID, EFI GUID uses little-endian for the first three fields TimeLow, TimeMid and TimeHighAndVersion. Thus, in text representation of the GUID, converting the three fields from little-endian into big-endian is needed.

---
 sadump_info.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
sadump_info.c +3 -1
index e563180..84126b1 100644
@@ -23,6 +23,8 @@
 #include "print_info.h"
 #include "sadump_mod.h"
 
+#include <arpa/inet.h> /* htonl, htons */
+
 #define SADUMP_EFI_GUID_TEXT_REPR_LEN 36
 
 #ifdef __x86__
@@ -334,7 +336,7 @@ guid_to_str(efi_guid_t *guid, char *buf, size_t buflen)
 {
 	snprintf(buf, buflen,
 		 "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-		 guid->data1, guid->data2, guid->data3,
+		 htonl(guid->data1), htons(guid->data2), htons(guid->data3),
 		 guid->data4[0], guid->data4[1], guid->data4[2],
 		 guid->data4[3], guid->data4[4], guid->data4[5],
 		 guid->data4[6], guid->data4[7]);

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#3 lore raw
In reply to HATAYAMA Daisuke

Hello HATAYAMA-san,

Quoted 4 lines · HATAYAMA Daisuke

Hello Kumagai-san,

These are fixing the two bugs in printing GUID on sadump format. Could you apply these?

Sure, I'll merge these into v1.5.5.

Thanks
Atsushi Kumagai

Quoted 4 lines

These patchs are built on top of v1.5.4.

---

Quoted 8 lines

HATAYAMA Daisuke (2):
sadump: correct buffer size for GUID EFI text representation
sadump: convert the first three fields of EFI GUID from little-endian into big-endian

  sadump_info.c |   10 +++++++---
  1 file changed, 7 insertions(+), 3 deletions(-)

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec