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
bin2bn(): When len==0, just return a zero BIGNUM #20033
Conversation
This allows calls with s==NULL and len==0 to be safe. It probably already was, but address sanitizers could still complain.
This replaces #20017 |
Something to be noted is that this isn't necessary in 3.1 or 3.0, as they have older code, where this is already correctly dealt with. It can be argued that this fixes an omission from the refactoring that happened in master |
Would it be possible to add a testcase? |
This explains why I saw the address sanitizer complaining about this just now (when running my provider against master), although the bug in my provider leading to that situation was there much longer.... |
We test with binary input of length 1, length 0, and NULL input with length 0
Test added... I wonder if that should be backported to 3.1 and 3.0 |
Hmm... CI is relevant |
+1 to that. |
Oops, forgot to free |
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.
LGTM
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.
I notice that this function also blindly allows len to be negative.. (Which seems bad to me)
True that... and looking back at released versions, I see the same there, all the way down to 1.1.1. That might be a subject for a different PR |
Test included
I added code to catch the |
Re-review needed |
This pull request is ready to merge |
Merged to master. Thank you. |
This allows calls with s==NULL and len==0 to be safe. It probably already was, but address sanitizers could still complain. Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from #20033)
We test with binary input of length 1, length 0, and NULL input with length 0 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from #20033)
Test included Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Hugo Landau <hlandau@openssl.org> (Merged from #20033)
This allows calls with s==NULL and len==0 to be safe. It probably already
was, but address sanitizers could still complain.
This fixes the underlying problem detected in #20011