From 6c1bdd15d6fabcc595c0fefdb9994800f21cf07d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 24 May 2023 15:16:14 +0000 Subject: More size protection for winDde --- win/tclWinDde.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/win/tclWinDde.c b/win/tclWinDde.c index 697aae6..3377bfa 100644 --- a/win/tclWinDde.c +++ b/win/tclWinDde.c @@ -313,12 +313,12 @@ DdeSetServerName( Tcl_Obj *handlerPtr) /* Name of the optional proc/command to handle * incoming Dde eval's */ { - int suffix, offset; + int suffix; RegisteredInterp *riPtr, *prevPtr; Tcl_DString dString; const WCHAR *actualName; Tcl_Obj *srvListPtr = NULL, **srvPtrPtr = NULL; - Tcl_Size n, srvCount = 0; + Tcl_Size n, srvCount = 0, offset; int lastSuffix, r = TCL_OK; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); @@ -942,8 +942,8 @@ DdeServerProc( */ HSZPAIR *returnPtr; - int i; - int numItems; + Tcl_Size i; + DWORD numItems; for (i = 0, riPtr = tsdPtr->interpListPtr; riPtr != NULL; i++, riPtr = riPtr->nextPtr) { @@ -952,12 +952,15 @@ DdeServerProc( */ } - numItems = i; + if ((size_t)i >= UINT_MAX/sizeof(HSZPAIR)) { + return NULL; + } + numItems = (DWORD)i; ddeReturn = DdeCreateDataHandle(ddeInstance, NULL, - (numItems + 1) * sizeof(HSZPAIR), 0, 0, 0, 0); + (numItems + 1) * (DWORD)sizeof(HSZPAIR), 0, 0, 0, 0); returnPtr = (HSZPAIR *) DdeAccessData(ddeReturn, &dlen); len = dlen; - for (i = 0, riPtr = tsdPtr->interpListPtr; i < numItems; + for (i = 0, riPtr = tsdPtr->interpListPtr; i < (Tcl_Size)numItems; i++, riPtr = riPtr->nextPtr) { returnPtr[i].hszSvc = DdeCreateStringHandleW(ddeInstance, TCL_DDE_SERVICE_NAME, CP_WINUNICODE); @@ -1645,7 +1648,7 @@ DdeObjCmd( if ((tmp >= sizeof(WCHAR)) && !dataString[tmp / sizeof(WCHAR) - 1]) { - tmp -= sizeof(WCHAR); + tmp -= (DWORD)sizeof(WCHAR); } Tcl_DStringInit(&dsBuf); Tcl_WCharToUtfDString(dataString, tmp>>1, &dsBuf); -- cgit v0.12 From c7771a763e2451560f1667170fba99a679e1e9eb Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 24 May 2023 15:18:05 +0000 Subject: =?UTF-8?q?Enhance=20html=20generation,=20so=20it=20can=20handle?= =?UTF-8?q?=20the=20"=C2=A9"=20copy-sign=20as=20well?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/tcltk-man2html-utils.tcl | 2 +- tools/tcltk-man2html.tcl | 2 +- unix/Makefile.in | 2 +- win/Makefile.in | 2 +- win/makefile.vc | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/tcltk-man2html-utils.tcl b/tools/tcltk-man2html-utils.tcl index 78aa8ec..63e1fb9 100644 --- a/tools/tcltk-man2html-utils.tcl +++ b/tools/tcltk-man2html-utils.tcl @@ -1271,7 +1271,7 @@ proc output-directive {line} { ## proc merge-copyrights {l1 l2} { set merge {} - set re1 {^Copyright +(?:\(c\)|\\\(co|©) +(\w.*?)(?:all rights reserved)?(?:\. )*$} + set re1 {^Copyright +(?:\(c\)|\\\(©|co|©) +(\w.*?)(?:all rights reserved)?(?:\. )*$} set re2 {^(\d+) +(?:by +)?(\w.*)$} ;# date who set re3 {^(\d+)-(\d+) +(?:by +)?(\w.*)$} ;# from to who set re4 {^(\d+), *(\d+) +(?:by +)?(\w.*)$} ;# date1 date2 who diff --git a/tools/tcltk-man2html.tcl b/tools/tcltk-man2html.tcl index 5f211f3..2b35bd8 100755 --- a/tools/tcltk-man2html.tcl +++ b/tools/tcltk-man2html.tcl @@ -29,7 +29,7 @@ set ::CSSFILE "docs.css" ## Source the utility functions that provide most of the ## implementation of the transformation from nroff to html. ## -source [file join [file dirname [info script]] tcltk-man2html-utils.tcl] +source -encoding utf-8 [file join [file dirname [info script]] tcltk-man2html-utils.tcl] proc getversion {tclh {name {}}} { if {[file exists $tclh]} { diff --git a/unix/Makefile.in b/unix/Makefile.in index 802472b..996cd30 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -2424,7 +2424,7 @@ html-tk: ${NATIVE_TCLSH} @EXTRA_BUILD_HTML@ BUILD_HTML = \ - @${NATIVE_TCLSH} $(TOOL_DIR)/tcltk-man2html.tcl \ + @${NATIVE_TCLSH} -encoding utf-8 $(TOOL_DIR)/tcltk-man2html.tcl \ --useversion=$(MAJOR_VERSION).$(MINOR_VERSION) \ --htmldir="$(HTML_INSTALL_DIR)" \ --srcdir=$(TOP_DIR) $(BUILD_HTML_FLAGS) diff --git a/win/Makefile.in b/win/Makefile.in index 6c92749..b282452 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -974,7 +974,7 @@ runtest: tcltest # `make shell SCRIPT=foo.tcl` shell: binaries @TCL_LIBRARY="$(LIBRARY_DIR)"; export TCL_LIBRARY; \ - $(WINE) ./$(TCLSH) $(SCRIPT) + $(WINE) ./$(TCLSH) -encoding utf-8 $(SCRIPT) # This target can be used to run tclsh inside either gdb or insight gdb: binaries diff --git a/win/makefile.vc b/win/makefile.vc index d1f4ef3..b1a8b6a 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -676,7 +676,7 @@ CHMFILE=$(HTMLDIR)\$(HTMLBASE).chm htmlhelp: chmsetup $(CHMFILE) $(CHMFILE): $(DOCDIR)\* - @$(TCLSH) $(TOOLSDIR)\tcltk-man2html.tcl "--htmldir=$(HTMLDIR)" + @$(TCLSH) -encoding utf-8 $(TOOLSDIR)\tcltk-man2html.tcl "--htmldir=$(HTMLDIR)" @echo Compiling HTML help project -"$(HHC)" <<$(HHPFILE) >NUL [OPTIONS] -- cgit v0.12 From 70a3d08fc4eb639c20c5613ea5952a0dfdd5e935 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 24 May 2023 15:22:00 +0000 Subject: Fix regular expression in previous commit --- tools/tcltk-man2html-utils.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/tcltk-man2html-utils.tcl b/tools/tcltk-man2html-utils.tcl index 63e1fb9..c658d71 100644 --- a/tools/tcltk-man2html-utils.tcl +++ b/tools/tcltk-man2html-utils.tcl @@ -1271,7 +1271,7 @@ proc output-directive {line} { ## proc merge-copyrights {l1 l2} { set merge {} - set re1 {^Copyright +(?:\(c\)|\\\(©|co|©) +(\w.*?)(?:all rights reserved)?(?:\. )*$} + set re1 {^Copyright +(?:\(c\)|\\\(co|©|©) +(\w.*?)(?:all rights reserved)?(?:\. )*$} set re2 {^(\d+) +(?:by +)?(\w.*)$} ;# date who set re3 {^(\d+)-(\d+) +(?:by +)?(\w.*)$} ;# from to who set re4 {^(\d+), *(\d+) +(?:by +)?(\w.*)$} ;# date1 date2 who -- cgit v0.12