Skip to content

Commit d312369

Browse files
authored
Merge pull request #263 from LedgerHQ/y333/fix_nbgl_issues
Fix NBGL object issues when null strings are provided
2 parents 2679ffa + 86e46f3 commit d312369

File tree

6 files changed

+44
-48
lines changed

6 files changed

+44
-48
lines changed

.github/workflows/get_rust_apps.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
# Excluded Rust apps
1212
# app-kadena-legacy: has been replaced by app-kadena
1313
# app-pocket: does not build (Obsidians' Alamgu issue)
14-
# app-age: not maintained anymore
15-
excluded_apps = ["app-kadena-legacy", "app-pocket", "app-age"]
14+
excluded_apps = ["app-kadena-legacy", "app-pocket"]
1615

1716
# Retrieve all public apps on LedgerHQ GitHub organization
1817
token = sys.argv[1]

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
| Crate | Description | Latest Release |
88
| ------------------------------------------------ | --------------------------------------------------------------- | -------------- |
9-
| [cargo-ledger](./cargo-ledger) | Cargo extension required to build Ledger applications | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fcargo-ledger%2FCargo.toml&query=%24.package.version&label=version) |
109
| [ledger_device_sdk](./ledger_device_sdk) | Rust SDK | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_device_sdk%2FCargo.toml&query=%24.package.version&label=version) |
1110
| [ledger_secure_sdk_sys](./ledger_secure_sdk_sys) | [C SDK](https://github.com/LedgerHQ/ledger-secure-sdk) bindings | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Fledger_secure_sdk_sys%2FCargo.toml&query=%24.package.version&label=version) |
1211
| [include_gif](./include_gif) | Procedural macro to integrate logo in the UI/UX | ![Dynamic TOML Badge](https://img.shields.io/badge/dynamic/toml?url=https%3A%2F%2Fraw.githubusercontent.com%2FLedgerHQ%2Fledger-device-rust-sdk%2Frefs%2Fheads%2Fmaster%2Finclude_gif%2FCargo.toml&query=%24.package.version&label=version) |

ledger_device_sdk/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ledger_device_sdk"
3-
version = "1.22.8"
3+
version = "1.22.9"
44
authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"]
55
edition = "2021"
66
license.workspace = true

ledger_device_sdk/src/nbgl/nbgl_choice.rs

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,5 @@
11
use super::*;
22

3-
const WARNING_64PX_BITMAP: [u8; 359] = [
4-
0x40, 0x00, 0x40, 0x00, 0x21, 0x5f, 0x01, 0x00, 0x5d, 0x01, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00,
5-
0x00, 0x00, 0x02, 0xff, 0x85, 0xd5, 0x31, 0x4e, 0xc3, 0x40, 0x10, 0x05, 0xd0, 0x8d, 0x85, 0x08,
6-
0x4a, 0x45, 0x49, 0x91, 0xc2, 0x25, 0xb2, 0x52, 0xe4, 0x08, 0x39, 0x40, 0xc4, 0x19, 0x72, 0x82,
7-
0x5c, 0x81, 0x84, 0x03, 0x80, 0xb8, 0x41, 0xc4, 0x05, 0x72, 0x04, 0x0a, 0xd2, 0xe7, 0x08, 0x69,
8-
0x02, 0xa2, 0x0b, 0xa5, 0x13, 0xa1, 0x1d, 0xec, 0x99, 0x5d, 0xb3, 0xf6, 0xee, 0x1f, 0x6f, 0xfb,
9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xeb, 0x16, 0x44, 0xf9, 0xcc, 0xde, 0xa1, 0xbb, 0x00, 0x1f, 0xa0, 0xd3, 0x39, 0xef, 0xb4,
21-
0x4f, 0xb7, 0xbf, 0xbe, 0xf5, 0xfe, 0x72, 0xed, 0x1b, 0x14, 0xa4, 0xfb, 0x7b, 0x78, 0x82, 0x2e,
22-
0x05, 0xf7, 0xd8, 0xe9, 0x33, 0x18, 0x3f, 0xc9, 0xf9, 0xf4, 0xa1, 0xcf, 0x27, 0x97, 0x97, 0x02,
23-
0xbb, 0x14, 0x4c, 0xb0, 0x4b, 0xc1, 0x03, 0x76, 0xf2, 0x89, 0x43, 0x6e, 0x57, 0xfa, 0x7c, 0xf7,
24-
0x89, 0xdb, 0xe8, 0xfb, 0xc5, 0x4c, 0x95, 0xfd, 0xb4, 0x50, 0xf7, 0x93, 0x5f, 0x60, 0x23, 0x65,
25-
0x3f, 0xe6, 0xba, 0x73, 0xa0, 0xc6, 0x3d, 0xfb, 0x99, 0xf4, 0x05, 0x5e, 0xcd, 0xcb, 0x3f, 0xe4,
26-
0x2a, 0x7b, 0x24, 0x00, 0x08, 0x00, 0x00,
27-
];
28-
293
/// A wrapper around the asynchronous NBGL nbgl_useCaseChoice C API binding.
304
/// Draws a generic choice page, described in a centered info (with configurable icon),
315
/// thanks to a button and a footer at the bottom of the page.
@@ -57,13 +31,7 @@ impl<'a> NbglChoice<'a> {
5731
unsafe {
5832
let icon: nbgl_icon_details_t = match self.glyph {
5933
Some(g) => g.into(),
60-
None => nbgl_icon_details_t {
61-
width: 64,
62-
height: 64,
63-
bpp: NBGL_BPP_4,
64-
isFile: true,
65-
bitmap: &WARNING_64PX_BITMAP as *const u8,
66-
},
34+
None => nbgl_icon_details_t::default(),
6735
};
6836
let message = CString::new(message).unwrap();
6937
let sub_message = CString::new(sub_message).unwrap();
@@ -73,10 +41,22 @@ impl<'a> NbglChoice<'a> {
7341
self.ux_sync_init();
7442
nbgl_useCaseChoice(
7543
&icon as *const nbgl_icon_details_t,
76-
message.as_ptr() as *const c_char,
77-
sub_message.as_ptr() as *const c_char,
78-
confirm_text.as_ptr() as *const c_char,
79-
cancel_text.as_ptr() as *const c_char,
44+
match message.is_empty() {
45+
true => core::ptr::null(),
46+
false => message.as_ptr() as *const c_char,
47+
},
48+
match sub_message.is_empty() {
49+
true => core::ptr::null(),
50+
false => sub_message.as_ptr() as *const c_char,
51+
},
52+
match confirm_text.is_empty() {
53+
true => core::ptr::null(),
54+
false => confirm_text.as_ptr() as *const c_char,
55+
},
56+
match cancel_text.is_empty() {
57+
true => core::ptr::null(),
58+
false => cancel_text.as_ptr() as *const c_char,
59+
},
8060
Some(choice_callback),
8161
);
8262
let sync_ret = self.ux_sync_wait(false);

ledger_device_sdk/src/nbgl/nbgl_review.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,18 @@ impl<'a> NbglReview<'a> {
107107
self.tx_type.to_c_type(false),
108108
&tag_value_list as *const nbgl_contentTagValueList_t,
109109
&icon as *const nbgl_icon_details_t,
110-
self.title.as_ptr() as *const c_char,
111-
self.subtitle.as_ptr() as *const c_char,
112-
self.finish_title.as_ptr() as *const c_char,
110+
match self.title.is_empty() {
111+
true => core::ptr::null(),
112+
false => self.title.as_ptr() as *const c_char,
113+
},
114+
match self.subtitle.is_empty() {
115+
true => core::ptr::null(),
116+
false => self.subtitle.as_ptr() as *const c_char,
117+
},
118+
match self.finish_title.is_empty() {
119+
true => core::ptr::null(),
120+
false => self.finish_title.as_ptr() as *const c_char,
121+
},
113122
core::ptr::null(),
114123
Some(choice_callback),
115124
);
@@ -120,9 +129,18 @@ impl<'a> NbglReview<'a> {
120129
self.tx_type.to_c_type(false),
121130
&tag_value_list as *const nbgl_contentTagValueList_t,
122131
&icon as *const nbgl_icon_details_t,
123-
self.title.as_ptr() as *const c_char,
124-
self.subtitle.as_ptr() as *const c_char,
125-
self.finish_title.as_ptr() as *const c_char,
132+
match self.title.is_empty() {
133+
true => core::ptr::null(),
134+
false => self.title.as_ptr() as *const c_char,
135+
},
136+
match self.subtitle.is_empty() {
137+
true => core::ptr::null(),
138+
false => self.subtitle.as_ptr() as *const c_char,
139+
},
140+
match self.finish_title.is_empty() {
141+
true => core::ptr::null(),
142+
false => self.finish_title.as_ptr() as *const c_char,
143+
},
126144
Some(choice_callback),
127145
);
128146
} else {

0 commit comments

Comments
 (0)