Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

ERROR: AddressSanitizer: global-buffer-overflow in function ErrorIDToName

Open Beginner friendly
#923 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
cpp
Domain
backend

Research direction

Start in tinyxml2.cpp at ErrorIDToName and the _errorNames array, then check the XMLError enum in tinyxml2.h. The array has 19 entries but the enum value XML_ERROR_COUNT (19) can reach the indexing line. Reproduce with the attached fuzzing wrapper under AddressSanitizer. Done when ErrorIDToName no longer reads past the array for XML_ERROR_COUNT and the existing tests still pass.

Written by the indexing model from the issue text.

Description

Instrument Futag found this error with tinyxml2 version 9.0.0 and in current version.

https://github.com/leethomason/tinyxml2/blob/e45d9d16d430a3f5d3eee9fe40d5e194e1e5e63a/tinyxml2.cpp#L2501-L2507

errorID is a variable of XMLError type, which can receive value from XML_SUCCESS (0) to XML_ERROR_COUNT (19)
https://github.com/leethomason/tinyxml2/blob/e45d9d16d430a3f5d3eee9fe40d5e194e1e5e63a/tinyxml2.h#L523-L545

The _errorNames array has 19 elements (from 0 to 18) and was defined here:
https://github.com/leethomason/tinyxml2/blob/e45d9d16d430a3f5d3eee9fe40d5e194e1e5e63a/tinyxml2.cpp#L2136-L2156

So, when errorID gets XML_ERROR_COUNT value, error occurs at instruction const char* errorName = _errorNames[errorID];

The generated fuzzing wrapper is attached below.
ErrorIDToName1.cpp.zip

Dominant language
C++
Stars
5.8k
Forks
2k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from leethomason/tinyxml2

All issues in leethomason/tinyxml2

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.