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

SEGV in jfif_encode() at jfif.c:763 #47

Closed
Marsman1996 opened this issue Dec 16, 2021 · 0 comments
Closed

SEGV in jfif_encode() at jfif.c:763 #47

Marsman1996 opened this issue Dec 16, 2021 · 0 comments

Comments

@Marsman1996
Copy link
Contributor

This segment fault error is because in bmp_load(), when bmp's size is out of range, it returns without assign memory buffer to pb->pdata and did not exit the program.
So the program crashes when it tries to access the pb->data, which is a invalid memory address.

Test Environment

Ubuntu 16.04, 64bit
ffjpeg (master d5cfd49)

How to trigger

$ ./ffjpeg -e $POC

POC FILE

https://github.com/Marsman1996/pocs/blob/master/ffjpeg/poc-ffjpeg-d5cfd49-jfif_encode-SEGV?raw=true

Details

gdb report

Breakpoint 1, bmp_load (pb=0x7fffffffdae0, file=0x7fffffffe070 "./poc-ffjpeg-d5cfd49-jfif_encode-SEGV") at bmp.c:45
45              printf("bmp's width * height is out of range !\n");
(gdb) n
bmp's width * height is out of range !
46              goto done;
(gdb) c
Continuing.

Breakpoint 2, jfif_encode (pb=0x7fffffffdae0) at jfif.c:757
757         bsrc = pb->pdata;
(gdb) n
758         ydst = yuv_datbuf[0];
(gdb) p bsrc
$2 = (BYTE *) 0x0
(gdb) c
Continuing.

Program received signal SIGSEGV, Segmentation fault.
0x0000000000520b78 in jfif_encode (pb=0x7fffffffdae0) at jfif.c:763
763                 rgb_to_yuv(bsrc[2], bsrc[1], bsrc[0], ydst, udst, vdst);
(gdb) bt
#0  0x0000000000520b78 in jfif_encode (pb=0x7fffffffdae0) at jfif.c:763
#1  0x0000000000515e58 in main (argc=3, argv=0x7fffffffdcf8) at ffjpeg.c:30
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

No branches or pull requests

1 participant