Skip to content

Commit

Permalink
Revert "fuzzing!"
Browse files Browse the repository at this point in the history
This reverts commit 9313cf8.
  • Loading branch information
overcat committed Apr 21, 2024
1 parent a5c3807 commit 79d92b6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 45 deletions.
65 changes: 32 additions & 33 deletions fuzz/fuzz_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,37 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
return 0;
}

char detail_caption[DETAIL_CAPTION_MAX_LENGTH];
char detail_value[DETAIL_VALUE_MAX_LENGTH];

uint8_t signing_key[] = {0xe9, 0x33, 0x88, 0xbb, 0xfd, 0x2f, 0xbd, 0x11, 0x80, 0x6d, 0xd0,
0xbd, 0x59, 0xce, 0xa9, 0x7, 0x9e, 0x7c, 0xc7, 0xc, 0xe7, 0xb1,
0xe1, 0x54, 0xf1, 0x14, 0xcd, 0xfe, 0x4e, 0x46, 0x6e, 0xcd};

formatter_data_t fdata = {
.raw_data = data,
.raw_data_len = size,
.envelope = &envelope,
.caption = detail_caption,
.value = detail_value,
.signing_key = signing_key,
.caption_len = DETAIL_CAPTION_MAX_LENGTH,
.value_len = DETAIL_VALUE_MAX_LENGTH,
.display_sequence = true,
};

reset_formatter();

bool data_exists = true;
bool is_op_header = false;

while (true) {
if (!get_next_data(&fdata, true, &data_exists, &is_op_header)) {
return 0;
}

if (!data_exists) {
break;
}
}
// char detail_caption[DETAIL_CAPTION_MAX_LENGTH];
// char detail_value[DETAIL_VALUE_MAX_LENGTH];

// uint8_t signing_key[] = {0xe9, 0x33, 0x88, 0xbb, 0xfd, 0x2f, 0xbd, 0x11, 0x80, 0x6d, 0xd0,
// 0xbd, 0x59, 0xce, 0xa9, 0x7, 0x9e, 0x7c, 0xc7, 0xc, 0xe7, 0xb1,
// 0xe1, 0x54, 0xf1, 0x14, 0xcd, 0xfe, 0x4e, 0x46, 0x6e, 0xcd};

// formatter_data_t fdata = {
// .raw_data = data,
// .raw_data_len = size,
// .envelope = &envelope,
// .caption = detail_caption,
// .value = detail_value,
// .signing_key = signing_key,
// .caption_len = DETAIL_CAPTION_MAX_LENGTH,
// .value_len = DETAIL_VALUE_MAX_LENGTH,
// .display_sequence = true,
// };

// reset_formatter();

// while (true) {
// bool data_exists = true;
// bool is_op_header = false;
// if (!get_next_data(&fdata, true, &data_exists, &is_op_header)) {
// return 0;
// }

// if (!data_exists) {
// break;
// }
// }
return 0;
}
5 changes: 0 additions & 5 deletions libstellar/formatter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,6 @@ static const format_function_t formatters[] = {&format_create_account,
NULL, // &format_invoke_host_function,
&format_extend_footprint_ttl,
&format_restore_footprint};

static bool format_confirm_operation(formatter_data_t *fdata) {
if (fdata->envelope->tx.operations_count > 1) {
char op_caption[OPERATION_CAPTION_MAX_LENGTH];
Expand All @@ -1740,10 +1739,6 @@ static bool format_confirm_operation(formatter_data_t *fdata) {
FORMATTER_CHECK(push_to_formatter_stack(
((format_function_t) PIC(formatters[fdata->envelope->tx.op_details.type]))));
} else {
if (fdata->envelope->tx.op_details.type == OPERATION_INVOKE_HOST_FUNCTION) {
// TODO: add support!
return false;
}
((format_function_t) PIC(formatters[fdata->envelope->tx.op_details.type]))(fdata);
}
return true;
Expand Down
10 changes: 3 additions & 7 deletions libstellar/printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ uint16_t crc16(const uint8_t *input_str, int num_bytes) {
}

bool encode_key(const uint8_t *in, uint8_t version_byte, char *out, uint8_t out_len) {
if (in == NULL || out_len < 56 + 1) {
if (out_len < 56 + 1) {
return false;
}
uint8_t buffer[35] = {0};
uint8_t buffer[35];
buffer[0] = version_byte;
for (uint8_t i = 0; i < 32; i++) {
buffer[i + 1] = in[i];
Expand Down Expand Up @@ -102,17 +102,13 @@ bool encode_ed25519_signed_payload(const ed25519_signed_payload_t *signed_payloa
}

bool encode_muxed_account(const muxed_account_t *raw_muxed_account, char *out, size_t out_len) {
if (raw_muxed_account == NULL || raw_muxed_account->med25519.ed25519 == NULL ||
out_len < ENCODED_MUXED_ACCOUNT_KEY_LENGTH) {
return false;
}
if (raw_muxed_account->type == KEY_TYPE_ED25519) {
return encode_ed25519_public_key(raw_muxed_account->ed25519, out, out_len);
} else {
if (out_len < ENCODED_MUXED_ACCOUNT_KEY_LENGTH) {
return false;
}
uint8_t buffer[MUXED_ACCOUNT_MED_25519_SIZE] = {0};
uint8_t buffer[MUXED_ACCOUNT_MED_25519_SIZE];
buffer[0] = VERSION_BYTE_MUXED_ACCOUNT;
memcpy(buffer + 1, raw_muxed_account->med25519.ed25519, RAW_ED25519_PUBLIC_KEY_SIZE);
for (int i = 0; i < 8; i++) {
Expand Down

0 comments on commit 79d92b6

Please sign in to comment.