1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +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,27 +22,33 @@ 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) {
console.log('File loaded'); if (e.total != 0 && e.total == e.loaded) {
console.log('File loaded');
intel_hex = e.target.result;
parse_hex(intel_hex, function(data) {
parsed_hex = data;
if (parsed_hex) { intel_hex = e.target.result;
STM32.GUI_status('<span style="color: green">Firmware loaded, ready for flashing</span>');
$('a.flash_firmware').removeClass('locked'); parse_hex(intel_hex, function(data) {
parsed_hex = data;
$('span.size').html(parsed_hex.bytes + ' bytes'); if (parsed_hex) {
} else { STM32.GUI_status('<span style="color: green">Firmware loaded, ready for flashing</span>');
STM32.GUI_status('<span style="color: red">HEX file appears to be corrupted</span>'); $('a.flash_firmware').removeClass('locked');
}
}); $('span.size').html(parsed_hex.bytes + ' bytes');
} else {
STM32.GUI_status('<span style="color: red">HEX file appears to be corrupted</span>');
}
});
}
}; };
reader.readAsText(file); reader.readAsText(file);