Skip to content

Commit

Permalink
Merge pull request #422 from LedgerHQ/fix/ocr_null_deref
Browse files Browse the repository at this point in the history
fix: do not parse fonts if symbol not present
  • Loading branch information
xchapron-ledger authored Sep 28, 2023
2 parents 6a34680 + 6f42e28 commit 73c3b0a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.3.1] - 2023-09-28

### Fixed
- OCR: Prevent null dereference when expected font is not in ELF file

## [0.3.0] - 2023-09-11

### Added
Expand Down
2 changes: 2 additions & 0 deletions speculos/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def get_elf_infos(app_path):
fonts_addr = bagl_fonts_symbol[0]['st_value']
fonts_size = bagl_fonts_symbol[0]['st_size']
logger.info(f"Found C_bagl_fonts at 0x{fonts_addr:X} ({fonts_size} bytes)\n")
else:
logger.info("Disabling OCR.")

supp_ram = elf.get_section_by_name('.rfbss')
ram_addr, ram_size = (supp_ram['sh_addr'], supp_ram['sh_size']) if supp_ram is not None else (0, 0)
Expand Down
6 changes: 4 additions & 2 deletions src/launcher.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,8 +541,10 @@ static int run_app(char *name, unsigned long *parameters)
app = get_current_app();

// Parse fonts and build bitmap -> character table
parse_fonts(memory.code, app->elf.text_load_addr, app->elf.fonts_addr,
app->elf.fonts_size);
if ((app->elf.fonts_addr != 0) || (hw_model == MODEL_STAX)) {
parse_fonts(memory.code, app->elf.text_load_addr, app->elf.fonts_addr,
app->elf.fonts_size);
}

/* thumb mode */
f = (void *)((unsigned long)p | 1);
Expand Down

0 comments on commit 73c3b0a

Please sign in to comment.