-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
in-place decode and regular decode return BAD_PAYLOAD if there are an…
…y non-terminal zero bytes in the payload (#44) * in-place decode and regular decode return BAD_PAYLOAD if there are any non-terminal zero bytes in the payload * actions v3, MP on win
- Loading branch information
1 parent
dbdc6e9
commit 9482051
Showing
5 changed files
with
31 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,16 +1,26 @@ | ||
#include "../cobs.h" | ||
#include "byte_vec.h" | ||
#include "doctest.h" | ||
|
||
#include <cstring> | ||
|
||
TEST_CASE("Decoding validation") { | ||
unsigned char enc[32], dec[32]; | ||
unsigned char dec[32]; | ||
unsigned dec_len; | ||
|
||
SUBCASE("Invalid payload") { | ||
// first byte jumps past end | ||
enc[0] = 3; | ||
enc[1] = 0; | ||
REQUIRE(cobs_decode(&enc, 2, dec, sizeof(enc), &dec_len) == COBS_RET_ERR_BAD_PAYLOAD); | ||
SUBCASE("Invalid payload: jump past end") { | ||
byte_vec_t enc{3, 0}; | ||
REQUIRE(cobs_decode(enc.data(), | ||
unsigned(enc.size()), | ||
dec, | ||
sizeof(dec), | ||
&dec_len) == COBS_RET_ERR_BAD_PAYLOAD); | ||
} | ||
|
||
SUBCASE("Invalid payload: jump over internal zeroes") { | ||
byte_vec_t enc{5, 1, 0, 0, 1, 0}; | ||
REQUIRE(cobs_decode(enc.data(), | ||
unsigned(enc.size()), | ||
dec, | ||
sizeof(dec), | ||
&dec_len) == COBS_RET_ERR_BAD_PAYLOAD); | ||
} | ||
} |
This file contains 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