aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-12-31 11:14:50 -0500
committerJack Lloyd <[email protected]>2015-12-31 11:14:50 -0500
commit75e60b8fdbce20c5a82cd09c741b0cad5c25547b (patch)
tree2677fe47c7db57c49f92d9dcbb6d82125299bd1a
parentd4915aa4cd9c11879780267413f2980d0014240e (diff)
Add missing assignment in DataSource::discard_next
Reported on the mailing list by Falko
-rw-r--r--doc/news.rst4
-rw-r--r--src/lib/utils/data_src.cpp1
2 files changed, 5 insertions, 0 deletions
diff --git a/doc/news.rst b/doc/news.rst
index e340033c4..9ddca58bd 100644
--- a/doc/news.rst
+++ b/doc/news.rst
@@ -34,6 +34,10 @@ Version 1.11.26, Not Yet Released
* Add support for RSA-KEM from ISO 18033-2
+* Fix a bug in DataSource::discard_next() which could cause either an
+ infinite loop or the discarding of an incorrect number of bytes.
+ Reported on mailing list by Falko Strenzke.
+
* Avoid calling memcpy, memset, or memmove with a length of zero to
avoid undefined behavior, as calling these functions with an invalid
or null pointer, even with a length of zero, is invalid. Often there
diff --git a/src/lib/utils/data_src.cpp b/src/lib/utils/data_src.cpp
index 4e0725943..b79f83d40 100644
--- a/src/lib/utils/data_src.cpp
+++ b/src/lib/utils/data_src.cpp
@@ -41,6 +41,7 @@ size_t DataSource::discard_next(size_t n)
{
const size_t got = this->read(buf, std::min(n, sizeof(buf)));
discarded += got;
+ n -= got;
if(got == 0)
break;