git: ca5d9506c410 - main - net/tigervnc-viewer: Apply a fix for ZRLE exception

From: Koichiro Iwao <meta_at_FreeBSD.org>
Date: Wed, 28 Aug 2024 02:28:17 UTC
The branch main has been updated by meta:

URL: https://cgit.FreeBSD.org/ports/commit/?id=ca5d9506c4108b8c4e26e93833c3f79c1ea4319c

commit ca5d9506c4108b8c4e26e93833c3f79c1ea4319c
Author:     Koichiro Iwao <meta@FreeBSD.org>
AuthorDate: 2024-08-28 02:18:18 +0000
Commit:     Koichiro Iwao <meta@FreeBSD.org>
CommitDate: 2024-08-28 02:21:06 +0000

    net/tigervnc-viewer: Apply a fix for ZRLE exception
    
    Reported by:    Keith White <Keith.White@uottawa.ca>
    Obtained from:  https://github.com/TigerVNC/tigervnc/issues/1809
---
 .../files/patch-common_rfb_ZRLEDecoder.cxx                | 15 +++++++++++++++
 net/tigervnc-viewer/Makefile                              |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/net/tigervnc-server/files/patch-common_rfb_ZRLEDecoder.cxx b/net/tigervnc-server/files/patch-common_rfb_ZRLEDecoder.cxx
new file mode 100644
index 000000000000..bd97820b5fb7
--- /dev/null
+++ b/net/tigervnc-server/files/patch-common_rfb_ZRLEDecoder.cxx
@@ -0,0 +1,15 @@
+--- common/rfb/ZRLEDecoder.cxx.orig	2024-07-23 08:50:25 UTC
++++ common/rfb/ZRLEDecoder.cxx
+@@ -126,10 +126,10 @@ void ZRLEDecoder::zrleDecode(const Rect& r, rdr::InStr
+   Pixel maxPixel = pf.pixelFromRGB((uint16_t)-1, (uint16_t)-1, (uint16_t)-1);
+   bool fitsInLS3Bytes = maxPixel < (1<<24);
+   bool fitsInMS3Bytes = (maxPixel & 0xff) == 0;
+-  bool isLowCPixel = (sizeof(T) == 4) &&
++  bool isLowCPixel = (sizeof(T) == 4) && (pf.depth <= 24) &&
+                      ((fitsInLS3Bytes && pf.isLittleEndian()) ||
+                       (fitsInMS3Bytes && pf.isBigEndian()));
+-  bool isHighCPixel = (sizeof(T) == 4) &&
++  bool isHighCPixel = (sizeof(T) == 4) && (pf.depth <= 24) &&
+                       ((fitsInLS3Bytes && pf.isBigEndian()) ||
+                        (fitsInMS3Bytes && pf.isLittleEndian()));
+ 
diff --git a/net/tigervnc-viewer/Makefile b/net/tigervnc-viewer/Makefile
index e9161161ec94..5d9644cec68a 100644
--- a/net/tigervnc-viewer/Makefile
+++ b/net/tigervnc-viewer/Makefile
@@ -1,5 +1,6 @@
 PKGNAMESUFFIX=	-viewer
 CATEGORIES=	net
+PORTREVISION=	1
 
 COMMENT=	TigerVNC Viewer
 WWW=		https://tigervnc.org/
@@ -33,4 +34,5 @@ post-patch:
 		${WRKSRC}/CMakeLists.txt
 
 MASTERDIR=	${.CURDIR}/../tigervnc-server
+
 .include "${MASTERDIR}/Makefile.common.mk"