File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
55and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
66
7+ ## [ Unreleased]
8+ ### Added
9+ - Size check when restoring firmware via USB/DFU.
10+
711## [ 1.0.0-alpha.3] - 2021-04-09
812### Changed
913- Print BLE download progress after chunk is complete instead of before.
Original file line number Diff line number Diff line change 11# SPDX-License-Identifier: MIT
2- # Copyright (c) 2019-2020 The Pybricks Authors
2+ # Copyright (c) 2019-2021 The Pybricks Authors
33
44import errno
55import os
@@ -93,6 +93,13 @@ def restore_dfu(file: BinaryIO) -> None:
9393 Args:
9494 file: the file that contains the firmware data
9595 """
96+ file .seek (0 , os .SEEK_END )
97+ size = file .tell ()
98+ file .seek (0 , os .SEEK_SET )
99+
100+ if size < 512 :
101+ raise ValueError ("File is too small to be a valid firmware file" )
102+
96103 try :
97104 # TODO: implement this using pydfu
98105 raise NoBackendError
You can’t perform that action at this time.
0 commit comments