1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-26 09:45:37 +03:00

limit custom firmware file size to 1 MB

This commit is contained in:
cTn 2014-01-11 00:08:24 +01:00
parent dba4b0d6dd
commit ce495cd260

View file

@ -22,11 +22,16 @@ function tab_initialize_firmware_flasher() {
fileEntry.file(function(file) { fileEntry.file(function(file) {
var reader = new FileReader(); var reader = new FileReader();
reader.onerror = function (e) { reader.onprogress = function(e) {
console.error(e); if (e.total > 1048576) { // 1 MB
// dont allow reading files bigger then 1 MB
console.log('File limit (1 MB) exceeded, aborting');
reader.abort();
}
}; };
reader.onloadend = function(e) { reader.onloadend = function(e) {
if (e.total != 0 && e.total == e.loaded) {
console.log('File loaded'); console.log('File loaded');
intel_hex = e.target.result; intel_hex = e.target.result;
@ -43,6 +48,7 @@ function tab_initialize_firmware_flasher() {
STM32.GUI_status('<span style="color: red">HEX file appears to be corrupted</span>'); STM32.GUI_status('<span style="color: red">HEX file appears to be corrupted</span>');
} }
}); });
}
}; };
reader.readAsText(file); reader.readAsText(file);