mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 15:38:11 +00:00
src/apps/common: introduce limit for homescreen size
This commit is contained in:
parent
8cdec0652e
commit
0484f599fd
@ -4,6 +4,8 @@ from trezor import config
|
||||
from trezor.crypto import random
|
||||
from apps.common import cache
|
||||
|
||||
HOMESCREEN_MAXSIZE = 16384
|
||||
|
||||
_STORAGE_VERSION = b'\x01'
|
||||
|
||||
_APP = const(0x01) # app namespace
|
||||
@ -73,7 +75,8 @@ def load_settings(label: str=None, use_passphrase: bool=None, homescreen: bytes=
|
||||
config.set(_APP, _USE_PASSPHRASE, b'')
|
||||
if homescreen is not None:
|
||||
if homescreen[:8] == b'TOIf\x90\x00\x90\x00':
|
||||
config.set(_APP, _HOMESCREEN, homescreen, True) # public
|
||||
if len(homescreen) <= HOMESCREEN_MAXSIZE:
|
||||
config.set(_APP, _HOMESCREEN, homescreen, True) # public
|
||||
else:
|
||||
config.set(_APP, _HOMESCREEN, b'', True) # public
|
||||
|
||||
|
@ -11,6 +11,8 @@ async def apply_settings(ctx, msg):
|
||||
raise wire.FailureError(FailureType.ProcessError, 'No setting provided')
|
||||
|
||||
if msg.homescreen is not None:
|
||||
if len(msg.homescreen) > storage.HOMESCREEN_MAXSIZE:
|
||||
raise wire.FailureError(FailureType.DataError, 'Homescreen is too complex')
|
||||
await require_confirm(ctx, Text(
|
||||
'Change homescreen', ui.ICON_CONFIG,
|
||||
'Do you really want to', 'change homescreen?'),
|
||||
|
Loading…
Reference in New Issue
Block a user