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

Truncated stdio Return Value #88

Open
ArielSAdamsNASA opened this issue Sep 27, 2021 · 0 comments
Open

Truncated stdio Return Value #88

ArielSAdamsNASA opened this issue Sep 27, 2021 · 0 comments

Comments

@ArielSAdamsNASA
Copy link

Describe the bug
There are API usage errors with fgetc.

Expected behavior
Check EOF then cast value.

Code snips

while ((VerboseStr[i] = fgetc(SrcFileDesc)) != '\0')

while ((i < sizeof(VerboseStr)) && ((VerboseStr[i] = fgetc(SrcFileDesc)) != '\0'))

AByte = fgetc(SrcFileDesc);

AByte = fgetc(SrcFileDesc);

System observed on:
Coverity: https://scan.coverity.com/projects/arielsadamsnasa-cfs-jsf-rules?tab=overview

Additional context
Assigning the return value of fgetc to char AByte truncates its value.

Assigning the return value of fgetc to char VerboseStr[i] truncates its value.

Reporter Info
Ariel Adams, ASRC Federal

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

No branches or pull requests

1 participant