* [PATCH 1/2] sadump: correct buffer size for GUID EFI text representation
2013-09-13 10:53 [PATCH 0/2] makedumpfile, sadump: fix two GUID print bugs HATAYAMA Daisuke
@ 2013-09-13 10:53 ` HATAYAMA Daisuke
2013-09-13 10:53 ` [PATCH 2/2] sadump: convert the first three fields of EFI GUID from little-endian into big-endian HATAYAMA Daisuke
2013-09-17 6:20 ` [PATCH 0/2] makedumpfile, sadump: fix two GUID print bugs Atsushi Kumagai
2 siblings, 0 replies; 4+ messages in thread
From: HATAYAMA Daisuke @ 2013-09-13 10:53 UTC (permalink / raw)
To: kumagai-atsushi; +Cc: kexec
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.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
---
sadump_info.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sadump_info.c b/sadump_info.c
index be6cf55..e563180 100644
--- a/sadump_info.c
+++ b/sadump_info.c
@@ -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
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] sadump: convert the first three fields of EFI GUID from little-endian into big-endian
2013-09-13 10:53 [PATCH 0/2] makedumpfile, sadump: fix two GUID print bugs HATAYAMA Daisuke
2013-09-13 10:53 ` [PATCH 1/2] sadump: correct buffer size for GUID EFI text representation HATAYAMA Daisuke
@ 2013-09-13 10:53 ` HATAYAMA Daisuke
2013-09-17 6:20 ` [PATCH 0/2] makedumpfile, sadump: fix two GUID print bugs Atsushi Kumagai
2 siblings, 0 replies; 4+ messages in thread
From: HATAYAMA Daisuke @ 2013-09-13 10:53 UTC (permalink / raw)
To: kumagai-atsushi; +Cc: kexec
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.
Signed-off-by: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
---
sadump_info.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sadump_info.c b/sadump_info.c
index e563180..84126b1 100644
--- a/sadump_info.c
+++ b/sadump_info.c
@@ -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
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 4+ messages in thread