From 94186afe3e7be64c56fbc43d2b1ce1760089e30d Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Sun, 2 Feb 2020 21:26:35 +0100 Subject: [PATCH] pictureviewer: fix possible integer_overflow Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/eba5864fb220b614f12cc90b55852eb2946752f9 Author: Jacek Jendrzej Date: 2020-02-02 (Sun, 02 Feb 2020) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/driver/pictureviewer/pictureviewer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/driver/pictureviewer/pictureviewer.cpp b/src/driver/pictureviewer/pictureviewer.cpp index 27871f67c..acf2014b5 100644 --- a/src/driver/pictureviewer/pictureviewer.cpp +++ b/src/driver/pictureviewer/pictureviewer.cpp @@ -902,7 +902,11 @@ unsigned char * CPictureViewer::int_Resize(unsigned char *orgin, int ox, int oy, unsigned char * cr; if(dst == NULL) { - size_t bufsize = dx * dy * ((alpha) ? 4 : 3); + int ai = ((alpha) ? 4 : 3); + if (dy <= 1 || dx <= 1 || (dx *ai > INT_MAX / dy)) + return orgin; + + size_t bufsize = dx * dy * ai; if (!checkfreemem(bufsize)){ return orgin; }