* Incorrect EFI_FILE_PROTOCOL version
The driver implements EFI_FILE_PROTOCOL_REVISION version,
not EFI_FILE_PROTOCOL_REVISION2 version.
* Fix directory reading logic by implementing EFI_FILE_INFO cache
Problem:
According to the UEFI specification, reading from a directory must
return zero Size for the EFI_FILE_INFO structure when directory
entries are exhausted. The original FileReadDir() implementation
always returned a fixed EFI_FILE_INFO size before reporting
end-of-directory. This caused fuzzing tests to enter an infinite
directory iteration loop due to unexpected behavior.
Solution:
Introduced an EFI_FILE_INFO cache with the following logic:
1. FileReadDir() caches EFI_FILE_INFO on first read. The cache key
combines directory path hash (with FNV-1a 64-bit hashing) and
DirIndex value
2. When the key matches and buffer size is sufficient:
- Data is returned from cache
- Cache is cleared
3. When the key matches with insufficent buffer size:
- Cache is preserved for subsequent retries
4. Key mismatch triggers cache reset
Additional benefits:
- Eliminates fixed MINIMUM_INFO_LENGTH requirement
- FileReadDir() now requests only required buffer size
Note:
A more elegant solution is being considered for future NTFS
driver improvements, requiring further analysis and testing.
Links:
FNV Hash: http://www.isthe.com/chongo/tech/comp/fnv/index.html
* Fix memory leak in FileReadDir() function
Function NtfsOppen() allocates additional memory for
file structure. After use it, need to free by call FreeFile()
function.
* Fixed invalid pointer access in ReadAttr() function
Solution:
- Added a null check for the Current field in ReadAttr() function
- Added validation for MFT record flags in the InitFile() function
Signed-off-by: Pavel Naberezhnev <pavelnaberezhnev@gmail.com>
OpenCore bootloader with development SDK.
Libraries
This repository also contains additional UEFI support common libraries shared by other projects in Acidanthera. The primary purpose of the library set is to provide supplemental functionality for Apple-specific UEFI drivers. Key features:
- Apple disk image loading support
- Apple keyboard input aggregation
- Apple PE image signature verification
- Apple UEFI secure boot supplemental code
- Audio management with screen reading support
- Basic ACPI and SMBIOS manipulation
- CPU information gathering with timer support
- Cryptographic primitives (SHA-256, RSA, etc.)
- Decompression primitives (zlib, lzss, lzvn, etc.)
- Helper code for ACPI reads and modifications
- Higher level abstractions for files, strings, UEFI variables
- Overflow checking arithmetics
- PE image loading with no UEFI Secure Boot conflict
- Plist configuration format parsing
- PNG image manipulation
- Text output and graphics output implementations
- XNU kernel driver injection and patch engine
Early history of the codebase could be found in AppleSupportPkg and PicoLib library set by The HermitCrabs Lab.
OcGuardLib
This library implements basic safety features recommended for the use within the project. It implements fast safe integral arithmetics mapping on compiler builtins, type alignment checking, and UBSan runtime, based on NetBSD implementation.
The use of UBSan runtime requires the use of Clang compiler and -fsanitize=undefined argument. Refer to
Clang documentation for more
details.
Credits
- The HermitCrabs Lab
- All projects providing third-party code (refer to file headers)
- AppleLife team and user-contributed resources
- Chameleon and Clover teams for hints and legacy
- al3xtjames
- Andrey1970AppleLife
- mhaeuser (ex Download-Fritz)
- Goldfish64
- MikeBeaton
- nms42
- PMheart
- savvamitrofanov
- usr-sse2
- vit9696
Discussion
Please refer to the following list of OpenCore discussion forums.