[frameworks/kfilemetadata] src/extractors: Fix overflow in extractAudioProperties

Albert Astals Cid <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit c7dc23d11faddb45d074111da83ead57da4ff649 by Albert Astals Cid.
Committed on 31/07/2026 at 22:36.
Pushed by aacid into branch 'master'.

Fix overflow in extractAudioProperties

M  +5    -2    src/extractors/taglibextractor.cpp

https://invent.kde.org/frameworks/kfilemetadata/-/commit/c7dc23d11faddb45d074111da83ead57da4ff649

diff --git a/src/extractors/taglibextractor.cpp b/src/extractors/taglibextractor.cpp
index f97f8ccd..17a56ef4 100644
--- a/src/extractors/taglibextractor.cpp
+++ b/src/extractors/taglibextractor.cpp
@@ -41,6 +41,8 @@
 #include <popularimeterframe.h>
 #include <attachedpictureframe.h>
 
+#include <limits>
+
 using namespace KFileMetaData;
 
 namespace {
@@ -80,8 +82,9 @@ void extractAudioProperties(TagLib::File* file, ExtractionResult* result)
             result->add(Property::Duration, audioProp->lengthInSeconds());
         }
 
-        if (audioProp->bitrate()) {
-            result->add(Property::BitRate, audioProp->bitrate() * 1000);
+        const int bitRate = audioProp->bitrate();
+        if (bitRate > 0 && bitRate <= std::numeric_limits<int>::max() / 1000) {
+            result->add(Property::BitRate, bitRate * 1000);
         }
 
         if (audioProp->channels()) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.