diff options
author | 2020-03-27 08:08:57 +0000 | |
---|---|---|
committer | 2020-03-27 08:08:57 +0000 | |
commit | af8f6cf3aba3398b36117dd3acce6f5a3c0610c6 (patch) | |
tree | 8637c0c3300f6a1324bac0b35e2f0b2e69803e08 /libs/binder/BufferedTextOutput.cpp | |
parent | 58e1ce0b3b6881d2ac3ff3bfd4b0548c121286ea (diff) | |
parent | 93fe51840ebf2e2ea0c29d3c5aa196e328129469 (diff) |
Merge "Fix addition/overflow checks." into qt-qpr1-dev
Diffstat (limited to 'libs/binder/BufferedTextOutput.cpp')
-rw-r--r-- | libs/binder/BufferedTextOutput.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/libs/binder/BufferedTextOutput.cpp b/libs/binder/BufferedTextOutput.cpp index 857bbf9510..2978b539d7 100644 --- a/libs/binder/BufferedTextOutput.cpp +++ b/libs/binder/BufferedTextOutput.cpp @@ -49,9 +49,10 @@ struct BufferedTextOutput::BufferState : public RefBase } status_t append(const char* txt, size_t len) { + if (len > SIZE_MAX - bufferPos) return NO_MEMORY; // overflow if ((len+bufferPos) > bufferSize) { + if ((len + bufferPos) > SIZE_MAX / 3) return NO_MEMORY; // overflow size_t newSize = ((len+bufferPos)*3)/2; - if (newSize < (len+bufferPos)) return NO_MEMORY; // overflow void* b = realloc(buffer, newSize); if (!b) return NO_MEMORY; buffer = (char*)b; |