|
|
101986 |
diff --git a/Brewfile b/Brewfile
|
|
|
101986 |
new file mode 100644
|
|
|
101986 |
index 0000000..af81e5b
|
|
|
101986 |
--- /dev/null
|
|
|
101986 |
+++ b/Brewfile
|
|
|
101986 |
@@ -0,0 +1,3 @@
|
|
|
101986 |
+brew 'doxygen'
|
|
|
101986 |
+brew 'libogg'
|
|
|
101986 |
+brew 'xz'
|
|
|
101986 |
diff --git a/Makefile.am b/Makefile.am
|
|
|
101986 |
index c35131a..3feaf72 100644
|
|
|
101986 |
--- a/Makefile.am
|
|
|
101986 |
+++ b/Makefile.am
|
|
|
101986 |
@@ -26,7 +26,7 @@ EXTRA_DIST = \
|
|
|
101986 |
vorbisenc-uninstalled.pc.in \
|
|
|
101986 |
vorbisfile-uninstalled.pc.in \
|
|
|
101986 |
symbian \
|
|
|
101986 |
- macosx win32
|
|
|
101986 |
+ macosx win32 CMakeLists.txt
|
|
|
101986 |
|
|
|
101986 |
|
|
|
101986 |
DISTCHECK_CONFIGURE_FLAGS = --enable-docs
|
|
|
101986 |
diff --git a/contrib/oss-fuzz/build.sh b/contrib/oss-fuzz/build.sh
|
|
|
101986 |
new file mode 100755
|
|
|
101986 |
index 0000000..29e7f38
|
|
|
101986 |
--- /dev/null
|
|
|
101986 |
+++ b/contrib/oss-fuzz/build.sh
|
|
|
101986 |
@@ -0,0 +1,23 @@
|
|
|
101986 |
+#!/bin/bash -eu
|
|
|
101986 |
+
|
|
|
101986 |
+pushd $SRC
|
|
|
101986 |
+mv people.xiph.org/*.ogg decode_corpus/
|
|
|
101986 |
+zip -r "$OUT/decode_fuzzer_seed_corpus.zip" decode_corpus/
|
|
|
101986 |
+popd
|
|
|
101986 |
+
|
|
|
101986 |
+pushd $SRC/ogg
|
|
|
101986 |
+./autogen.sh
|
|
|
101986 |
+./configure --prefix="$WORK" --enable-static --disable-shared --disable-crc
|
|
|
101986 |
+make clean
|
|
|
101986 |
+make -j$(nproc)
|
|
|
101986 |
+make install
|
|
|
101986 |
+popd
|
|
|
101986 |
+
|
|
|
101986 |
+
|
|
|
101986 |
+./autogen.sh
|
|
|
101986 |
+./configure --prefix="$WORK" --enable-static --disable-shared
|
|
|
101986 |
+make clean
|
|
|
101986 |
+make -j$(nproc)
|
|
|
101986 |
+make install
|
|
|
101986 |
+
|
|
|
101986 |
+$CXX $CXXFLAGS $SRC/vorbis/contrib/oss-fuzz/decode_fuzzer.cc -o $OUT/decode_fuzzer -L"$WORK/lib" -I"$WORK/include" -lFuzzingEngine -lvorbisfile -lvorbis -logg
|
|
|
101986 |
diff --git a/contrib/oss-fuzz/decode_fuzzer.cc b/contrib/oss-fuzz/decode_fuzzer.cc
|
|
|
101986 |
new file mode 100644
|
|
|
101986 |
index 0000000..b8840c1
|
|
|
101986 |
--- /dev/null
|
|
|
101986 |
+++ b/contrib/oss-fuzz/decode_fuzzer.cc
|
|
|
101986 |
@@ -0,0 +1,48 @@
|
|
|
101986 |
+#include <stdio.h>
|
|
|
101986 |
+#include <string.h>
|
|
|
101986 |
+#include <cstdint>
|
|
|
101986 |
+#include <vorbis/vorbisfile.h>
|
|
|
101986 |
+
|
|
|
101986 |
+struct vorbis_data {
|
|
|
101986 |
+ const uint8_t *current;
|
|
|
101986 |
+ const uint8_t *data;
|
|
|
101986 |
+ size_t size;
|
|
|
101986 |
+};
|
|
|
101986 |
+
|
|
|
101986 |
+size_t read_func(void *ptr, size_t size1, size_t size2, void *datasource) {
|
|
|
101986 |
+ vorbis_data* vd = (vorbis_data *)(datasource);
|
|
|
101986 |
+ size_t len = size1 * size2;
|
|
|
101986 |
+ if (vd->current + len > vd->data + vd->size) {
|
|
|
101986 |
+ len = vd->data + vd->size - vd->current;
|
|
|
101986 |
+ }
|
|
|
101986 |
+ memcpy(ptr, vd->current, len);
|
|
|
101986 |
+ vd->current += len;
|
|
|
101986 |
+ return len;
|
|
|
101986 |
+}
|
|
|
101986 |
+
|
|
|
101986 |
+
|
|
|
101986 |
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
|
|
101986 |
+ ov_callbacks memory_callbacks = {0};
|
|
|
101986 |
+ memory_callbacks.read_func = read_func;
|
|
|
101986 |
+ vorbis_data data_st;
|
|
|
101986 |
+ data_st.size = Size;
|
|
|
101986 |
+ data_st.current = Data;
|
|
|
101986 |
+ data_st.data = Data;
|
|
|
101986 |
+ OggVorbis_File vf;
|
|
|
101986 |
+ int result = ov_open_callbacks(&data_st, &vf, NULL, 0, memory_callbacks);
|
|
|
101986 |
+ if (result < 0) {
|
|
|
101986 |
+ return 0;
|
|
|
101986 |
+ }
|
|
|
101986 |
+ int current_section = 0;
|
|
|
101986 |
+ int eof = 0;
|
|
|
101986 |
+ char buf[4096];
|
|
|
101986 |
+ int read_result;
|
|
|
101986 |
+ while (!eof) {
|
|
|
101986 |
+ read_result = ov_read(&vf, buf, sizeof(buf), 0, 2, 1, ¤t_section);
|
|
|
101986 |
+ if (read_result != OV_HOLE && read_result <= 0) {
|
|
|
101986 |
+ eof = 1;
|
|
|
101986 |
+ }
|
|
|
101986 |
+ }
|
|
|
101986 |
+ ov_clear(&vf);
|
|
|
101986 |
+ return 0;
|
|
|
101986 |
+}
|
|
|
101986 |
diff --git a/lib/Makefile.am b/lib/Makefile.am
|
|
|
101986 |
index cd5afdf..e22895e 100644
|
|
|
101986 |
--- a/lib/Makefile.am
|
|
|
101986 |
+++ b/lib/Makefile.am
|
|
|
101986 |
@@ -35,7 +35,7 @@ psytune_SOURCES = psytune.c
|
|
|
101986 |
psytune_LDFLAGS = -static
|
|
|
101986 |
psytune_LDADD = libvorbis.la
|
|
|
101986 |
|
|
|
101986 |
-EXTRA_DIST = lookups.pl
|
|
|
101986 |
+EXTRA_DIST = lookups.pl CMakeLists.txt
|
|
|
101986 |
|
|
|
101986 |
# build and run the self tests on 'make check'
|
|
|
101986 |
|
|
|
101986 |
diff --git a/lib/info.c b/lib/info.c
|
|
|
101986 |
index 3fbb7c7..23efa25 100644
|
|
|
101986 |
--- a/lib/info.c
|
|
|
101986 |
+++ b/lib/info.c
|
|
|
101986 |
@@ -203,6 +203,7 @@ void vorbis_info_clear(vorbis_info *vi){
|
|
|
101986 |
|
|
|
101986 |
static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
|
|
|
101986 |
codec_setup_info *ci=vi->codec_setup;
|
|
|
101986 |
+ int bs;
|
|
|
101986 |
if(!ci)return(OV_EFAULT);
|
|
|
101986 |
|
|
|
101986 |
vi->version=oggpack_read(opb,32);
|
|
|
101986 |
@@ -215,8 +216,12 @@ static int _vorbis_unpack_info(vorbis_info *vi,oggpack_buffer *opb){
|
|
|
101986 |
vi->bitrate_nominal=(ogg_int32_t)oggpack_read(opb,32);
|
|
|
101986 |
vi->bitrate_lower=(ogg_int32_t)oggpack_read(opb,32);
|
|
|
101986 |
|
|
|
101986 |
- ci->blocksizes[0]=1<
|
|
|
101986 |
- ci->blocksizes[1]=1<
|
|
|
101986 |
+ bs = oggpack_read(opb,4);
|
|
|
101986 |
+ if(bs<0)goto err_out;
|
|
|
101986 |
+ ci->blocksizes[0]=1<
|
|
|
101986 |
+ bs = oggpack_read(opb,4);
|
|
|
101986 |
+ if(bs<0)goto err_out;
|
|
|
101986 |
+ ci->blocksizes[1]=1<
|
|
|
101986 |
|
|
|
101986 |
if(vi->rate<1)goto err_out;
|
|
|
101986 |
if(vi->channels<1)goto err_out;
|
|
|
101986 |
diff --git a/lib/os.h b/lib/os.h
|
|
|
101986 |
index 416a401..e098926 100644
|
|
|
101986 |
--- a/lib/os.h
|
|
|
101986 |
+++ b/lib/os.h
|
|
|
101986 |
@@ -120,7 +120,7 @@ static inline int vorbis_ftoi(double f){ /* yes, double! Otherwise,
|
|
|
101986 |
/* MSVC inline assembly. 32 bit only; inline ASM isn't implemented in the
|
|
|
101986 |
* 64 bit compiler and doesn't work on arm. */
|
|
|
101986 |
#if defined(_MSC_VER) && !defined(_WIN64) && \
|
|
|
101986 |
- !defined(_WIN32_WCE) && !defined(_M_ARM)
|
|
|
101986 |
+ !defined(_WIN32_WCE) && !defined(_M_ARM) && !defined(_M_ARM64)
|
|
|
101986 |
# define VORBIS_FPU_CONTROL
|
|
|
101986 |
|
|
|
101986 |
typedef ogg_int16_t vorbis_fpu_control;
|
|
|
101986 |
diff --git a/lib/psy.c b/lib/psy.c
|
|
|
101986 |
index 422c6f1..1310123 100644
|
|
|
101986 |
--- a/lib/psy.c
|
|
|
101986 |
+++ b/lib/psy.c
|
|
|
101986 |
@@ -602,8 +602,9 @@ static void bark_noise_hybridmp(int n,const long *b,
|
|
|
101986 |
for (i = 0, x = 0.f;; i++, x += 1.f) {
|
|
|
101986 |
|
|
|
101986 |
lo = b[i] >> 16;
|
|
|
101986 |
- if( lo>=0 ) break;
|
|
|
101986 |
hi = b[i] & 0xffff;
|
|
|
101986 |
+ if( lo>=0 ) break;
|
|
|
101986 |
+ if( hi>=n ) break;
|
|
|
101986 |
|
|
|
101986 |
tN = N[hi] + N[-lo];
|
|
|
101986 |
tX = X[hi] - X[-lo];
|
|
|
101986 |
diff --git a/lib/sharedbook.c b/lib/sharedbook.c
|
|
|
101986 |
index 4545d4f..8d73daa 100644
|
|
|
101986 |
--- a/lib/sharedbook.c
|
|
|
101986 |
+++ b/lib/sharedbook.c
|
|
|
101986 |
@@ -62,7 +62,15 @@ float _float32_unpack(long val){
|
|
|
101986 |
int sign=val&0x80000000;
|
|
|
101986 |
long exp =(val&0x7fe00000L)>>VQ_FMAN;
|
|
|
101986 |
if(sign)mant= -mant;
|
|
|
101986 |
- return(ldexp(mant,exp-(VQ_FMAN-1)-VQ_FEXP_BIAS));
|
|
|
101986 |
+ exp=exp-(VQ_FMAN-1)-VQ_FEXP_BIAS;
|
|
|
101986 |
+ /* clamp excessive exponent values */
|
|
|
101986 |
+ if (exp>63){
|
|
|
101986 |
+ exp=63;
|
|
|
101986 |
+ }
|
|
|
101986 |
+ if (exp<-63){
|
|
|
101986 |
+ exp-63;
|
|
|
101986 |
+ }
|
|
|
101986 |
+ return(ldexp(mant,exp));
|
|
|
101986 |
}
|
|
|
101986 |
|
|
|
101986 |
/* given a list of word lengths, generate a list of codewords. Works
|
|
|
101986 |
diff --git a/lib/vorbisenc.c b/lib/vorbisenc.c
|
|
|
101986 |
index 4a4607c..64a51b5 100644
|
|
|
101986 |
--- a/lib/vorbisenc.c
|
|
|
101986 |
+++ b/lib/vorbisenc.c
|
|
|
101986 |
@@ -684,6 +684,7 @@ int vorbis_encode_setup_init(vorbis_info *vi){
|
|
|
101986 |
highlevel_encode_setup *hi=&ci->hi;
|
|
|
101986 |
|
|
|
101986 |
if(ci==NULL)return(OV_EINVAL);
|
|
|
101986 |
+ if(vi->channels<1||vi->channels>255)return(OV_EINVAL);
|
|
|
101986 |
if(!hi->impulse_block_p)i0=1;
|
|
|
101986 |
|
|
|
101986 |
/* too low/high an ATH floater is nonsensical, but doesn't break anything */
|
|
|
101986 |
@@ -1210,7 +1211,7 @@ int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg){
|
|
|
101986 |
hi->req,
|
|
|
101986 |
hi->managed,
|
|
|
101986 |
&new_base);
|
|
|
101986 |
- if(!hi->setup)return OV_EIMPL;
|
|
|
101986 |
+ if(!new_template)return OV_EIMPL;
|
|
|
101986 |
hi->setup=new_template;
|
|
|
101986 |
hi->base_setting=new_base;
|
|
|
101986 |
vorbis_encode_setup_setting(vi,vi->channels,vi->rate);
|