File 0001-Added-bounds-check-to-CDataList-in-JWW-parser.patch of Package librecad.17497

From 4edcbe72679f95cb60979c77a348c1522a20b0f4 Mon Sep 17 00:00:00 2001
From: eldstal <laeder.keps@gmail.com>
Date: Sat, 18 Dec 2021 23:55:22 +0100
Subject: [PATCH] Added bounds check to CDataList in JWW parser

This fixes issue #1464
---
 libraries/jwwlib/src/jwwdoc.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libraries/jwwlib/src/jwwdoc.h b/libraries/jwwlib/src/jwwdoc.h
index fc8cd217..7ccf2d83 100644
--- a/libraries/jwwlib/src/jwwdoc.h
+++ b/libraries/jwwlib/src/jwwdoc.h
@@ -793,7 +793,17 @@ cout << "MojiData1:"  << m_strName << endl;
 		}else
 		{
 			ifstr >> wd;
+
+			jwDWORD skip = 0;
+			if (wd > 511) {
+				skip = wd - 511;
+				wd = 511;
+			}
+
 			ifstr.read(buf,wd);
+
+			if (skip != 0) ifstr.ignore(skip);
+
 			buf[wd] = '\0';
 			m_strName = buf;
 #ifdef	DATA_DUMP
-- 
2.36.1

openSUSE Build Service is sponsored by