Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Unified Diff: tests/test_opus_padding.c

Issue 28553003: Updating Opus to a pre-release of 1.1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/opus
Patch Set: Removing failing file Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/test_opus_encode.c ('k') | version.mk » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/test_opus_padding.c
diff --git a/tests/test_opus_padding.c b/tests/test_opus_padding.c
new file mode 100644
index 0000000000000000000000000000000000000000..c5efc292308cc932ec208a0719d23eb47c91be40
--- /dev/null
+++ b/tests/test_opus_padding.c
@@ -0,0 +1,67 @@
+/* Check for overflow in reading the padding length.
+ * Example by Jüri Aedla and Ralph Giles
+ * http://lists.xiph.org/pipermail/opus/2012-November/001834.html
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "opus.h"
+#include "test_opus_common.h"
+
+#define PACKETSIZE 16909318
+#define CHANNELS 2
+#define FRAMESIZE 5760
+
+int test_overflow(void)
+{
+ OpusDecoder *decoder;
+ int result;
+ int error;
+
+ unsigned char *in = malloc(PACKETSIZE);
+ opus_int16 *out = malloc(FRAMESIZE*CHANNELS*sizeof(*out));
+
+ fprintf(stderr, " Checking for padding overflow... ");
+ if (!in || !out) {
+ fprintf(stderr, "FAIL (out of memory)\n");
+ return -1;
+ }
+ in[0] = 0xff;
+ in[1] = 0x41;
+ memset(in + 2, 0xff, PACKETSIZE - 3);
+ in[PACKETSIZE-1] = 0x0b;
+
+ decoder = opus_decoder_create(48000, CHANNELS, &error);
+ result = opus_decode(decoder, in, PACKETSIZE, out, FRAMESIZE, 0);
+ opus_decoder_destroy(decoder);
+
+ free(in);
+ free(out);
+
+ if (result != OPUS_INVALID_PACKET) {
+ fprintf(stderr, "FAIL!\n");
+ test_failed();
+ }
+
+ fprintf(stderr, "OK.\n");
+
+ return 1;
+}
+
+int main(void)
+{
+ const char *oversion;
+ int tests = 0;;
+
+ iseed = 0;
+ oversion = opus_get_version_string();
+ if (!oversion) test_failed();
+ fprintf(stderr, "Testing %s padding.\n", oversion);
+
+ tests += test_overflow();
+
+ fprintf(stderr, "All padding tests passed.\n");
+
+ return 0;
+}
« no previous file with comments | « tests/test_opus_encode.c ('k') | version.mk » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698