Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ht_dec.c:1215 #1492

Merged
merged 1 commit into from
Dec 8, 2023
Merged

fix ht_dec.c:1215 #1492

merged 1 commit into from
Dec 8, 2023

Conversation

headshog
Copy link
Contributor

@headshog headshog commented Dec 6, 2023

Hi! We've been fuzzing openjpeg with sydr-fuzz security predicates and we found incorrect using of memcpy in ht_dec.c:1215.

In function opj_t1_ht_decode_cblk at line 1215 there is a memcpy call: memcpy(cblkdata + cblk_len, cblk->chunks[i].data, cblk->chunks[i].len). We have found input where cblk_len is NULL, so therefore nullptr + offset is put in destination parameter of memcpy and that is incorrect. Also, if cblk_len is NULL and cblk->chunks[i].len is not zero, that instantly leads to crash.

Environment

How to reproduce this error

  1. Build docker container:

    sudo docker build -t oss-sydr-fuzz-openjpeg .
    
  2. Run docker container:

    sudo docker run --privileged --network host -v /etc/localtime:/etc/localtime:ro --rm -it -v $PWD:/fuzz oss-sydr-fuzz-openjpeg /bin/bash
    
  3. Run on the following input:

     /opj_decompress_fuzzer_JP2_afl sydr_ht_dec.txt
    
  4. Output:

    /openjpeg/src/lib/openjp2/ht_dec.c:1215:20: runtime error: null pointer passed as argument 1, which is declared to never be null
    /usr/include/string.h:44:28: note: nonnull attribute specified here
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /openjpeg/src/lib/openjp2/ht_dec.c:1215:20
    

@rouault rouault merged commit 03afd06 into uclouvain:master Dec 8, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants