From f03739f222139fc6602f5c6139b045fa9ec73902 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sat, 14 Dec 2019 21:04:46 +0100 Subject: [PATCH] pic: Fix Invalid-enum-value undefined behaviour Summary: Instead of directly casting the quint8 to PicChannelEncoding we just store the quint8 and compare it to the possible PicChannelEncoding values when needed oss-fuzz/19344 Reviewers: dfaure Reviewed By: dfaure Subscribers: dfaure, security-team, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D25937 --- src/imageformats/pic.cpp | 4 +--- src/imageformats/pic_p.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/imageformats/pic.cpp b/src/imageformats/pic.cpp index c901e31..22bd8b4 100644 --- a/src/imageformats/pic.cpp +++ b/src/imageformats/pic.cpp @@ -130,9 +130,7 @@ static QDataStream &operator>> (QDataStream &s, QList &channels) PicChannel channel; s >> chained; s >> channel.size; - quint8 encoding; - s >> encoding; - channel.encoding = PicChannelEncoding(encoding); + s >> channel.encoding; s >> channel.code; channels << channel; ++count; diff --git a/src/imageformats/pic_p.h b/src/imageformats/pic_p.h index b8ea054..ed9dc8b 100644 --- a/src/imageformats/pic_p.h +++ b/src/imageformats/pic_p.h @@ -119,7 +119,7 @@ struct PicHeader { */ struct PicChannel { quint8 size; /**< Bits per component per pixel. */ - PicChannelEncoding encoding; /**< How the channel's data is encoded. */ + quint8 encoding; /**< How the channel's data is encoded. */ quint8 code; /**< Flag field to describe which components are encoded in this channel. */