-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iso] fix FAT filenames being truncated on image extraction
* Needed to read 12 chars instead of stopping at 11 and therefore inserting a NUL. * Closes #2534. * Also enable detection of bootriscv64.efi and bootloongarch64.efi bootloaders from FAT images.
- Loading branch information
Showing
4 changed files
with
32 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* ----------------------------------------------------------------------- * | ||
* | ||
* Copyright 2019 Pete Batard <[email protected]> | ||
* Copyright 2019-2024 Pete Batard <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -19,6 +19,10 @@ | |
#include <string.h> | ||
#include "libfatint.h" | ||
|
||
#ifndef ARRAYSIZE | ||
#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a))) | ||
#endif | ||
|
||
static struct fat_dirent* get_next_dirent(struct libfat_filesystem *fs, | ||
libfat_sector_t *sector, int *offset) | ||
{ | ||
|
@@ -41,12 +45,12 @@ static struct fat_dirent* get_next_dirent(struct libfat_filesystem *fs, | |
static void fill_utf16(wchar_t *name, unsigned char *entry) | ||
{ | ||
int i; | ||
for (i=0; i<5; i++) | ||
name[i] = read16((le16_t*)&entry[1 + 2*i]); | ||
for (i=5; i<11; i++) | ||
name[i] = read16((le16_t*)&entry[4 + 2*i]); | ||
for (i=11; i<12; i++) | ||
name[i] = read16((le16_t*)&entry[6 + 2*i]); | ||
for (i = 0; i < 5; i++) | ||
name[i] = read16((le16_t*)&entry[1 + 2 * i]); | ||
for (i = 5; i < 11; i++) | ||
name[i] = read16((le16_t*)&entry[4 + 2 * i]); | ||
for (i = 11; i < 13; i++) | ||
name[i] = read16((le16_t*)&entry[6 + 2 * i]); | ||
} | ||
|
||
int libfat_dumpdir(struct libfat_filesystem *fs, libfat_dirpos_t *dp, | ||
|
@@ -94,11 +98,14 @@ int libfat_dumpdir(struct libfat_filesystem *fs, libfat_dirpos_t *dp, | |
if ((j >= 0) && (i != j - 1)) | ||
return -3; | ||
j = i; | ||
if (i > ARRAYSIZE(di->name) - 13) | ||
i = ARRAYSIZE(di->name) - 13; | ||
fill_utf16(&di->name[13 * i], dep->name); | ||
dep = get_next_dirent(fs, &dp->sector, &dp->offset); | ||
if (!dep) | ||
return -1; | ||
} | ||
di->name[ARRAYSIZE(di->name) - 1] = 0; | ||
|
||
if (di->name[0] == 0) { | ||
for (i = 0, j = 0; i < 12; i++) { | ||
|