Disallow negative size values

This commit is contained in:
KernelDeimos 2024-05-21 18:46:34 -04:00
parent 90463a0732
commit 1f6a2093fb
2 changed files with 9 additions and 1 deletions

View File

@ -220,6 +220,10 @@ module.exports = class APIError {
status: 400, status: 400,
message: 'Missing fileinfo entry or BLOB for operation.', message: 'Missing fileinfo entry or BLOB for operation.',
}, },
'invalid_file_metadata': {
status: 400,
message: 'Invalid file metadata.',
},
// Open // Open
'no_suitable_app': { 'no_suitable_app': {

View File

@ -192,7 +192,11 @@ module.exports = eggspress('/batch', {
} }
if ( fieldname === 'fileinfo' ) { if ( fieldname === 'fileinfo' ) {
fileinfos.push(JSON.parse(value)); const fileinfo = JSON.parse(value);
if ( fileinfo.size < 0 ) {
throw APIError.create('invalid_file_metadata');
}
fileinfos.push(fileinfo);
return; return;
} }