IteratorUsage tests: Add some canary nulled space before begin.

Hardening against write-before-begin.
This commit is contained in:
hashlag
2026-02-04 23:31:14 +03:00
parent 5fd27cd7b5
commit 15d841893c
3 changed files with 43 additions and 37 deletions

View File

@@ -360,17 +360,18 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
Arc4Gen gen(key, key + std::size(key));
std::array<uint8_t, 20> out;
std::array<uint8_t, 23> out;
out.fill(0);
std::array<uint8_t, 20> expected =
std::array<uint8_t, 23> expected =
{
0x00, 0x00, 0x00,
0xb2, 0x39, 0x63, 0x05, 0xf0, 0x3d, 0xc0, 0x27,
0xcc, 0xc3, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00
};
gen.Generate(out.begin(), 11);
gen.Generate(out.begin() + 3, 11);
ASSERT_EQ(expected, out);
}
@@ -379,17 +380,18 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
uint8_t key[] = { 0x01, 0x02, 0x03, 0x04, 0x05 };
Arc4Gen gen(key, key + std::size(key));
std::array<uint8_t, 20> out;
std::array<uint8_t, 23> out;
out.fill(0);
std::array<uint8_t, 20> expected =
std::array<uint8_t, 23> expected =
{
0x00, 0x00, 0x00,
0xb2, 0x39, 0x63, 0x05, 0xf0, 0x3d, 0xc0, 0x27,
0xcc, 0xc3, 0x52, 0x4a, 0x0a, 0x11, 0x18, 0xa8,
0x69, 0x82, 0x00, 0x00
};
gen.Generate(out.begin(), 18);
gen.Generate(out.begin() + 3, 18);
ASSERT_EQ(expected, out);
}
@@ -404,7 +406,7 @@ TEST(Arc4GenTests, GenerateOutIteratorUsageTest)
std::array<uint8_t, 20> expected;
expected.fill(0);
gen.Generate(out.begin(), 0);
gen.Generate(out.begin() + 3, 0);
ASSERT_EQ(expected, out);
}