Skip to content

Commit 82c5e11

Browse files
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 4f4e34c commit 82c5e11

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/sdcard/sdcard.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ static bool read_config_file(void) {
154154
return false;
155155
}
156156

157-
TCHAR buf[6] = {0}; // Config file should have a magic header of 5 bytes
157+
TCHAR buf[6] = {0}; // 5-byte magic + null terminator
158158
UINT bytes_read = 0;
159159
if (f_read(&file, buf, sizeof buf - 1, &bytes_read) != FR_OK
160160
|| bytes_read != sizeof buf - 1) {
@@ -163,7 +163,8 @@ static bool read_config_file(void) {
163163
}
164164
f_close(&file);
165165

166-
return true;
166+
// Magic header must be exactly "PSLAB".
167+
return (buf[0] == 'P' && buf[1] == 'S' && buf[2] == 'L' && buf[3] == 'A' && buf[4] == 'B');
167168
}
168169

169170
response_t SDCARD_standalone_check(void) {

0 commit comments

Comments
 (0)