Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
fix(api): Fix errors in send_trytes
Browse files Browse the repository at this point in the history
serialize/serialize.c: Return `SC_SERIALIZER_INVALID_REQ` if any element (trytes)
in the  requeting trytes list length not equal to NUM_TRYTES_SERIALIZED_TRANSACTION.

utils/pow.c: Exit pow loop if tx == NULL which may happen if the requesting trytes
is arbitrary tytes which means the transaction indext doesn't meet the real index.
  • Loading branch information
howjmay committed Jun 3, 2019
1 parent c7410f0 commit 688c5b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions accelerator/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ typedef enum {
SC_SERIALIZER_JSON_PARSE_UNICODE =
0x04 | SC_MODULE_SERIALIZER | SC_SEVERITY_FATAL,
/**< unicode value in JSON */
SC_SERIALIZER_INVALID_REQ = 0x05 | SC_MODULE_SERIALIZER | SC_SEVERITY_FATAL,
/**< invald request value in JSON */

// Cache module
SC_CACHE_NULL = 0x01 | SC_MODULE_CACHE | SC_SEVERITY_FATAL,
Expand Down
4 changes: 4 additions & 0 deletions serializer/serializer.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ static status_t ta_json_array_to_hash8019_array(cJSON const* const obj,
cJSON* current_obj = NULL;
cJSON_ArrayForEach(current_obj, json_item) {
if (current_obj->valuestring != NULL) {
if (strlen(current_obj->valuestring) !=
NUM_TRYTES_SERIALIZED_TRANSACTION) {
return SC_SERIALIZER_INVALID_REQ;
}
flex_trits_from_trytes(hash, NUM_TRITS_SERIALIZED_TRANSACTION,
(tryte_t const*)current_obj->valuestring,
NUM_TRYTES_SERIALIZED_TRANSACTION,
Expand Down
2 changes: 1 addition & 1 deletion utils/pow.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ status_t ta_pow(const bundle_transactions_t* bundle,
ctrunk = iota_flex_digest(tx_trits, NUM_TRITS_SERIALIZED_TRANSACTION);
tx = (iota_transaction_t*)utarray_prev(bundle, tx);
free(nonce);
} while (cur_idx != 0);
} while (cur_idx != 0 && tx != NULL);

done:
free(ctrunk);
Expand Down

0 comments on commit 688c5b4

Please sign in to comment.