s390utils/SOURCES/s390-tools-zipl-bls-loadaddr.patch
2022-02-04 16:13:27 +00:00

147 lines
4.7 KiB
Diff

From ecf5a4ecb909bfd91306678d0c460ab2f2837a33 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 18 Nov 2019 04:10:06 -0500
Subject: [PATCH 1/3] zipl: drop redundant string duplication
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Dan Horák <dan@danny.cz>
---
zipl/src/scan.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/zipl/src/scan.c b/zipl/src/scan.c
index 38fa5454..0ea37efa 100644
--- a/zipl/src/scan.c
+++ b/zipl/src/scan.c
@@ -1575,7 +1575,6 @@ scan_check_bls(struct scan_token *scan)
int i, rc;
char *target_value = NULL;
char *img_value = NULL;
- char *buffer = NULL;
/*
* In the BLS case, each BLS section heading inherits a keyword
* assignment target= from zipl.conf, and they are all the same.
@@ -1609,14 +1608,8 @@ scan_check_bls(struct scan_token *scan)
scan[i].content.keyword.value);
return rc;
}
- buffer = (char *)
- misc_malloc(strlen(img_value) + 1);
- if (buffer == NULL)
- return -1;
- memcpy(buffer, img_value, strlen(img_value));
- buffer[strlen(img_value)] = 0;
free(scan[i].content.keyword.value);
- scan[i].content.keyword.value = buffer;
+ scan[i].content.keyword.value = img_value;
}
}
}
From 05f83569960e2774e819fe0942da1f92d0cce35b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 18 Nov 2019 04:29:04 -0500
Subject: [PATCH 2/3] zipl: set reason not text for failed check
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Dan Horák <dan@danny.cz>
---
zipl/src/scan.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/zipl/src/scan.c b/zipl/src/scan.c
index 0ea37efa..0f01cac9 100644
--- a/zipl/src/scan.c
+++ b/zipl/src/scan.c
@@ -1603,7 +1603,7 @@ scan_check_bls(struct scan_token *scan)
scan[i].content.keyword.value);
rc = misc_check_readable_file(img_value);
if (rc) {
- error_text(
+ error_reason(
"Image file '%s' is not accessible",
scan[i].content.keyword.value);
return rc;
From 8ab552b430f109d80966d0c56bed0d204d917d30 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Mon, 18 Nov 2019 11:45:50 -0500
Subject: [PATCH 3/3] zipl: fix handling of values with load address in BLS
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Various keywords (like image or ramdisk) allow specifying a load address
as an optional argument. Adapt the logic for checking the presence of
the files to take this into the account.
Fixes: https://github.com/ibm-s390-tools/s390-tools/commit/d71628326d80e623fc9f008fe4ea93edb5592b2e
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1772054
Signed-off-by: Dan Horák <dan@danny.cz>
---
zipl/src/scan.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/zipl/src/scan.c b/zipl/src/scan.c
index 0f01cac9..a34edf62 100644
--- a/zipl/src/scan.c
+++ b/zipl/src/scan.c
@@ -1575,6 +1575,8 @@ scan_check_bls(struct scan_token *scan)
int i, rc;
char *target_value = NULL;
char *img_value = NULL;
+ char *file = NULL;
+ char *tmp, *value;
/*
* In the BLS case, each BLS section heading inherits a keyword
* assignment target= from zipl.conf, and they are all the same.
@@ -1595,19 +1597,37 @@ scan_check_bls(struct scan_token *scan)
if (scan[i].content.keyword.keyword == scan_keyword_image ||
scan[i].content.keyword.keyword == scan_keyword_ramdisk) {
- rc = misc_check_readable_file(
- scan[i].content.keyword.value);
+ value = scan[i].content.keyword.value;
+ /*
+ * put the filename only into the file var before
+ * checking its presence
+ */
+ if (contains_address(value)) {
+ tmp = strrchr(value, ',');
+ file = strndup(value, tmp - value);
+ } else {
+ file = value;
+ }
+ rc = misc_check_readable_file(file);
if (rc) {
misc_asprintf(&img_value, "%s%s",
- target_value,
- scan[i].content.keyword.value);
+ target_value, file);
rc = misc_check_readable_file(img_value);
if (rc) {
error_reason(
- "Image file '%s' is not accessible",
- scan[i].content.keyword.value);
+ "File '%s' not accessible", file);
return rc;
}
+ /*
+ * when file has stripped the load address part,
+ * do generate a prefixed value
+ */
+ if (file != value) {
+ free(file);
+ free(img_value);
+ misc_asprintf(&img_value, "%s%s",
+ target_value, value);
+ }
free(scan[i].content.keyword.value);
scan[i].content.keyword.value = img_value;
}