diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2017-04-22 19:33:33 +0300 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2017-04-22 17:18:49 +0000 |
commit | 225ef1baeb0e49f157f3ba1271915e623bd27dd9 (patch) | |
tree | a036555373f045f6ad7d1acd48bdd71f01c2c208 | |
parent | e5dfb098638628b0215e11791bce372a656af390 (diff) |
Fix possible UB in read() under Unix
If the user calls setReadBufferSize() with a value lesser than the
current size of the read buffer, then we get UB in readNotification():
readFromPort(nullptr, some_negative_value);
Change-Id: Iddf5838c84c8615670285e9883c48f29faacc07e
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r-- | src/serialport/qserialport_unix.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 8f9f087a..4df1fcba 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -773,7 +773,7 @@ bool QSerialPortPrivate::readNotification() if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size())) { bytesToRead = readBufferMaxSize - buffer.size(); - if (bytesToRead == 0) { + if (bytesToRead <= 0) { // Buffer is full. User must read data from the buffer // before we can read more from the port. setReadNotificationEnabled(false); |