Skip to content

Commit

Permalink
Fix buffer size in TestDecodeBase58Address ref #34
Browse files Browse the repository at this point in the history
  • Loading branch information
stdevAlDen committed Jun 17, 2019
1 parent cbcc513 commit e2a5b2d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/cgo/tests/check_cipher.address.common.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,13 @@ END_TEST

START_TEST(TestDecodeBase58Address)
{
GoString strAddr = {SKYCOIN_ADDRESS_VALID, 35};
GoString strAddr = {.p = SKYCOIN_ADDRESS_VALID, .n = 35};
cipher__Address addr;
GoUint32 err = SKY_cipher_DecodeBase58Address(strAddr, &addr);
ck_assert_int_eq(err, SKY_OK);

char tempStr[50];
int errorcode;
GoUint32 errorcode;

// preceding whitespace is invalid
strcpy(tempStr, " ");
Expand Down Expand Up @@ -229,9 +229,9 @@ START_TEST(TestDecodeBase58Address)
b.data = Cub.data;
b.len = Cub.len;

int len_b = b.len;
const GoInt len_b = b.len;
char bufferHead[1024];
GoString_ h = {bufferHead, 0};
GoString_ h = {bufferHead, sizeof(bufferHead)};
b.len = (GoInt)(len_b / 2);
errorcode = SKY_base58_Hex2Base58(b, &h);
ck_assert(errorcode == SKY_OK);
Expand All @@ -242,6 +242,7 @@ START_TEST(TestDecodeBase58Address)
errorcode = SKY_cipher_DecodeBase58Address(tmph, &addr);
ck_assert_msg(errorcode == SKY_ErrAddressInvalidLength, "Fail %X", errorcode);
b.len = len_b;
h.n = sizeof(bufferHead);
errorcode = SKY_base58_Hex2Base58(b, &h);
ck_assert(errorcode == SKY_OK);
tmph.n = h.n;
Expand Down

0 comments on commit e2a5b2d

Please sign in to comment.