Aritmetic exception when scanning a QR code
Status: Beta
Brought to you by:
spadix
Hi,
Using AFL, we managed to craft a QR file that triggers a SIGFPE in zbarimg. Find attached the file. If you use zbarimg, you will get a crash with a stack trace like this one:
Program received signal SIGFPE, Arithmetic exception.
0x000000000042ae66 in qr_hom_fit (_hom=0x7fffffffdaa0, _ul=0x7fffffffdb20, _ur=0x7fffffffdba0, _dl=0x7fffffffdc20, _p=0x7fffffffdda4,
_aff=0x7fffffffda40, _isaac=0x61e00000f380, _img=0x624000006100 '\377' <repeats 24 times>, _width=86, _height=87) at zbar/qrcode/qrdec.c:2244
2244 brx=(int)QR_DIVROUND(QR_EXTMUL((dim-7)*_p[0][0],p3[0]*dy21,
(gdb) bt
#0 0x000000000042ae66 in qr_hom_fit (_hom=0x7fffffffdaa0, _ul=0x7fffffffdb20, _ur=0x7fffffffdba0, _dl=0x7fffffffdc20, _p=0x7fffffffdda4,
_aff=0x7fffffffda40, _isaac=0x61e00000f380, _img=0x624000006100 '\377' <repeats 24 times>, _width=86, _height=87) at zbar/qrcode/qrdec.c:2244
#1 0x0000000000435d73 in qr_reader_try_configuration (_reader=0x61e00000f080, _qrdata=0x7fffffffdd90, _img=0x624000006100 '\377' <repeats 24 times>,
_width=86, _height=87, _c=0x7fffffffdd50) at zbar/qrcode/qrdec.c:3666
#2 0x00000000004365f0 in qr_reader_match_centers (_reader=0x61e00000f080, _qrlist=0x7fffffffdf00, _centers=0x61500000be80, _ncenters=16,
_img=0x624000006100 '\377' <repeats 24 times>, _width=86, _height=87) at zbar/qrcode/qrdec.c:3828
#3 0x0000000000437874 in _zbar_qr_decode (reader=0x61e00000f080, iscn=0x611000009f00, img=0x60800000bfa0) at zbar/qrcode/qrdec.c:3940
#4 0x000000000040a2cf in zbar_scan_image (iscn=0x611000009f00, img=0x60800000bfa0) at zbar/img_scanner.c:752
We tested this issue in zbar 0.10 (libzbar0) running Ubuntu 14.04 (x86_64) and ArchLinux (x86_64)
Regards,
Gustavo.