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

Check Return Value of fseek #85

Open
ArielSAdamsNASA opened this issue Sep 23, 2021 · 0 comments · May be fixed by #123
Open

Check Return Value of fseek #85

ArielSAdamsNASA opened this issue Sep 23, 2021 · 0 comments · May be fixed by #123

Comments

@ArielSAdamsNASA
Copy link

ArielSAdamsNASA commented Sep 23, 2021

Describe the bug
The return value of fseek is not checked which may cause an unexpected failure.

Expected behavior
Check the return value for fseek in elf2cfetbl.c.

Code snips

fseek(SrcFileDesc, SeekOffset, SEEK_SET);

fseek(SrcFileDesc, SeekOffset, SEEK_SET);

fseek(SrcFileDesc, SeekOffset, SEEK_SET);

fseek(SrcFileDesc, SeekOffset, SEEK_SET);

Additional context
Identified by Coverity: https://scan.coverity.com/projects/arielsadamsnasa-cfs-jsf-rules?tab=overview

Possible solution:

                Status = fseek(SrcFileDesc, SeekOffset, SEEK_SET);
                if (Status != 0)
                {
                    printf("Error locating Section Header #%d in file '%s'\n", SectionIndex, SrcFilename);
                    return FAILED;
                }
                else 
                {
                    fseek(SrcFileDesc, SeekOffset, SEEK_SET);
                }

Reporter Info
Ariel Adams, ASRC Federal

thnkslprpt added a commit to thnkslprpt/elf2cfetbl that referenced this issue Nov 11, 2022
@thnkslprpt thnkslprpt linked a pull request Nov 11, 2022 that will close this issue
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant