Skip to content

Commit 8044b94

Browse files
committed
cli: fix edge case in pyimg4 im4m/img4 info
Some IM4Ms contain null values in place of an actual value for the ECID/ApNonce/SepNonce, this adds in checks to confirm the IM4M contains the value before printing
1 parent 7cb9cbe commit 8044b94

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

pyimg4/__main__.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,14 @@ def im4m_info(input_: BinaryIO, verbose: bool) -> None:
6565
else:
6666
click.echo(f' Device Processor: {soc}')
6767

68-
click.echo(f' ECID (hex): {hex(im4m.ecid)}')
69-
click.echo(f' ApNonce (hex): {im4m.apnonce.hex()}')
70-
click.echo(f' SepNonce (hex): {im4m.sepnonce.hex()}')
68+
if im4m.ecid is not None:
69+
click.echo(f' ECID (hex): {hex(im4m.ecid)}')
70+
71+
if im4m.apnonce is not None:
72+
click.echo(f' ApNonce (hex): {im4m.apnonce.hex()}')
73+
74+
if im4m.sepnonce is not None:
75+
click.echo(f' SepNonce (hex): {im4m.sepnonce.hex()}')
7176

7277
if verbose:
7378
for p, prop in enumerate(im4m.properties):
@@ -944,9 +949,14 @@ def img4_info(input_: BinaryIO, verbose: bool) -> None:
944949
else:
945950
click.echo(f' Device Processor: {soc}')
946951

947-
click.echo(f' ECID (hex): {hex(img4.im4m.ecid)}')
948-
click.echo(f' ApNonce (hex): {img4.im4m.apnonce.hex()}')
949-
click.echo(f' SepNonce (hex): {img4.im4m.sepnonce.hex()}')
952+
if img4.im4m.ecid is not None:
953+
click.echo(f' ECID (hex): {hex(img4.im4m.ecid)}')
954+
955+
if img4.im4m.apnonce is not None:
956+
click.echo(f' ApNonce (hex): {img4.im4m.apnonce.hex()}')
957+
958+
if img4.im4m.sepnonce is not None:
959+
click.echo(f' SepNonce (hex): {img4.im4m.sepnonce.hex()}')
950960

951961
if verbose:
952962
for p, prop in enumerate(img4.im4m.properties):

0 commit comments

Comments
 (0)