cybersecurity · beginner · ~15 min · safe pentest lab
Restore the overwritten first byte.
Restore the filename byte that FAT overwrites on deletion, substituting a guessed character only when the entry is actually deleted.
Implement unsigned char recover_first(unsigned char first, unsigned char hint) that returns hint when the entry is deleted (first == 0xE5), and otherwise returns first unchanged.
first: the entry's current first byte.hint: the character to substitute when the entry is deleted.Returns the recovered first byte: hint if first == 0xE5, else first.
recover_first(0xE5, 'R') -> 'R' (deleted: use the hint)
recover_first('A', 'R') -> 'A' (live: keep it)
first == 0xE5; any other value is returned as-is.The entry's first byte first and a replacement character hint.
hint if first == 0xE5; otherwise first unchanged.
Substitute only when first == 0xE5.
unsigned char recover_first(unsigned char first, unsigned char hint) {
/* TODO */
return first;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.