grub2/0052-udf-Fix-reading-label-lvd.ident-is-dstring.patch
Peter Jones 81987f4958 Update grub2 for f28
- Try to fix things for new compiler madness.
  I really don't know why gcc decided __attribute__((packed)) on a "typedef
  struct" should imply __attribute__((align (1))) and that it should have a
  warning that it does so.  The obvious behavior would be to keep the alignment
  of the first element unless it's used in another object or type that /also/
  hask the packed attribute.  Why should it change the default alignment at
  all?
- Merge in the BLS patches Javier and I wrote.
- Attempt to fix pmtimer initialization failures to not be super duper slow.

Signed-off-by: Peter Jones <pjones@redhat.com>
2018-02-28 09:40:44 -05:00

55 lines
1.5 KiB
Diff

From 76188809d5ca40c5285b0ab202b5edea7be3f04d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali.rohar@gmail.com>
Date: Thu, 22 Jun 2017 14:33:17 +0200
Subject: [PATCH 052/206] udf: Fix reading label, lvd.ident is dstring
UDF dstring has stored length in the last byte of buffer. Therefore last
byte is not part of recorded characters. And empty string in dstring is
encoded as empty buffer, including first byte (compression id).
---
grub-core/fs/udf.c | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c
index 839bff88963..2587456336e 100644
--- a/grub-core/fs/udf.c
+++ b/grub-core/fs/udf.c
@@ -860,6 +860,25 @@ read_string (const grub_uint8_t *raw, grub_size_t sz, char *outbuf)
return outbuf;
}
+static char *
+read_dstring (const grub_uint8_t *raw, grub_size_t sz)
+{
+ grub_size_t len;
+
+ if (raw[0] == 0) {
+ char *outbuf = grub_malloc (1);
+ if (!outbuf)
+ return NULL;
+ outbuf[0] = 0;
+ return outbuf;
+ }
+
+ len = raw[sz - 1];
+ if (len > sz - 1)
+ len = sz - 1;
+ return read_string (raw, len, NULL);
+}
+
static int
grub_udf_iterate_dir (grub_fshelp_node_t dir,
grub_fshelp_iterate_dir_hook_t hook, void *hook_data)
@@ -1197,7 +1216,7 @@ grub_udf_label (grub_device_t device, char **label)
if (data)
{
- *label = read_string (data->lvd.ident, sizeof (data->lvd.ident), 0);
+ *label = read_dstring (data->lvd.ident, sizeof (data->lvd.ident));
grub_free (data);
}
else
--
2.15.0