Skip to content
Snippets Groups Projects
Unverified Commit 5854a9f7 authored by Timothy B. Terriberry's avatar Timothy B. Terriberry
Browse files

Improve extension generator buffer too small test.

Test multiple buffer lengths and ensure we do not write past the
 end of the provided buffer.
parent 2ad86699
No related branches found
No related tags found
No related merge requests found
......@@ -149,8 +149,24 @@ void test_extensions_generate_fail(void)
unsigned char packet[100];
/* buffer too small */
result = opus_packet_extensions_generate(packet, 4, ext, 4, 1);
expect_true(result == OPUS_BUFFER_TOO_SMALL, "expected OPUS_BUFFER_TOO_SMALL");
{
opus_int32 len;
/* this failure can occur at lots of points, so iterate to check as many
as possible */
for (len=0;len<23;len++)
{
size_t i;
for (i=len;i<sizeof(packet);i++) packet[i] = 0xFE;
result = opus_packet_extensions_generate(packet, len, ext, 4, 1);
expect_true(result == OPUS_BUFFER_TOO_SMALL,
"expected OPUS_BUFFER_TOO_SMALL");
for (i=len;i<sizeof(packet);i++)
{
expect_true(packet[i] == 0xFE,
"expected 0xFE padding to be undisturbed");
}
}
}
/* invalid id */
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment