Skip to content

Conversation

andistorm
Copy link
Member

Describe your changes

Issue ticket number and link

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • I read the contribution documentation and made sure that my changes meet its requirements

Signed-off-by: Andreas Heinrich <[email protected]>
@andistorm andistorm marked this pull request as draft September 24, 2025 11:49
Signed-off-by: Andreas Heinrich <[email protected]>
Signed-off-by: Andreas Heinrich <[email protected]>
@andistorm andistorm changed the title tmp use branch chore(everest-ci): bump build-kit base image version to debian13 Sep 25, 2025

TEST(openssl, base64Decode) {
auto res = openssl::base64_decode(&iso_exi_a_hash_b64[0], sizeof(iso_exi_a_hash_b64));
auto res = openssl::base64_decode(iso_exi_a_hash_b64, std::strlen(iso_exi_a_hash_b64));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change needs to be reverted.
openssl::base64_decode() takes a constant pointer and a length - normally from a buffer of known size. It does not need to be null terminated.
And it if isn't null terminated then strlen() will not help.

ASSERT_EQ(res.size(), sizeof(iso_exi_a_hash));
EXPECT_EQ(std::memcmp(res.data(), &iso_exi_a_hash[0], res.size()), 0);
res = openssl::base64_decode(&iso_exi_sig_b64[0], sizeof(iso_exi_sig_b64));
res = openssl::base64_decode(iso_exi_sig_b64, std::strlen(iso_exi_sig_b64));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change needs to be reverted.
openssl::base64_decode() takes a constant pointer and a length - normally from a buffer of known size. It does not need to be null terminated.
And it if isn't null terminated then strlen() will not help.

std::size_t buffer_len = buffer.size();

EXPECT_TRUE(openssl::base64_decode(&iso_exi_a_hash_b64[0], sizeof(iso_exi_a_hash_b64), buffer.data(), buffer_len));
EXPECT_TRUE(openssl::base64_decode(iso_exi_a_hash_b64, std::strlen(iso_exi_a_hash_b64), buffer.data(), buffer_len));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above why strlen isn't a solution


TEST(openssl, base64DecodeNl) {
auto res = openssl::base64_decode(&iso_exi_a_hash_b64_nl[0], sizeof(iso_exi_a_hash_b64_nl));
auto res = openssl::base64_decode(iso_exi_a_hash_b64_nl, std::strlen(iso_exi_a_hash_b64_nl));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above why strlen isn't a solution

ASSERT_EQ(res.size(), sizeof(iso_exi_a_hash));
EXPECT_EQ(std::memcmp(res.data(), &iso_exi_a_hash[0], res.size()), 0);
res = openssl::base64_decode(&iso_exi_sig_b64_nl[0], sizeof(iso_exi_sig_b64_nl));
res = openssl::base64_decode(iso_exi_sig_b64_nl, std::strlen(iso_exi_sig_b64_nl));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above why strlen isn't a solution


EXPECT_TRUE(
openssl::base64_decode(&iso_exi_a_hash_b64_nl[0], sizeof(iso_exi_a_hash_b64_nl), buffer.data(), buffer_len));
openssl::base64_decode(iso_exi_a_hash_b64_nl, std::strlen(iso_exi_a_hash_b64_nl), buffer.data(), buffer_len));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above why strlen isn't a solution

Copy link
Member

@james-ctc james-ctc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strlen() doesn't solve a "problem" where a string isn't null terminated.

Signed-off-by: Andreas Heinrich <[email protected]>
Signed-off-by: Andreas Heinrich <[email protected]>
Signed-off-by: Andreas Heinrich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants