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

Invalid memory read in process_EXIF()/Get16u() #49

Closed
joachim-reichel opened this issue Dec 22, 2021 · 2 comments
Closed

Invalid memory read in process_EXIF()/Get16u() #49

joachim-reichel opened this issue Dec 22, 2021 · 2 comments

Comments

@joachim-reichel
Copy link
Contributor

Running jhead 3.06.0.1 on the attached repro case under valgrind results in

==3535479== Memcheck, a memory error detector
==3535479== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3535479== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
[...] (some error messages from jhead removed for brevity)
==3535479== Conditional jump or move depends on uninitialised value(s)
==3535479==    at 0x11197F: process_EXIF (exif.c:1042)
==3535479==    by 0x10EDBF: ReadJpegSections.part.0 (jpgfile.c:289)
==3535479==    by 0x10EFE8: ReadJpegSections (jpgfile.c:125)
==3535479==    by 0x10EFE8: ReadJpegFile [(jpgfile.c:381)](url)
==3535479==    by 0x10CC16: ProcessFile (jhead.c:914)
==3535479==    by 0x10B6DB: main (jhead.c:1770)

The problem still exists in current master.

The problem is that process_EXIF() expects that length >= 16 but does not check that at all (here it is 10). There is check a couple of lines later (executed only under certain conditions), but IMHO this should be checked much sooner (before the EXIF header component check).

Original Debian bug report: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=968961

00_invalid_read_get16u

@Matthias-Wandel
Copy link
Owner

Unable to reproduce

Matthias-Wandel pushed a commit that referenced this issue Jun 6, 2023
However, issue #49 was not reproducible ahead of this, so can't be sure.
@Matthias-Wandel
Copy link
Owner

added the suggested fix int 18de671
However, seeing that the problem already could not be reproduced without this change, I can't be 100% sure.

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

2 participants