I discovered wdiff the other day thanks to falsifian, but it has a bad
habit of crashing repeatedly.
The TL;DR (and you're really better off not reading the sources) is
that it malloc(0) and then passes the pointer to tgetstr() where it
crashes due to a write attempt.
Here's a way to address it. To try, both before and after the fix, try
$ {got,git,cvs,rcsdiff,whatever} diff | wdiff -ad
still in doubt if it's useful to waste spaces on the mirrors for a
debug package for this.
ok?
Index: Makefile
===================================================================
RCS file: /home/cvs/ports/textproc/wdiff/Makefile,v
retrieving revision 1.37
diff -u -p -r1.37 Makefile
--- Makefile 11 Mar 2022 20:03:35 -0000 1.37
+++ Makefile 17 May 2023 16:54:43 -0000
@@ -4,7 +4,7 @@ DISTNAME= wdiff-1.2.2
CATEGORIES= textproc
HOMEPAGE= https://www.gnu.org/software/wdiff
MASTER_SITES= ${MASTER_SITE_GNU:=wdiff/}
-REVISION= 3
+REVISION= 4
# GPLv3+
PERMIT_PACKAGE= Yes
@@ -16,5 +16,7 @@ TEST_DEPENDS= misc/screen
CONFIGURE_STYLE= gnu
CONFIGURE_ARGS= --prefix="${PREFIX}"
USE_GMAKE= Yes
+
+DEBUG_PACKAGES= ${BUILD_PACKAGES}
.include <bsd.port.mk>
Index: patches/patch-lib_Makefile_in
===================================================================
RCS file: /home/cvs/ports/textproc/wdiff/patches/patch-lib_Makefile_in,v
retrieving revision 1.5
diff -u -p -r1.5 patch-lib_Makefile_in
--- patches/patch-lib_Makefile_in 11 Mar 2022 20:03:35 -0000 1.5
+++ patches/patch-lib_Makefile_in 17 May 2023 15:32:33 -0000
@@ -1,9 +1,10 @@
Do not install charset.alias, which is already provided by
converters/libiconv
---- lib/Makefile.in.orig Wed May 30 22:31:33 2012
-+++ lib/Makefile.in Tue Feb 5 22:12:25 2013
-@@ -1673,7 +1673,7 @@ install-exec-localcharset: all-local
+Index: lib/Makefile.in
+--- lib/Makefile.in.orig
++++ lib/Makefile.in
+@@ -1777,7 +1777,7 @@ install-exec-localcharset: all-local
case '$(host_os)' in \
darwin[56]*) \
need_charset_alias=true ;; \
Index: patches/patch-src_wdiff_c
===================================================================
RCS file: patches/patch-src_wdiff_c
diff -N patches/patch-src_wdiff_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_wdiff_c 17 May 2023 16:33:03 -0000
@@ -0,0 +1,28 @@
+avoid crashing, if possible.
+
+if strlen(term_buffer) is zero, which it is, it later tries to write
+into it... Also, that malloc should have been a calloc really...
+
+Index: src/wdiff.c
+--- src/wdiff.c.orig
++++ src/wdiff.c
+@@ -218,7 +218,6 @@ initialize_strings (void)
+ {
+ const char *name; /* terminal capability name */
+ char term_buffer[2048]; /* terminal description */
+- static char *buffer; /* buffer for capabilities */
+ char *filler; /* cursor into allocated strings */
+ int success; /* tgetent results */
+
+@@ -231,8 +230,9 @@ initialize_strings (void)
+ error (EXIT_ERROR, 0, _("could not access the termcap data base"));
+ if (success == 0)
+ error (EXIT_ERROR, 0, _("terminal type `%s' is not defined"), name);
+- buffer = (char *) malloc (strlen (term_buffer));
+- filler = buffer;
++
++ memset (&term_buffer, 0, sizeof (term_buffer));
++ filler = term_buffer;
+
+ term_delete_start = tgetstr ("us", &filler);
+ term_delete_end = tgetstr ("ue", &filler);