Drop trailing NUL in .sbat/.sdmagic sections (#34950)

This commit is contained in:
Lennart Poettering
2024-10-31 21:48:18 +01:00
committed by GitHub
3 changed files with 16 additions and 8 deletions
+2 -2
View File
@@ -1926,14 +1926,14 @@ static bool is_sd_boot(EFI_FILE *root_dir, const char16_t *loader_path) {
/* profile= */ UINT_MAX,
/* validate_base= */ 0,
&vector);
if (vector.memory_size != sizeof(SD_MAGIC))
if (vector.memory_size != STRLEN(SD_MAGIC))
return false;
err = file_handle_read(handle, vector.file_offset, vector.file_size, &content, &read);
if (err != EFI_SUCCESS || vector.file_size != read)
return false;
return memcmp(content, SD_MAGIC, sizeof(SD_MAGIC)) == 0;
return memcmp(content, SD_MAGIC, STRLEN(SD_MAGIC)) == 0;
}
static BootEntry* config_add_entry_loader_auto(
-1
View File
@@ -542,7 +542,6 @@ static inline uint64_t ALIGN_OFFSET_U64(uint64_t l, uint64_t ali) {
#define DECLARE_NOALLOC_SECTION(name, text) \
asm(".pushsection " name ",\"S\"\n\t" \
".ascii " STRINGIFY(text) "\n\t" \
".zero 1\n\t" \
".popsection\n")
#ifdef SBAT_DISTRO
+14 -5
View File
@@ -8,17 +8,26 @@
#include "sbat.h"
#include "tests.h"
TEST(sbat_section_text) {
log_info("---SBAT-----------&<----------------------------------------\n"
TEST(BOOT_SBAT) {
log_info("---SBAT-----------&<-----------------------------------------\n"
"%s"
"------------------>&-----------------------------------------",
#ifdef SBAT_DISTRO
SBAT_BOOT_SECTION_TEXT
#else
"(not defined)"
#endif
);
}
TEST(STUB_SBAT) {
log_info("---SBAT-----------&<-----------------------------------------\n"
"%s"
"------------------>&-----------------------------------------",
#ifdef SBAT_DISTRO
SBAT_BOOT_SECTION_TEXT,
SBAT_STUB_SECTION_TEXT
#else
"(not defined)",
""
"(not defined)"
#endif
);
}