From d881a7bbb1562af383bbb6ca20340ad739fb0d13 Mon Sep 17 00:00:00 2001 From: Mirco Miranda Date: Tue, 20 Sep 2022 19:44:08 +0200 Subject: [PATCH] LibRaw_QIODevice::seek() bounding checks --- src/imageformats/raw.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/imageformats/raw.cpp b/src/imageformats/raw.cpp index 276d004..5e92fad 100644 --- a/src/imageformats/raw.cpp +++ b/src/imageformats/raw.cpp @@ -131,11 +131,15 @@ public: virtual int seek(INT64 o, int whence) override { auto pos = o; + auto size = m_device->size(); if (whence == SEEK_CUR) { pos = m_device->pos() + o; } if (whence == SEEK_END) { - pos = m_device->size() + o; + pos = size + o; + } + if (pos < 0 || pos > size) { + return -1; } return m_device->seek(pos) ? 0 : -1; }