Skip to content

Commit

Permalink
Fix prefix clashing bug and adjust code style (reported by @behrang)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skydev0h committed Feb 23, 2024
1 parent 8661ce2 commit 4458be0
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions contracts/wallet_v5.fc
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ cell verify_actions(cell c5) inline {
() dispatch_complex_request(slice cs) impure inline_ref {

;; Recurse into extended actions until we reach standard actions
while (cs~load_uint(1)) {
var is_add_ext = cs~check_and_remove_add_extension_prefix();
var is_del_ext = cs~check_and_remove_remove_extension_prefix();
while (cs~load_int(1)) {
var is_add_ext? = cs~check_and_remove_add_extension_prefix();
var is_del_ext? = is_add_ext? ? 0 : cs~check_and_remove_remove_extension_prefix();
;; Add/remove extensions
if ((is_add_ext) | (is_del_ext)) {
if (is_add_ext? | is_del_ext?) {
(int wc, int hash) = parse_std_addr(cs~load_msg_addr());
int packed_addr = pack_address((wc, hash) );

Expand All @@ -85,7 +85,7 @@ cell verify_actions(cell c5) inline {
var extensions = ds.preload_dict();

;; Add extension
if (is_add_ext) {
if (is_add_ext?) {
(extensions, int success?) = extensions.udict_add_builder?(256, packed_addr, begin_cell().store_int(wc,8));
throw_unless(39, success?);
} else
Expand All @@ -103,11 +103,11 @@ cell verify_actions(cell c5) inline {
.end_cell());
}
elseif (cs~check_and_remove_set_signature_auth_allowed_prefix()) {
var allow = cs~load_uint(1);
var allow? = cs~load_int(1);
var ds = get_data().begin_parse();
var stored_seqno = ds~load_int(size::stored_seqno);
var immutable_tail = ds; ;; stored_subwallet ~ public_key ~ extensions
if (allow) {
if (allow?) {
;; allow
throw_unless(43, stored_seqno < 0);
;; Can't be disallowed with 0 because disallowing increments seqno
Expand Down Expand Up @@ -289,10 +289,10 @@ cell verify_actions(cell c5) inline {
;; - 0x6578746E "extn" authenticated by extension
;; - 0x73696E74 "sint" internal message authenticated by signature

(body, int is_extn) = check_and_remove_extn_prefix(body); ;; 0x6578746E ("extn")
(body, int is_extn?) = check_and_remove_extn_prefix(body); ;; 0x6578746E ("extn")

;; IFJMPREF because unconditionally returns inside
if (is_extn) { ;; "extn" authenticated by extension
if (is_extn?) { ;; "extn" authenticated by extension

;; Authenticate extension by its address.
int packed_sender_addr = pack_address(parse_std_addr(full_msg_slice~load_msg_addr())); ;; no PLDMSGADDR exists
Expand All @@ -312,8 +312,8 @@ cell verify_actions(cell c5) inline {
}

slice full_body = body;
(_, int is_sint) = check_and_remove_sint_prefix(body); ;; 0x73696E74 ("sint") - sign internal
return_unless(is_sint);
(_, int is_sint?) = check_and_remove_sint_prefix(body); ;; 0x73696E74 ("sint") - sign internal
return_unless(is_sint?);

;; Process the rest of the slice just like the signed request.
process_signed_request_from_internal_message(full_body);
Expand Down

0 comments on commit 4458be0

Please sign in to comment.