@@ -282,6 +282,10 @@ async def read_devices(znp: ZNP) -> typing.Sequence[StoredDevice]:
282
282
t .AddrMgrUserType .Assoc | t .AddrMgrUserType .Security ,
283
283
t .AddrMgrUserType .Security ,
284
284
):
285
+ if not 0x0000 <= entry .nwkAddr <= 0xFFF7 :
286
+ LOGGER .warning ("Ignoring invalid address manager entry: %s" , entry )
287
+ continue
288
+
285
289
devices [entry .extAddr ] = StoredDevice (
286
290
ieee = entry .extAddr ,
287
291
nwk = entry .nwkAddr ,
@@ -290,6 +294,16 @@ async def read_devices(znp: ZNP) -> typing.Sequence[StoredDevice]:
290
294
raise ValueError (f"Unexpected entry type: { entry .type } " )
291
295
292
296
async for ieee , tx_ctr , rx_ctr , key in read_hashed_link_keys (znp , tclk_seed ):
297
+ if ieee not in devices :
298
+ LOGGER .warning (
299
+ "Skipping hashed link key %s (tx: %s, rx: %s) for unknown device %s" ,
300
+ ":" .join (f"{ b :02x} " for b in key ),
301
+ tx_ctr ,
302
+ rx_ctr ,
303
+ ieee ,
304
+ )
305
+ continue
306
+
293
307
devices [ieee ] = devices [ieee ].replace (
294
308
tx_counter = tx_ctr ,
295
309
rx_counter = rx_ctr ,
@@ -298,6 +312,16 @@ async def read_devices(znp: ZNP) -> typing.Sequence[StoredDevice]:
298
312
)
299
313
300
314
async for ieee , tx_ctr , rx_ctr , key in read_unhashed_link_keys (znp , addr_mgr ):
315
+ if ieee not in devices :
316
+ LOGGER .warning (
317
+ "Skipping unhashed link key %s (tx: %s, rx: %s) for unknown device %s" ,
318
+ ":" .join (f"{ b :02x} " for b in key ),
319
+ tx_ctr ,
320
+ rx_ctr ,
321
+ ieee ,
322
+ )
323
+ continue
324
+
301
325
devices [ieee ] = devices [ieee ].replace (
302
326
tx_counter = tx_ctr ,
303
327
rx_counter = rx_ctr ,
0 commit comments