forked from LedgerHQ/app-hedera
-
Notifications
You must be signed in to change notification settings - Fork 1
Fuzz test hedera_format_amount #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jakubretajczykBD
wants to merge
2
commits into
blockydevs:develop
Choose a base branch
from
jakubretajczykBD:test/fuzz-test-hedera-format-amount
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/1ea2fd93a856f4eba868a855307371bf9155c545
Binary file not shown.
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/29e24643a6328cb4ea893738b89c63b842ce24e7
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/3350e3f4b98a70ac012622f12b19f03edb099688
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/33a9ec1437ff27c8a33afb7266c659f80eecdb64
Binary file not shown.
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/3fdd6b611c43d851d86ba27b09cfcd0dffe0b847
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/419ccdb422d4cbdc95522e49874137439a905bd3
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/45c5dc55d8f328988f198d5b49ab603c82487694
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/45db28616f269c8f5c6c27a2e26cdff8a86005cd
Binary file not shown.
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/4a277da8619417c7666f4e90039083a4c7052d13
Binary file not shown.
1 change: 1 addition & 0 deletions
1
fuzzing/corpus/hedera_format_amount/52a719f9d01e6a1882f97bc011e52c80f807e955
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ˜ |
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/5df46b520e98fd320df253c3de2b6d773a13dd5f
Binary file not shown.
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/611076e0b00ec8ac376d8e8c956fef85014b5f13
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/61c655709afa77141c37568f29b9b6894f9ef091
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
fuzzing/corpus/hedera_format_amount/62399d6d1e18ce79ab91c1a3475f2b49be33500d
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
|
|
||
| ÿÿÿÿÿkÿ |
1 change: 1 addition & 0 deletions
1
fuzzing/corpus/hedera_format_amount/6448dcc065b65939aa646b6a9104eefdb3cf2e92
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ÿÿÿÿÿÿÿÿÿ |
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/699d813f549a03aad9c1c93588eb86310ad10848
Binary file not shown.
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/71aa908aff1548c8c6cdecf63545261584738a25
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/7c157bb9a75e088b023868dca7174b04b683b761
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/7de8afb88739af6d5d814e6c0749412b30bbf2aa
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/8aee5665b6c681e8ede2a9a736777fba7581b6f0
Binary file not shown.
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/97af31a2a1f06ef650b21ab5e3d62c0c2b7770db
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
fuzzing/corpus/hedera_format_amount/a1d83033b232221ab32f5ffe8c9775ecbb6c9cb8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ØØØØØØ | ||
| 1 |
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/ad82f98fc58b9a00ca9ce8bf3fcb81108769f9ce
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/b79efe44558fb3286f6fde16d7faa398bac7c37c
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/bf22e24b6819e76b39e8a458fde6ff453d8c11eb
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/c38bec1f1d89357a06ffe7f6559594e5ea31182c
Binary file not shown.
2 changes: 2 additions & 0 deletions
2
fuzzing/corpus/hedera_format_amount/dabe30a519cb3bf7788cd93aee70282a29d96ee7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ØØ | ||
| ØØØ1Ø |
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/e6c2f557ada3359a285ed34fc816958f8113396b
Binary file not shown.
Binary file added
BIN
+9 Bytes
fuzzing/corpus/hedera_format_amount/f42016a2b1457b1bf73aa97d7536f631237a5476
Binary file not shown.
Binary file added
BIN
+8 Bytes
fuzzing/corpus/hedera_format_amount/f55870793d86b146f367f0896d0366426b115089
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #include <stdint.h> | ||
| #include <stddef.h> | ||
| #include <string.h> | ||
|
|
||
| #include "hedera_format_amount.h" | ||
|
|
||
| int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { | ||
| if (!data || size == 0) return 0; | ||
|
|
||
| uint64_t amount = 0; | ||
| uint8_t decimals = 0; | ||
|
|
||
| if (size >= 8) memcpy(&amount, data, 8); | ||
| if (size >= 9) decimals = data[8]; | ||
|
|
||
| (void)hedera_format_amount(amount, decimals); | ||
| (void)hedera_format_amount(amount, (uint8_t)(decimals % 32)); | ||
|
|
||
| return 0; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #include <string.h> | ||
| #include "hedera_format_amount.h" | ||
|
|
||
| #define BUF_SIZE 32 | ||
|
|
||
| const char *hedera_format_amount(uint64_t amount, uint8_t decimals) { | ||
| static char buf[BUF_SIZE]; | ||
|
|
||
| memset(buf, 0, BUF_SIZE); | ||
|
|
||
| if (amount == 0) { | ||
| buf[0] = '0'; | ||
| buf[1] = '\0'; | ||
| return buf; | ||
| } | ||
|
|
||
| if (decimals >= 20) return buf; | ||
|
|
||
| int i = 0; | ||
|
|
||
| while (i < (BUF_SIZE - 1) && (amount > 0 || i < decimals)) { | ||
| int digit = amount % 10; | ||
| amount /= 10; | ||
|
|
||
| buf[i++] = '0' + digit; | ||
|
|
||
| if (i == decimals) { | ||
| buf[i++] = '.'; | ||
| } | ||
| } | ||
|
|
||
| if (buf[i - 1] == '.') { | ||
| buf[i++] = '0'; | ||
| } | ||
|
|
||
| int size = i; | ||
| int j = 0; | ||
| char tmp; | ||
|
|
||
| while (j < i) { | ||
| i -= 1; | ||
|
|
||
| tmp = buf[j]; | ||
| buf[j] = buf[i]; | ||
| buf[i] = tmp; | ||
|
|
||
| j += 1; | ||
| } | ||
|
|
||
| for (j = size - 1; j > 0; j--) { | ||
| if (buf[j] == '0') { | ||
| continue; | ||
| } else if (buf[j] == '.') { | ||
| break; | ||
| } else { | ||
| j += 1; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (j < size - 1) { | ||
| buf[j] = '\0'; | ||
| } | ||
|
|
||
| return buf; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #pragma once | ||
| #include <stdint.h> | ||
|
|
||
| const char *hedera_format_amount(uint64_t amount, uint8_t decimals); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
For loop variable changed in body Note