2
0
mirror of https://git.missingno.dev/kolibrios-nvme-driver/ synced 2024-12-22 13:58:47 +01:00

fix: add null terminator to IDENTC ASCII strings

This prevents garbage and redundant values from being printed to the
debug log.
This commit is contained in:
Abdur-Rahman Mansoor 2024-08-02 13:16:43 -04:00
parent 0f140a9c90
commit c9d58c1ec7

View File

@ -804,14 +804,22 @@ proc nvme_init stdcall, pci:dword
mov eax, dword [edi + IDENTC.nn] mov eax, dword [edi + IDENTC.nn]
mov dword [esi + pcidev.nn], eax mov dword [esi + pcidev.nn], eax
DEBUGF DBG_INFO, "nvme%u: Namespace Count: %u\n", [esi + pcidev.num], eax DEBUGF DBG_INFO, "nvme%u: Namespace Count: %u\n", [esi + pcidev.num], eax
; Note that the specification only allows ASCII strings that contain code
; values between 0x20 (' ') and 0x7E ('~'). Strings are left justified and
; padded with spaces (at least according to the 1.4.0 spec) which means there
; is no null terminator anywhere. To prevent garbage or repeated values from
; being printed to the debug log, I have inserted a 0 byte at the end of each
; string.
lea ebx, byte [edi + IDENTC.sn] lea ebx, byte [edi + IDENTC.sn]
lea eax, byte [esi + pcidev.serial] mov byte [ebx + 19], 0
stdcall memcpyd, eax, ebx, 20 / 4 DEBUGF DBG_INFO, "nvme%u: Serial Number: %s\n", [esi + pcidev.num], ebx
DEBUGF DBG_INFO, "nvme%u: Serial Number: %s\n", [esi + pcidev.num], eax
add ebx, 20 add ebx, 20
lea eax, byte [esi + pcidev.model] mov byte [ebx + 39], 0
stdcall memcpyd, eax, ebx, 40 / 4 DEBUGF DBG_INFO, "nvme%u: Model Number: %s\n", [esi + pcidev.num], ebx
DEBUGF DBG_INFO, "nvme%u: Model: %s\n", [esi + pcidev.num], eax add ebx, 40
mov byte [ebx + 7], 0
DEBUGF DBG_INFO, "nvme%u: Firmware Revision: %s\n", [esi + pcidev.num], ebx
mov edx, dword [esi + pcidev.version] mov edx, dword [esi + pcidev.version]
cmp edx, VS140 cmp edx, VS140