Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
the IO error checking currently done via the
*_noerr
functions are entirely misguided. stdio functions are typically buffered, so most of these calls are more or less just memcpy. and since the password isn't likely going to be big enough to fill the buffer to cause a flush (i,e an actual IO operation) these calls are almost never going to fail - with the exception of the newline character - which might cause a flush if stdout is "interactive" and thus set to line-buffered mode.but there's no guarantee stdout is interactive, user might want to pipe the output to some encryption tool for example. in such cases, the stdout flush will occur due to calling
exit()
and any errors that occur at that point will be entirely missed by the application.the proper way to error check stdio functions is to manually flush at the end and check for the error flag on the stream. here's the result before and after the patch:
additionally, the way
*_noerr
functions are checking forerrno
is also confusing:errno != 0
check is entirely redundant.one regression from this patch is that the exact cause of error is not known anymore. so the error message will be the same for any errors.