-
Notifications
You must be signed in to change notification settings - Fork 206
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
Fix #298, fix infinite loop when gz file is truncated #367
Conversation
Has this been confirmed to correctly handle a NON-truncated file? |
Another general comment, if we are touching this code I would like to see a couple more changes. The checks of At line 287:
And At line 294:
Rather than specifically testing for Also note that the |
Preference is to avoid "magic numbers" like -1. Is there an OSAL/CFE define that is appropriate? |
Not particularly. The function is supposed to return the first character in the buffer, but in this case the buffer is empty, so there is nothing to return. Another reasonable option might be the NUL char (0). But that just as magic as -1. Returning 0 won't corrupt the shift register that the values go into, whereas -1 does. Either way though, this decompress code still violates coding standards in every conceivable way. I only mention it because it might cause a compile failure if things change and EOF no longer happens to be defined. Same with the length check (testing <= 0 vs. testing a specific value). The real fix for this should be done in #291 |
Understood. Let's fix the <=0 now. The EOF builds today and the "-1" solution isn't acceptable, so lets just leave as is for now. Or if you really want to, feel free to propose a solution that doesn't include the use of a "magic number" (create an appropriate #define, identify an appropriate one that already exists, or whatever). But I don't think the EOF change is worth our time right now due to #291.
Agreed, which is why I'm OK with leaving the EOF as-is, but I'd like to get this fix in first. |
Since it's all local to cfe_fs_decompress.c, why not just: #define CFE_FS_EOF -1 or something? and change EOF to CFE_FS_EOF? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Describe the contribution
Fix issue #298, when cfe_fs_decompress goes into infinite loop when gz file is truncated.
Fix #298
Testing performed
corgi2.jpg.gz
Gzip good file
Pass as parameter and verify output.
System(s) tested on:
Contributor Info
Anh Van, NASA Goddard
Community contributors
You must attach a signed CLA (required for acceptance) or reference one already submitted