Skip to content

Commit cc89f11

Browse files
authored
Merge pull request #259 from LedgerHQ/y333/fix_nbg_empty_pages
Test if CString is empty before calling C API
2 parents 1bc15fd + 786d983 commit cc89f11

File tree

5 files changed

+24
-12
lines changed

5 files changed

+24
-12
lines changed

.github/workflows/reusable_build_all_apps.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
fail-fast: false
7272
matrix:
7373
app-name: ["app-boilerplate-rust"]
74-
device: ["nanosp", "nanox", "stax", "flex"]
74+
device: ["nanos+", "nanox", "stax", "flex"]
7575
include: ${{ fromJSON(needs.retrieve-rust-apps.outputs.rust_apps) }}
7676
runs-on: ubuntu-latest
7777
container:
@@ -142,6 +142,6 @@ jobs:
142142
cargo +$RUST_NIGHTLY update include_gif
143143
cargo +$RUST_NIGHTLY update ledger_secure_sdk_sys
144144
cargo +$RUST_NIGHTLY update ledger_device_sdk
145-
device=$(echo ${{ matrix.device }} | sed 's/p/plus/')
145+
device=$(echo ${{ matrix.device }} | sed 's/+/plus/')
146146
echo "Build for "$device
147147
cargo ledger build $device

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.

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.5"
3+
version = "1.22.6"
44
authors = ["yhql", "yogh333", "agrojean-ledger", "kingofpayne"]
55
edition = "2021"
66
license.workspace = true

ledger_device_sdk/src/nbgl/nbgl_address_review.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ impl SyncNBGL for NbglAddressReview<'_> {}
1212
impl<'a> NbglAddressReview<'a> {
1313
pub fn new() -> NbglAddressReview<'a> {
1414
NbglAddressReview {
15-
verify_str: CString::new("").unwrap(),
15+
verify_str: CString::default(),
1616
glyph: None,
1717
}
1818
}
@@ -45,7 +45,10 @@ impl<'a> NbglAddressReview<'a> {
4545
address.as_ptr(),
4646
core::ptr::null(),
4747
&icon as *const nbgl_icon_details_t,
48-
self.verify_str.as_ptr(),
48+
match self.verify_str.is_empty() {
49+
true => core::ptr::null(),
50+
false => self.verify_str.as_ptr(),
51+
},
4952
core::ptr::null(),
5053
Some(choice_callback),
5154
);

ledger_device_sdk/src/nbgl/nbgl_review.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ impl SyncNBGL for NbglReview<'_> {}
1717
impl<'a> NbglReview<'a> {
1818
pub fn new() -> NbglReview<'a> {
1919
NbglReview {
20-
title: CString::new("").unwrap(),
21-
subtitle: CString::new("").unwrap(),
22-
finish_title: CString::new("").unwrap(),
20+
title: CString::default(),
21+
subtitle: CString::default(),
22+
finish_title: CString::default(),
2323
glyph: None,
2424
tx_type: TransactionType::Transaction,
2525
blind: false,
@@ -130,9 +130,18 @@ impl<'a> NbglReview<'a> {
130130
self.tx_type.to_c_type(false),
131131
&tag_value_list as *const nbgl_contentTagValueList_t,
132132
&icon as *const nbgl_icon_details_t,
133-
self.title.as_ptr() as *const c_char,
134-
self.subtitle.as_ptr() as *const c_char,
135-
self.finish_title.as_ptr() as *const c_char,
133+
match self.title.is_empty() {
134+
true => core::ptr::null(),
135+
false => self.title.as_ptr() as *const c_char,
136+
},
137+
match self.subtitle.is_empty() {
138+
true => core::ptr::null(),
139+
false => self.subtitle.as_ptr() as *const c_char,
140+
},
141+
match self.finish_title.is_empty() {
142+
true => core::ptr::null(),
143+
false => self.finish_title.as_ptr() as *const c_char,
144+
},
136145
Some(choice_callback),
137146
);
138147
}

0 commit comments

Comments
 (0)