-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Allow 0 as a valid ret value for mbedtls_ssl_write #1006
Allow 0 as a valid ret value for mbedtls_ssl_write #1006
Conversation
c35b56d
to
c0f1ad4
Compare
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.
Ok, but I think we should add some comments inside ssl_tls.c
as well. This patch was triggered by a proposed change to ssl_tls.c
which we analyzed and rejected; we should document the relevant place in ssl_write_real
to explain what's happening.
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.
Without modifying ssl_tls.c
, this doesn't resolve the issue. We've concluded that the code shouldn't be modified, but we should add a comment to explain the current behavior.
@gilles-peskine-arm: I have added more documentation to |
Documentation-only change, so ok to merge despite the CI failed (and anyway all the CI steps suceeded??) |
@gilles-peskine-arm: Indeed, I am not sure why the overall test reports a failure, but it seems that none of the individual pipeline stages failed. |
include/mbedtls/ssl.h
Outdated
* value or MBEDTLS_ERR_SSL_WANT_READ/WRITE, the ssl context | ||
* becomes unusable, and you should either free it or call | ||
* \c mbedtls_ssl_session_reset() on it before re-using it for | ||
* a new connection; the current connection must be closed. | ||
* | ||
* \note When this function returns MBEDTLS_ERR_SSL_WANT_WRITE/READ, | ||
* it must be called later with the *same* arguments, | ||
* until it returns a positive value. | ||
* until it returns a value greater that or equal to 0. |
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.
It should be greater than or
here.
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.
You mean that the sentence should be ... until it returns a value greater then or 0
?
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.
until it returns a value greater than or equal to 0
/* | ||
* The user is trying to send a message the first time, so we need to | ||
* copy the data into the internal buffers and setup the data structure | ||
* to keep track of partial writes |
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.
Thanks for this additional documentation 👍
Nitpicking: There are full stops missing at the end of this and the previous documentation snippet.
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 think I will leave it as it is. I think the reason for this is that the doxygen documentation should be well punctuated, etc because it will ultimately end up as a formal documentation website. However, these are only in code comments, if you look at the other comments like this, you will see that (1) the style is fairly inconsistent across the library and (2) a lot of them don't have a full stop at the end either.
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.
Please correct it in case you add an additional commit for the other documentation fix - it's not a big thing and where we see such things we should correct them on the fly.
I noticed we currently don't support |
@andresag01 While I would prefer the test changes to be done in this PR, I might open a separate PR for them to not block progress here. @gilles-peskine-arm What's your opinion on that? |
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.
Left some comments on grammar in the documentation, but otherwise I'm fine with the changes. I've also read the code and ran a test to confirm that it is possible to send empty AD records.
Leaving it to @gilles-peskine-arm whether or not to correct the documentation, they are not blockers.
I think we should add tests for empty AD records, which would involve a small adaption to ssl_client2.c
. I could do that here if desired, or defer it to a separate PR.
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 ran some more tests and noticed unexpected behavior in some cases that I need to investigate. Please don't merge, yet.
Sending and receiving 0-sized application records is not well-tested, but documenting it well gives the impression that it's well-supported. Therefore, I'm holding off merging this for the time being. Tracked internally in IOTSSL-1255 |
LGTM. |
@andresag01 - Could you please rebase this PR and create backports? |
This patch modifies the documentation for mbedtls_ssl_write() to allow 0 as a valid return value as this is the correct number of bytes that should be returned when an empty TLS Application record is sent.
ed071d9
to
5b92352
Compare
@sbutcher-arm: I have rebased the PR and created the backports: |
This patch modifies the documentation for mbedtls_ssl_write() to allow
0 as a valid return value as this is the correct number of bytes that
should be returned when an empty TLS Application record is sent.
NOTES: