fofi/FoFiIdentifier.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
New commits: commit 07318f3899248f67a58148b29a9555ff47a1b083 Author: Albert Astals Cid <aa...@kde.org> Date: Thu May 24 20:15:42 2018 +0200 StreamReader::cmp: Fix potential undefined behaviour going outside an array range is technically undefined behaviour, even if then after you go back in range with the next operation, so we first calculate the diff and then add it to the array diff --git a/fofi/FoFiIdentifier.cc b/fofi/FoFiIdentifier.cc index 3d41145b..ffe9c47c 100644 --- a/fofi/FoFiIdentifier.cc +++ b/fofi/FoFiIdentifier.cc @@ -378,13 +378,12 @@ GBool StreamReader::getUVarBE(int pos, int size, Guint *val) { } GBool StreamReader::cmp(int pos, const char *s) { - int n; - - n = (int)strlen(s); + const int n = (int)strlen(s); if (!fillBuf(pos, n)) { return gFalse; } - return !memcmp(buf - bufPos + pos, s, n); + const int posDiff = pos - bufPos; + return !memcmp(buf + posDiff, s, n); } GBool StreamReader::fillBuf(int pos, int len) { _______________________________________________ poppler mailing list poppler@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/poppler