szaszm commented on a change in pull request #1028:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1028#discussion_r596130219
##########
File path: libminifi/src/io/tls/SecureDescriptorStream.cpp
##########
@@ -71,34 +71,29 @@ int SecureDescriptorStream::write(const uint8_t *value, int
size) {
}
}
-int SecureDescriptorStream::read(uint8_t *buf, int buflen) {
- gsl_Expects(buflen >= 0);
+size_t SecureDescriptorStream::read(uint8_t * const buf, const size_t buflen) {
if (buflen == 0) {
return 0;
}
- if (!IsNullOrEmpty(buf)) {
- int total_read = 0;
- int status = 0;
- while (buflen) {
- int sslStatus;
- do {
- status = SSL_read(ssl_, buf, buflen);
- sslStatus = SSL_get_error(ssl_, status);
- } while (status < 0 && sslStatus == SSL_ERROR_WANT_READ);
+ if (IsNullOrEmpty(buf)) return static_cast<size_t>(-1);
+ size_t total_read = 0;
+ uint8_t* writepos = buf;
+ while (buflen > total_read) {
+ int status;
+ int sslStatus;
+ do {
+ status = SSL_read(ssl_, writepos, gsl::narrow<int>(std::min(buflen -
total_read, gsl::narrow<size_t>(std::numeric_limits<int>::max()))));
Review comment:
named the third argument in 46f3b0e
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]