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

Fix out-of-bound access on some PDFs. #483

Merged
merged 1 commit into from
Oct 10, 2020

Conversation

Flameeyes
Copy link
Contributor

Replace the non-emptiness check with a minimum length check — you can't get the second to last item in a list of less than two items.

@pietermarsman
Copy link
Member

Hi @Flameeyes, thanks for the suggestion. Can you create an issue first? Maybe also add an example PDF that shows the problematic behavior.

I'm closing this PR since it might introduce new problems. E.g. if x == None the len(x) fails.

@Flameeyes
Copy link
Contributor Author

Unfortunately, I cannot provide an example PDF because the PDF having an issue is a bank statement, which is one of the strongest forms of PII. That's the reason why I didn't file an issue — there's nothing I can provide beside the stack trace.

I'd like to point out that closing a first-contribution pull request is not a very friendly presentation. GitHub has a review system where you can request changes, instead of closing a pull request. That's significantly less adversarial than closing.

Furthermore, your assertion regarding the change's ability to introduce new problem is actually incorrect. x is assigned an empty list ([]) at the beginning of the block the if is in, so it can never be None. So len(x) is always valid.

You're welcome to reopen and merge this pull request if that made you change your mind.

@pietermarsman
Copy link
Member

I was indeed a bit quick in closing this PR. By looking a bit more to the context of your change I now see that the len(x) check is indeed a much better alternative than checking for an empty list. Sorry for my impatience!

@pietermarsman pietermarsman reopened this Sep 17, 2020
Copy link
Member

@pietermarsman pietermarsman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To finish up this PR, can you add a line to the changelog?

Replace the non-emptiness check with a minimum length check — you can't get the second to last item in a list of less than two items.
@Flameeyes
Copy link
Contributor Author

To finish up this PR, can you add a line to the changelog?

Yup, done!

Thank you for circling back on this one :)

@pietermarsman pietermarsman merged commit 67e2d79 into pdfminer:develop Oct 10, 2020
@pietermarsman
Copy link
Member

Thanks for the work (and the patience)!

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