Skip to content

Fix Buffer Overflow#640

Merged
adriengivry merged 1 commit intoOverload-Technologies:mainfrom
gabrielOFlores:main
Feb 1, 2026
Merged

Fix Buffer Overflow#640
adriengivry merged 1 commit intoOverload-Technologies:mainfrom
gabrielOFlores:main

Conversation

@gabrielOFlores
Copy link
Contributor

@gabrielOFlores gabrielOFlores commented Feb 1, 2026

Update GetInt functions to use array for results with a fixed size of 4

Description

Fix for Buffer Overflow by limiting the number of integers in GLint:

//GLBackend.cpp

GLint result[4]; // Fixed size of 4

glGetIntegerv(p_parameter, result); // The max size of glGetIntegerv is 4

return static_cast<int>(result[0]);

Related Issue(s)

Fixes #634

Checklist

  • My code follows the project's code style guidelines
  • My changes don't generate new warnings or errors

See also

Why a fixed value of 4?

Update GetInt functions to use array for results with a fixed size of 4
@gabrielOFlores
Copy link
Contributor Author

gabrielOFlores commented Feb 1, 2026

Sorry about earlier, I had some problems with branches and ended up making a mess; git is still quite confusing for me.

@gabrielOFlores
Copy link
Contributor Author

gabrielOFlores commented Feb 1, 2026

From what I've researched, some values ​​within OpenGL use arrays of 4 integers, such as viewports, colors, positions, etc...
Within the Build Debug there must be something that needs to return an array of 4 integers, and since it didn't have a fixed size before, it ended up returning nothing, or garbage.

Copy link
Member

@adriengivry adriengivry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I believe this solution is satisfactory for now. In the future we'll have to look into alternative solutions to avoid allocating unnecessary memory and protect other getters (float, bool, int64...) from buffer overruns.

Thanks for your contribution!

@gabrielOFlores
Copy link
Contributor Author

thank you and all the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Stack smashing (buffer overflow) detected in debug builds

2 participants