CVE-2021-33479
Description
A stack-based buffer overflow in GOCR's measure_pitch() function can lead to memory corruption and potential code execution.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
A stack-based buffer overflow in GOCR's measure_pitch() function can lead to memory corruption and potential code execution.
Vulnerability
A stack-based buffer overflow exists in GOCR (through version 0.53-20200802) in the measure_pitch() function within pgm2asc.c [1]. The function allocates a stack buffer pdists of size 4096 bytes, but when processing certain input, it reads from an offset before the buffer, causing a stack-buffer-underflow (or overflow) condition [1]. The vulnerability is reachable when GOCR processes a crafted image file, as demonstrated by the command ./src/gocr -m 4 @@ [1].
Exploitation
An attacker can exploit this vulnerability by providing a specially crafted image file to GOCR. No authentication or special privileges are required; the attacker only needs to convince a user to process the malicious image with GOCR. The bug is triggered during the measure_pitch() call, leading to out-of-bounds memory access [1].
Impact
Successful exploitation can cause memory corruption, potentially leading to a denial of service or arbitrary code execution in the context of the user running GOCR [2]. The vulnerability has a CVSS score (not provided in header, but it is a stack-based overflow). The Gentoo security advisory rates it as potentially leading to arbitrary code execution [2].
Mitigation
As of the publication date, no official patch has been released for GOCR. The project appears to be discontinued; Gentoo recommends unmerging the package (# emerge --ask --depclean "app-text/gocr") [2]. Users should avoid processing untrusted images with GOCR until a fix is available.
AI Insight generated on May 25, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
2- gocr/gocrdescription
Patches
0No patches discovered yet.
Vulnerability mechanics
Root cause
"A stack-based buffer underflow occurs in the `measure_pitch` function due to improper handling of input data."
Attack vector
An attacker can trigger this vulnerability by providing a specially crafted input file to the gocr utility. The `pgm2asc` function, called by `main`, processes this input and passes it to `measure_pitch`. This leads to a stack-based buffer underflow when `measure_pitch` attempts to read beyond the allocated buffer for `pdists` [ref_id=1].
Affected code
The vulnerability resides in the `measure_pitch` function located in the file `src/pgm2asc.c` [ref_id=1]. Specifically, the issue occurs around line 1689 where a read operation accesses memory at offset 28, underflowing the `pdists` buffer allocated on the stack [ref_id=1].
What the fix does
The provided bundle does not contain a patch file or specific details on the fix. However, the vulnerability is identified in the `measure_pitch` function within `pgm2asc.c` [ref_id=1]. A proper fix would involve validating the input size before accessing the `pdists` buffer to prevent out-of-bounds reads.
Preconditions
- inputA specially crafted input file that causes the `measure_pitch` function to perform an out-of-bounds read.
Generated on Jun 7, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
3- security.gentoo.org/glsa/202401-28mitrevendor-advisory
- bugzilla.redhat.com/show_bug.cgimitre
- sourceforge.net/p/jocr/bugs/39/mitre
News mentions
0No linked articles in our index yet.