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

csv: detect end of csv file correctly #404

Merged
merged 2 commits into from
Sep 8, 2021
Merged

csv: detect end of csv file correctly #404

merged 2 commits into from
Sep 8, 2021

Conversation

xypron
Copy link
Contributor

@xypron xypron commented Sep 2, 2021

.sbat sections contain user supplied data. We should not assume that it is
well formed. The last line feed might be missing or it might not be at the
end of the file. Instead one or more \0 might follow.

In parse_csv_data() variable 'line' is a pointer with a value between
the values of 'data' and 'data_end'.

There is no reason to check that it is non-zero after assigning it
from 'data' as we already check 'data'.

Instead at the beginning of the file and after each line we must check that
we have not reached the end of the file marked by a '\0' character.

.sbat sections contain user supplied data. We should not assume that it is
well formed. The last line feed might be missing or it might not be at the
end of the file. Instead one or more \0 might follow.

In parse_csv_data() variable 'line' is a pointer with a value between
the values of 'data' and 'data_end'.

There is no reason to check that it is non-zero after assigning it
from 'data' as we already check 'data'.

Instead at the beginning of the file and after each line we must check that
we have not reached the end of the file marked by a '\0' character.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Data after a NUL byte should be ignored.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
@xypron
Copy link
Contributor Author

xypron commented Sep 3, 2021

By mistake in the original pull request I included a superfluous '#include <stdio.h>'. It is removed now. Thanks @xnox for reviewing.

@vathpela vathpela merged commit 58e8dce into rhboot:main Sep 8, 2021
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 this pull request may close these issues.

2 participants