1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

src/apps/common: introduce limit for homescreen size

This commit is contained in:
Pavol Rusnak 2018-03-08 23:45:17 +01:00
parent 8cdec0652e
commit 0484f599fd
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 6 additions and 1 deletions

View File

@ -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,6 +75,7 @@ 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':
if len(homescreen) <= HOMESCREEN_MAXSIZE:
config.set(_APP, _HOMESCREEN, homescreen, True) # public
else:
config.set(_APP, _HOMESCREEN, b'', True) # public

View File

@ -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?'),