File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -555,7 +555,7 @@ def _do_romfs_deploy(state, args):
555555 romfs_filename = args .path
556556
557557 # Read in or create the ROMFS filesystem image.
558- if romfs_filename . endswith ( ".romfs" ):
558+ if os . path . isfile ( romfs_filename ):
559559 with open (romfs_filename , "rb" ) as f :
560560 romfs = f .read ()
561561 else :
@@ -581,6 +581,12 @@ def _do_romfs_deploy(state, args):
581581 rom_size = transport .eval ("len(dev)" )
582582 print (f"ROMFS{ rom_id } partition has size { rom_size } bytes" )
583583
584+ # Check if ROMFS image is valid
585+ ROMFS_HEADER = b"\xd2 \xcd \x31 "
586+ if len (romfs ) < 4 or not romfs .startswith (ROMFS_HEADER ):
587+ print ("Invalid ROMFS image" )
588+ sys .exit (1 )
589+
584590 # Check if ROMFS filesystem image will fit in the target partition.
585591 if len (romfs ) > rom_size :
586592 print ("ROMFS image is too big for the target partition" )
You can’t perform that action at this time.
0 commit comments