Add NXDT_FILE_PROPERTIES_MAX_NAME_LENGTH validation
This commit is contained in:
parent
dd56ef95fe
commit
0848d43bc9
1 changed files with 7 additions and 0 deletions
|
@ -44,6 +44,7 @@ class NxdtUsbAbi1 {
|
|||
|
||||
private static final int NXDT_MAX_COMMAND_SIZE = 0x1000;
|
||||
private static final int NXDT_FILE_CHUNK_SIZE = 0x800000;
|
||||
private static final int NXDT_FILE_PROPERTIES_MAX_NAME_LENGTH = 0x300;
|
||||
|
||||
private static final byte ABI_VERSION = 1;
|
||||
private static final byte[] MAGIC_NXDT = { 0x4e, 0x58, 0x44, 0x54 };
|
||||
|
@ -183,6 +184,12 @@ class NxdtUsbAbi1 {
|
|||
final int fileNameLen = getLEint(message, 0x18);
|
||||
String filename = new String(message, 0x20, fileNameLen, StandardCharsets.UTF_8);
|
||||
|
||||
if (fileNameLen == 0 || fileNameLen > NXDT_FILE_PROPERTIES_MAX_NAME_LENGTH){
|
||||
writeUsb(USBSTATUS_MALFORMED_REQUEST);
|
||||
logPrinter.print("Invalid filename length!", EMsgType.FAIL);
|
||||
return;
|
||||
}
|
||||
|
||||
logPrinter.print("Write request for: '"+filename+"' ("+fileSize+" bytes)", EMsgType.INFO);
|
||||
// If RomFs related
|
||||
if (isRomFs(filename)) {
|
||||
|
|
Loading…
Reference in a new issue