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

memory overflow in specpack.c code #174

Open
edwardhartnett opened this issue Nov 1, 2021 · 0 comments
Open

memory overflow in specpack.c code #174

edwardhartnett opened this issue Nov 1, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@edwardhartnett
Copy link
Contributor

In specpack.c we have this code:

    /* Calculate Laplacian scaling factors for each possible wave
     * number. */
    pscale = malloc((JJ + MM) * sizeof(g2float));
    tscale = (g2float)idrstmpl[4] * 1E-6;
    for (n = Js; n <= JJ + MM; n++)
        pscale[n] = pow((g2float)(n * (n + 1)), tscale);

Note that the for loop will always cause pscale to be written one beyond the size it has been malloced for. It was malloced for JJ + MM floats, but since the comparison in the for look is "<=" the loop will walk one float past JJ + MM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: No status
Development

No branches or pull requests

1 participant