Skip to content

Commit

Permalink
Fix label length assignment bug. (#156)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihuanhuan authored Aug 21, 2024
1 parent b24ee6f commit 2480f55
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/storage/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
HOMESCREEN_PATH_MAXSIZE = const(128)
BLE_NAME_MAXLENGTH = const(16)
BLE_VERSION_MAXLENGTH = const(8)
PREVIOUS_LABEL_MAXLENGTH = const(13)

SE_1ST_ADDRESS = const(0x10 << 1)
SE_2ND_ADDRESS = const(0x11 << 1)
Expand Down Expand Up @@ -726,7 +727,10 @@ def get_label() -> str:
label = common.get(_NAMESPACE, _LABEL, True) # public
if label is None:
previous_label_len = common.get_val_len(_NAMESPACE, _LABEL_DEPRECATED, True)
if previous_label_len is not None and 0 < previous_label_len < 16:
if (
previous_label_len is not None
and 0 < previous_label_len < PREVIOUS_LABEL_MAXLENGTH
):
label = common.get(_NAMESPACE, _LABEL_DEPRECATED, True)
_LABEL_VALUE = label.decode() if label else utils.DEFAULT_LABEL
return _LABEL_VALUE
Expand Down

0 comments on commit 2480f55

Please sign in to comment.