adamdebreceni commented on a change in pull request #1028:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1028#discussion_r601313766



##########
File path: extensions/mqtt/processors/PublishMQTT.h
##########
@@ -74,19 +77,21 @@ class PublishMQTT : public 
processors::AbstractMQTTProcessor {
       status_ = 0;
       read_size_ = 0;
     }
-    ~ReadCallback() = default;
-    int64_t process(const std::shared_ptr<io::BaseStream>& stream) {
+    ~ReadCallback() override = default;
+    int64_t process(const std::shared_ptr<io::BaseStream>& stream) override {
       if (flow_size_ < max_seg_size_)
         max_seg_size_ = flow_size_;
+      gsl_Expects(max_seg_size_ < 
gsl::narrow<uint64_t>(std::numeric_limits<int>::max()));
       std::vector<unsigned char> buffer;
       buffer.reserve(max_seg_size_);
       read_size_ = 0;
       status_ = 0;
       while (read_size_ < flow_size_) {
-        int readRet = stream->read(&buffer[0], max_seg_size_);
+        // MQTTClient_message::payloadlen is int, so we can't handle 2GB+
+        int readRet = static_cast<int>(stream->read(&buffer[0], 
max_seg_size_));

Review comment:
       we could check the return value of `stream->read(...)` with 
`io::isError` before casting to `int`




-- 
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:
us...@infra.apache.org


Reply via email to