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

buffer owerflow in the function parseVariant #6342

Open
DmitriyFedin opened this issue Sep 24, 2024 · 0 comments
Open

buffer owerflow in the function parseVariant #6342

DmitriyFedin opened this issue Sep 24, 2024 · 0 comments
Labels
needs triage The issue will be triaged during scrum

Comments

@DmitriyFedin
Copy link

if ((variant[0] < VAR_MIN) || (variant[0] > VAR_MAX)) {
fprintf(stderr, "Error: bad variable in %s : \"%s\"\n", fname, line);
fprintf(stderr, "Error: must be in [%c-%c]\n", VAR_MIN, VAR_MAX);
return (-1);
}
field->var = variant[0] - VAR_MIN;
variant++; /* Skip variable name */
variant++; /* Skip '=' */
/*
* We need a variable !
*/
if (obj->var[field->var] == NULL)
obj->var[field->var] = (char *)safe_malloc(MAX_FILTER);

In this case, the variable variant0 can reach a maximum value of 72.

The expression var = variant0 - VAR_MIN; calculates the difference between variant0 and a constant VAR_MIN, resulting in a value of 7 in this specific example.
Attempting to access the array using the calculated index 7 would lead to an out-of-bounds access, causing an array overflow.

Package Version and Platform:

  • Platform: ALT Linux 10
  • Package and version: main

Additional context
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reporter: Dmitriy Fedin ([email protected]).
Organization: Fobos-NT ([email protected]).

@DmitriyFedin DmitriyFedin added the needs triage The issue will be triaged during scrum label Sep 24, 2024
@DmitriyFedin DmitriyFedin changed the title Using a pointer size instead of buffer size at function get_ip_str buffer owerflow in the function parseVariant Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage The issue will be triaged during scrum
Projects
None yet
Development

No branches or pull requests

1 participant