Skip to content
Snippets Groups Projects
  1. Mar 24, 2025
  2. Mar 22, 2025
  3. Mar 21, 2025
  4. Mar 20, 2025
  5. Mar 19, 2025
  6. Mar 17, 2025
  7. Mar 16, 2025
  8. Mar 15, 2025
  9. Mar 14, 2025
    • Jörn Heusipp's avatar
      Add CI for --disable-asm. · fcc5d21e
      Jörn Heusipp authored
      CI currently does not thoroughly test encoding and decoding (except for
      encoding zeroed dummy frames).
      Testing --disable-asm is still useful because it ensures that the code compiles
      on platforms where there are no ASM optimizations and the generic C code paths
      are used.
      fcc5d21e
  10. Mar 10, 2025
    • Petter Reinholdtsen's avatar
      Renamed header file identifiers using C/C++ reserved name structure. · e5ccaa14
      Petter Reinholdtsen authored
      Adjust clang CI run to report warning about reserved identifiers.
      e5ccaa14
    • Petter Reinholdtsen's avatar
      Avoid negative bit shift operatoin in huffdec.c (CVE-2024-56431). · 5665f86b
      Petter Reinholdtsen authored
      A crash was discovered using input fuzzying, in th_decode_ceaderin()
      where the len value in the oc_fuff_tree_unpack() can end up as -1.
      Added a check to ensure this do not happen.
      
      Based on feedback from Timothy B. Terriberry.
      
      The issue was discovered using gcc sanitazion, which reported the following:
      
      huffdec.c:228:27: runtime error: shift exponent -1 is negative
          #0 0x5d471012bfd0 in oc_huff_tree_unpack /home/uos/libtheora-18570/theora/lib/huffdec.c:228
          #1 0x5d471012c134 in oc_huff_trees_unpack /home/uos/libtheora-18570/theora/lib/huffdec.c:392
          #2 0x5d471010a98c in oc_setup_unpack /home/uos/libtheora-18570/theora/lib/decinfo.c:169
          #3 0x5d471010a98c in oc_dec_headerin /home/uos/libtheora-18570/theora/lib/decinfo.c:238
          #4 0x5d471010a98c in th_decode_headerin /home/uos/libtheora-18570/theora/lib/decinfo.c:266
          #5 0x5d47100fd638 in TheoraDecoder::initialize() /home/uos/libtheora-18570/libtheora-18570/fuzzer.cpp:66
          #6 0x5d47100ffa76 in TheoraDecoder::Run() /home/uos/libtheora-18570/libtheora-18570/fuzzer.cpp:180
          #7 0x5d47100ffe48 in main /home/uos/libtheora-18570/libtheora-18570/fuzzer.cpp:240
          #8 0x7cc9a5e29d8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
          #9 0x7cc9a5e29e3f in __libc_start_main_impl ../csu/libc-start.c:392
          #10 0x5d47100f9964 in _start (/home/uos/libtheora-18570/libtheora-18570/poc1+0x83964)
      
      Fixes github pull request #19.
      5665f86b
    • Petter Reinholdtsen's avatar
      Added mingw CI build. · 13c10914
      Petter Reinholdtsen authored
      Do not build examples, as it require libvorbis, and do not build
      documentation as it require a host of programs not available
      during cross building.
      13c10914
    • Petter Reinholdtsen's avatar
      Avoided bit shift of negative values in OC_MV() macro. · 5a8228a6
      Petter Reinholdtsen authored
      During video playout using player_example with gcc sanitaztions
      enabled, new bit shifting of negative values were discovered.
      Replaced this with multiplication too.
      5a8228a6
  11. Mar 09, 2025
  12. Mar 08, 2025
    • Petter Reinholdtsen's avatar
      Adjusted OC_DCT_CW_PACK() for well defined C99 behaviour with negative _mag. · a768e356
      Petter Reinholdtsen authored
      Instead of shifting the negative number, shift one bit and multiply
      it with the negative number.
      
      Fixes the following clang message:
      ../../lib/decode.c:195:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0,10, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:198:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0,  0,1),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:208:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 1, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:210:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 2, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:212:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 3, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:214:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 4, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:216:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 5, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:220:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 1, -2,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:221:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 1, -3,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:227:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 6, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:228:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 7, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:229:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 8, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:230:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 9, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:236:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 2, -2,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:237:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 3, -2,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:238:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 2, -3,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:239:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 3, -3,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:242:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0,  0,1),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:253:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -1,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:257:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -2,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:260:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -3,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:262:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -4,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:264:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -5,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:266:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -6,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:270:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -7,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:271:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -8,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:277:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0, -9,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:278:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0,-10,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:279:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0,-11,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      ../../lib/decode.c:280:3: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
        OC_DCT_CW_PACK( 0, 0,-12,0),
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../../lib/decode.c:150:16: note: expanded from macro 'OC_DCT_CW_PACK'
       (_mag)-(_flip)<<OC_DCT_CW_MAG_SHIFT)
       ~~~~~~~~~~~~~~^
      
      Fixes #2322
      a768e356
    • Petter Reinholdtsen's avatar
      Make sure difference in encfrag.c is signed when taking absolute value. · f7c9abd4
      Petter Reinholdtsen authored
      Switching type of cd from unsigned to int make sure the difference
      passed to abs() wil be a signed value.
      
      As dc is calculated to at most ((8 * 8 * (2^8-1)) + 32) / 64, ie 255
      and the highest value it can hold before it is shifted 6 bit positions
      to the right is (8 * 8 * (2^8-1)) + 32) ie. 16352, it should fit nicely
      in an integer on any platform where int is at least 16 bit.
      
      Fixes this clang message:
      
      ../../../lib/encfrag.c:104:26: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
          for(j=0;j<8;j++)sad+=abs(_src[j]-dc);
                               ^
      ../../../lib/encfrag.c:104:26: note: remove the call to 'abs' since unsigned values cannot be negative
          for(j=0;j<8;j++)sad+=abs(_src[j]-dc);
                               ^~~
      f7c9abd4
    • Petter Reinholdtsen's avatar
      Stopped calculated unused total in oc_huff_tree_size(). · 4b90527c
      Petter Reinholdtsen authored
      This get rid of the following clang warning:
      
      huffdec.c:439:7: warning: variable 'total' set but not used [-Wunused-but-set-variable]
        int total;
            ^
      4b90527c
    • Petter Reinholdtsen's avatar
      Adjusted macros to avoid working outside OC_IDCT_CONSTS array. · 877ac811
      Petter Reinholdtsen authored
      The OC_IDCT_CONSTS array in x86/sse2idct.c is 64 elements long, so
      not use trying to pretend it is 128 elements long.
      
      This avoid the following copmiler message:
      
      In function 'oc_idct8x8_slow_mmx',
          inlined from 'oc_idct8x8_mmx' at ../../lib/x86/mmxidct.c:555:8:
      ../../lib/x86/mmxidct.c:290:3: warning: array subscript 'const struct <anonymous>[0]' is partly outside array bounds of 'const short unsigned int[64]' [-Warray-bounds]
        290 |   __asm__ __volatile__(
            |   ^~~~~~~
      In file included from ../../lib/x86/mmxidct.c:20:
      ../../lib/x86/x86int.h: In function 'oc_idct8x8_mmx':
      ../../lib/x86/x86int.h:95:58: note: object 'OC_IDCT_CONSTS' of size 128
         95 | extern const unsigned short __attribute__((aligned(16))) OC_IDCT_CONSTS[64];
            |                                                          ^~~~~~~~~~~~~~
      In function 'oc_idct8x8_10_mmx',
          inlined from 'oc_idct8x8_mmx' at ../../lib/x86/mmxidct.c:554:20:
      ../../lib/x86/mmxidct.c:492:3: warning: array subscript 'const struct <anonymous>[0]' is partly outside array bounds of 'const short unsigned int[64]' [-Warray-bounds]
        492 |   __asm__ __volatile__(
            |   ^~~~~~~
      ../../lib/x86/x86int.h: In function 'oc_idct8x8_mmx':
      ../../lib/x86/x86int.h:95:58: note: object 'OC_IDCT_CONSTS' of size 128
         95 | extern const unsigned short __attribute__((aligned(16))) OC_IDCT_CONSTS[64];
            |                                                          ^~~~~~~~~~~~~~
        CC       x86/sse2idct.lo
      In function 'oc_idct8x8_slow_sse2',
          inlined from 'oc_idct8x8_sse2' at ../../lib/x86/sse2idct.c:453:8:
      ../../lib/x86/sse2idct.c:213:3: warning: array subscript 'const struct <anonymous>[0]' is partly outside array bounds of 'const short unsigned int[64]' [-Warray-bounds]
        213 |   __asm__ __volatile__(
            |   ^~~~~~~
      ../../lib/x86/sse2idct.c: In function 'oc_idct8x8_sse2':
      ../../lib/x86/sse2idct.c:26:56: note: object 'OC_IDCT_CONSTS' of size 128
         26 | const unsigned short __attribute__((aligned(16),used)) OC_IDCT_CONSTS[64]={
            |                                                        ^~~~~~~~~~~~~~
      In function 'oc_idct8x8_10_sse2',
          inlined from 'oc_idct8x8_sse2' at ../../lib/x86/sse2idct.c:452:20:
      ../../lib/x86/sse2idct.c:398:3: warning: array subscript 'const struct <anonymous>[0]' is partly outside array bounds of 'const short unsigned int[64]' [-Warray-bounds]
        398 |   __asm__ __volatile__(
            |   ^~~~~~~
      ../../lib/x86/sse2idct.c: In function 'oc_idct8x8_sse2':
      ../../lib/x86/sse2idct.c:26:56: note: object 'OC_IDCT_CONSTS' of size 128
         26 | const unsigned short __attribute__((aligned(16),used)) OC_IDCT_CONSTS[64]={
            |                                                        ^~~~~~~~~~~~~~
      877ac811
Loading