code:
From: Tobias Geerinckx-Rice <me@tobias.gr>
Date: Tue, 01 Sep 2020 04:23:25 +0200
Subject: [PATCH] Update bpaste URL & regular expressions.

diff -Naur wgetpaste-2.30/wgetpaste wgetpaste-2.30a/wgetpaste
--- wgetpaste-2.30/wgetpaste	2020-07-31 23:56:05.000000000 +0200
+++ wgetpaste-2.30a/wgetpaste	2020-09-01 04:22:37.499898403 +0200
@@ -16,7 +16,7 @@
 SERVICES="codepad bpaste dpaste gists snippets"
 # bpaste
 ENGINE_bpaste=pinnwand
-URL_bpaste="https://bpaste.net/"
+URL_bpaste="https://bpa.st/"
 DEFAULT_EXPIRATION_bpaste="1week"
 DEFAULT_LANGUAGE_bpaste="text"
 # codepad
@@ -194,8 +194,8 @@
 xml+velocity xml xquery xslt xtend yaml"
 EXPIRATIONS_pinnwand="1day 1week 1month never"
 POST_pinnwand="submit=Paste! % % lexer expiry % code"
-REGEX_LOC_pinnwand="\(/show/[^ ]*\).*$|https://bpaste.net\1"
-REGEX_RAW_pinnwand='s|^\(https\?://[^/]*/\)show\(/[^ ]*/\?\)$|\1raw\2|'
+REGEX_LOC_pinnwand="\(/[^ ]*\).*$|https://bpa.st\1"
+REGEX_RAW_pinnwand='s|^\(https\?://[^/]*\)\(/[^ ]*/\?\)$|\1/raw\2|'

 ### errors
 die() {


code:
Fix copied from https://bugs.launchpad.net/wicd/+bug/1432423/comments/1

--- wicd-1.7.3/curses/netentry_curses.py	1969-12-31 19:00:00.000000000 -0500
+++ wicd-1.7.3/curses/netentry_curses.py	2015-08-11 23:26:19.999999649 -0400
@@ -538,11 +538,16 @@
         self.bitrates = wireless.GetAvailableBitrates()
         self.bitrates.append('auto')
         self.bitrate_combo.set_list(self.bitrates)
+
+        # bitrate property is sometimes None
+        chosen_bitrate = wireless.GetWirelessProperty(networkID, 'bitrate')
+        if chosen_bitrate not in self.bitrates:
+            chosen_bitrate = 'auto'
+
         self.bitrate_combo.set_focus(
-            self.bitrates.index(
-                wireless.GetWirelessProperty(networkID, 'bitrate')
-            )
+            self.bitrates.index(chosen_bitrate)
         )
+
         self.allow_lower_bitrates_chkbox.set_state(
             to_bool(self.format_entry(networkID, 'allow_lower_bitrates'))
         )

license: mit


code:
Fix copied from https://bugs.launchpad.net/wicd/+bug/1421918/comments/2

--- wicd-1.7.3/curses/wicd-curses.py	2014-12-21 16:57:33 +0000
+++ wicd-1.7.3/curses/wicd-curses.py	2015-02-24 23:41:01 +0000
@@ -532,7 +532,10 @@
     def get_selected_profile(self):
         """Get the selected wired profile"""
         loc = self.get_focus()[1]
-        return self.theList[loc]
+        if len(self.theList) > loc:
+            return self.theList[loc]
+        else:
+            return self.theList[-1]

 class AdHocDialog(Dialog2):


code:
Update the wicd-curses client to work with urwid-1.3.  Based on a patch from:
http://technik.blogbasis.net/wicd-curses-fix-fuer-attributeerror-screen-object-no-attribute-get_input_nonblocking-04-12-2014

--- wicd-1.7.3/curses/wicd-curses.py.orig	2014-12-21 14:40:46.000000000 -0500
+++ wicd-1.7.3/curses/wicd-curses.py	2015-02-05 23:41:17.530901204 -0500
@@ -1153,9 +1153,10 @@
         if not ui._started:
             return False

-        input_data = ui.get_input_nonblocking()
+        ui.set_input_timeouts(max_wait=0)
+        input_data = ui.get_input()
         # Resolve any "alarms" in the waiting
-        self.handle_keys(input_data[1])
+        self.handle_keys(input_data)

         # Update the screen
         canvas = self.frame.render((self.size), True)


code:
Add a template for WPA2-TTLS, which is notably used by Eduroam.

--- a/encryption/templates/active
+++ b/encryption/templates/active
@@ -4,6 +4,7 @@ wpa-psk
 wpa-psk-hex
 wpa2-leap
 wpa2-peap
+wpa2-ttls
 wep-hex
 wep-passphrase
 wep-shared
diff --git a/encryption/templates/wpa2-ttls b/encryption/templates/wpa2-ttls
new file mode 100644
index 0000000..4f66a1e
--- /dev/null
+++ b/encryption/templates/wpa2-ttls
@@ -0,0 +1,20 @@
+name = WPA2-TTLS (used notably by Eduroam)
+author = various contributors
+version = 1
+require identity *Identity anonymous_identity *Anonymous_identity password *Password ca_cert *Path_to_CA_Cert
+protected password *Password
+-----
+ctrl_interface=/var/run/wpa_supplicant
+network={
+        ssid="$_ESSID"
+        scan_ssid=$_SCAN
+        proto=WPA2
+        key_mgmt=WPA-EAP
+        group=CCMP TKIP
+        eap=TTLS
+        identity="$_IDENTITY"
+        password="$_PASSWORD"
+        anonymous_identity="$_ANONYMOUS_IDENTITY"
+        ca_cert="$_CA_CERT"
+        phase2="auth=PAP"
+}


code:
Description: use the system-wide minizip instead of the embeeded one if found.
Forwarded-Upstream: It was provided by upstream: http://bazaar.launchpad.net/~widelands-dev/widelands/b19-debian/revision/8147
 .
 Thanks to Fòram na Gàidhlig for the patch.

I just added this line to make its use easier:
  set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/Modules)

=== modified file 'CMakeLists.txt'
---
 CMakeLists.txt                     |    3 +++
 Modules/FindMinizip.cmake          |   37 +++++++++++++++++++++++++++++++++++++
 cmake/WlFunctions.cmake            |    7 +++++++
 src/io/CMakeLists.txt              |    2 +-
 src/third_party/CMakeLists.txt     |   20 +++++++++++---------
 src/third_party/minizip/README.txt |    4 ++++
 6 files changed, 63 insertions(+), 10 deletions(-)

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -43,6 +43,7 @@
 endif(POLICY CMP0074)

 include("${CMAKE_SOURCE_DIR}/cmake/WlFunctions.cmake")
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_HOME_DIRECTORY}/Modules)

 option(OPTION_USE_GLBINDING "Use glbinding instead of GLEW" OFF)
 option(OPTION_GLEW_STATIC "Use static GLEW Library" OFF)
@@ -105,6 +106,8 @@
 find_package(SDL2_ttf REQUIRED)
 find_package(ZLIB REQUIRED)
 find_package(ICU REQUIRED)
+find_package(Minizip)
+
 if(OPTION_USE_GLBINDING)
   find_package(glbinding REQUIRED)
 else()
--- /dev/null
+++ b/Modules/FindMinizip.cmake
@@ -0,0 +1,37 @@
+# - Try to find Minizip
+# Once done this will define
+#
+#  MINIZIP_FOUND        - system has MINIZIP
+#  MINIZIP_INCLUDE_DIR  - the MINIZIP include directory
+#  MINIZIP_LIBRARY_DIR  - where the libraries are
+#  MINIZIP_LIBRARY      - Link these to use MINIZIP
+#
+
+IF (MINIZIP_INCLUDE_DIR)
+  # Already in cache, be silent
+  SET(MINIZIP_FIND_QUIETLY TRUE)
+ENDIF (MINIZIP_INCLUDE_DIR)
+
+FIND_PATH( MINIZIP_INCLUDE_DIR
+	  NAMES zip.h unzip.h ioapi.h
+	  PATHS /usr/local/include /usr/include
+	  PATH_SUFFIXES minizip/ )
+SET( MINIZIP_NAMES minizip MINIZIP )
+FIND_LIBRARY( MINIZIP_LIBRARY
+	      NAMES ${MINIZIP_NAMES}
+	      PATHS /usr/lib /usr/local/lib )
+
+GET_FILENAME_COMPONENT( MINIZIP_LIBRARY_DIR ${MINIZIP_LIBRARY} PATH )
+
+IF (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+   SET(MINIZIP_FOUND TRUE)
+   SET(MINIZIP_LIBRARY_DIR ${MINIZIP_LIBRARY} )
+   IF (NOT MINIZIP_FIND_QUIETLY)
+     MESSAGE (STATUS "Found Minizip: ${MINIZIP_LIBRARY} ${MINIZIP_INCLUDE_DIR}")
+   ENDIF (NOT MINIZIP_FIND_QUIETLY)
+ELSE (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+   SET( MINIZIP_FOUND FALSE )
+   SET( MINIZIP_LIBRARY_DIR )
+   SET( MINIZIP_EXTRA_DEFINITIONS )
+ENDIF (MINIZIP_INCLUDE_DIR AND MINIZIP_LIBRARY)
+
--- a/cmake/WlFunctions.cmake
+++ b/cmake/WlFunctions.cmake
@@ -81,6 +81,14 @@
   if(ARG_USES_ZLIB)
     wl_include_system_directories(${NAME} ${ZLIB_INCLUDE_DIRS})
     target_link_libraries(${NAME} ${ZLIB_LIBRARY})
+    if (MINIZIP_FOUND)
+      wl_include_system_directories(${NAME}  ${MINIZIP_INCLUDE_DIR})
+      target_link_libraries(${NAME}  ${MINIZIP_LIBRARY})
+      target_compile_definitions(${NAME} PUBLIC -DHAVE_SYSTEM_MINIZIP)
+    else(MINIZIP_FOUND)
+      target_link_libraries(${NAME}  third_party_minizip)
+      message(FATAL_ERROR "You are using widelands-bundled minizip sources. Please install your distribution's minizip dev library or urge your distribution maintainer to include the minizip library in your package repository. Thank you.")
+    endif(MINIZIP_FOUND)
   endif()

   # OpenGL and GLEW are one thing for us. If you use the one, you also use the
--- a/src/third_party/CMakeLists.txt
+++ b/src/third_party/CMakeLists.txt
@@ -1,12 +1,14 @@
-wl_library(third_party_minizip
-  THIRD_PARTY
-  SRCS
-    minizip/ioapi.h
-    minizip/unzip.cc
-    minizip/unzip.h
-    minizip/zip.h
-  USES_ZLIB
-)
+if(NOT MINIZIP_FOUND)
+  wl_library(third_party_minizip
+    THIRD_PARTY
+    SRCS
+      ioapi.h
+      unzip.cc
+      unzip.h
+      zip.h
+    USES_ZLIB
+  )
+endif(NOT MINIZIP_FOUND)

 wl_library(third_party_eris
   THIRD_PARTY
--- a/src/io/filesystem/CMakeLists.txt
+++ b/src/io/filesystem/CMakeLists.txt
@@ -12,6 +12,7 @@
     zip_exceptions.h
     zip_filesystem.cc
     zip_filesystem.h
+  USES_ZLIB
   DEPENDS
     base_exceptions
     base_i18n
@@ -19,5 +20,4 @@
     base_macros
     graphic_text_layout
     io_stream
-    third_party_minizip
 )
--- a/src/io/filesystem/zip_filesystem.h
+++ b/src/io/filesystem/zip_filesystem.h
@@ -28,8 +28,14 @@
 #include "io/filesystem/filesystem.h"
 #include "io/streamread.h"
 #include "io/streamwrite.h"
+
+#ifndef HAVE_SYSTEM_MINIZIP
 #include "third_party/minizip/unzip.h"
 #include "third_party/minizip/zip.h"
+#else
+#include <minizip/unzip.h>
+#include <minizip/zip.h>
+#endif

 class ZipFilesystem : public FileSystem {
 public:


code:
Description: Correct 64 Architecture implementation of 32 bit data
Author: Chris Donoghue <cdonoghu@gmail.com>
Bug-Debian: http://bugs.debian.org/362068

--- wmctrl-1.07.orig/main.c
+++ wmctrl-1.07/main.c
@@ -1425,6 +1425,16 @@ static gchar *get_property (Display *dis
      *
      * long_length = Specifies the length in 32-bit multiples of the
      *               data to be retrieved.
+     *
+     * NOTE:  see
+     * http://mail.gnome.org/archives/wm-spec-list/2003-March/msg00067.html
+     * In particular:
+     *
+     * 	When the X window system was ported to 64-bit architectures, a
+     * rather peculiar design decision was made. 32-bit quantities such
+     * as Window IDs, atoms, etc, were kept as longs in the client side
+     * APIs, even when long was changed to 64 bits.
+     *
      */
     if (XGetWindowProperty(disp, win, xa_prop_name, 0, MAX_PROPERTY_VALUE_LEN / 4, False,
             xa_prop_type, &xa_ret_type, &ret_format,
@@ -1441,6 +1451,8 @@ static gchar *get_property (Display *dis

     /* null terminate the result to make string handling easier */
     tmp_size = (ret_format / 8) * ret_nitems;
+    /* Correct 64 Architecture implementation of 32 bit data */
+    if(ret_format==32) tmp_size *= sizeof(long)/4;
     ret = g_malloc(tmp_size + 1);
     memcpy(ret, ret_prop, tmp_size);
     ret[tmp_size] = '\0';


code:
This patch comes from Debian and was modified by Kei Kebreau <kkebreau@posteo.net>.
Link: https://anonscm.debian.org/cgit/pkg-wmaker/wmfire.git/plain/debian/patches/gdk_updates.patch?h=debian/1.2.4-2&id=a272234fc5eecdbfc469adb12133196bc62f3059

Description: Update for newer versions of GDK.
 In particular, the icon window was not receiving enter and leave events from
 the pointer.  To fix this, we get rid of the second GdkWindow iconwin entirely
 and set win to be its own icon.
 .
 This also removes the need for the "broken window manager" fix, so we remove it
 and all references to it.
Author: Doug Torrance <dtorrance@piedmont.edu>

diff -ur wmfire-1.2.4.old/src/wmfire.c wmfire-1.2.4/src/wmfire.c
--- wmfire-1.2.4.old/src/wmfire.c	2017-04-23 14:26:58.449487117 -0400
+++ wmfire-1.2.4/src/wmfire.c	2017-04-23 14:32:10.785238671 -0400
@@ -77,7 +77,6 @@
 typedef struct {
 	Display *display;	/* X11 display */
 	GdkWindow *win;		/* Main window */
-	GdkWindow *iconwin;	/* Icon window */
 	GdkGC *gc;		/* Drawing GC */
 	GdkPixmap *pixmap;	/* Main pixmap */
 	GdkBitmap *mask;	/* Dockapp mask */
@@ -141,7 +140,6 @@
 int cmap = 0;
 int lock = 0;
 int proximity = 0;
-int broken_wm = 0;

 /******************************************/
 /* Main                                   */
@@ -262,12 +260,8 @@
 		usleep(REFRESH);

 		/* Draw the rgb buffer to screen */
-		if (!broken_wm)
-			gdk_draw_rgb_image(bm.iconwin, bm.gc, 4, 4, XMAX, YMAX, GDK_RGB_DITHER_NONE, bm.rgb, XMAX * 3);
-		else
-			gdk_draw_rgb_image(bm.win, bm.gc, 4, 4, XMAX, YMAX, GDK_RGB_DITHER_NONE, bm.rgb, XMAX * 3);
+                gdk_draw_rgb_image(bm.win, bm.gc, 4, 4, XMAX, YMAX, GDK_RGB_DITHER_NONE, bm.rgb, XMAX * 3);
 	}
-
 	return 0;
 }

@@ -556,9 +550,7 @@
 #define MASK GDK_BUTTON_PRESS_MASK | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_HINT_MASK

 	GdkWindowAttr attr;
-	GdkWindowAttr attri;
 	Window win;
-	Window iconwin;

 	GdkPixmap *icon;

@@ -578,10 +570,6 @@
 	attr.wmclass_class = "wmfire";
 	attr.window_type = GDK_WINDOW_TOPLEVEL;

-	/* Make a copy for the iconwin - parameters are the same */
-	memcpy(&attri, &attr, sizeof (GdkWindowAttr));
-	attri.window_type = GDK_WINDOW_CHILD;
-
 	sizehints.flags = USSize;
 	sizehints.width = 64;
 	sizehints.height = 64;
@@ -592,18 +580,11 @@
 		exit(1);
 	}

-	bm.iconwin = gdk_window_new(bm.win, &attri, GDK_WA_TITLE | GDK_WA_WMCLASS);
-	if (!bm.iconwin) {
-		fprintf(stderr, "FATAL: Cannot make icon window\n");
-		exit(1);
-	}
-
 	win = GDK_WINDOW_XWINDOW(bm.win);
-	iconwin = GDK_WINDOW_XWINDOW(bm.iconwin);
 	XSetWMNormalHints(GDK_WINDOW_XDISPLAY(bm.win), win, &sizehints);

 	wmhints.initial_state = WithdrawnState;
-	wmhints.icon_window = iconwin;
+	wmhints.icon_window = win;
 	wmhints.icon_x = 0;
 	wmhints.icon_y = 0;
 	wmhints.window_group = win;
@@ -613,10 +594,8 @@

 	bm.pixmap = gdk_pixmap_create_from_xpm_d(bm.win, &(bm.mask), NULL, master_xpm);
 	gdk_window_shape_combine_mask(bm.win, bm.mask, 0, 0);
-	gdk_window_shape_combine_mask(bm.iconwin, bm.mask, 0, 0);

 	gdk_window_set_back_pixmap(bm.win, bm.pixmap, False);
-	gdk_window_set_back_pixmap(bm.iconwin, bm.pixmap, False);

 #if 0
         gdk_window_set_type_hint(bm.win, GDK_WINDOW_TYPE_HINT_DOCK);
@@ -626,7 +605,6 @@
 #endif

 	icon = gdk_pixmap_create_from_xpm_d(bm.win, NULL, NULL, icon_xpm);
-	gdk_window_set_icon(bm.win, bm.iconwin, icon, NULL);

 	gdk_window_show(bm.win);

@@ -721,9 +699,6 @@
 		case 'l':
 			lock = 1;
 			break;
-		case 'b':
-			broken_wm = 1;
-			break;
 		case 'h':
 		default:
 			do_help();
@@ -766,6 +741,5 @@
 	for (i = 0; i < NFLAMES; i++)
 		fprintf(stderr, "%d:%s ", i + 1, fire[i].text);
 	fprintf(stderr, "\n\t-l\t\t\tlock flame colour and monitor\n");
-	fprintf(stderr, "\t-b\t\t\tactivate broken window manager fix\n");
 	fprintf(stderr, "\t-h\t\t\tprints this help\n");
 }
Only in wmfire-1.2.4/src: wmfire.c~
diff -ur wmfire-1.2.4.old/wmfire.1 wmfire-1.2.4/wmfire.1
--- wmfire-1.2.4.old/wmfire.1	2017-04-23 14:26:58.449487117 -0400
+++ wmfire-1.2.4/wmfire.1	2017-04-23 14:41:20.697186114 -0400
@@ -8,7 +8,6 @@

 .SH SYNOPSIS
 .B wmfire
-[-b]
 [-c CPU]
 [-f COLOUR]
 [-F FILE]
@@ -54,9 +53,6 @@

 .SH OPTIONS
 .TP
-.B -b
-Activate broken window manager fix (if grey box diplayed)
-.TP
 .B -c [0..3]
 .br
 Monitor SMP CPU number X


code:
Fix CVE-2008-2149: buffer overflows by limiting the length of the string in sprintf
format string
Closes: #481186 (CVE-2008-2149)
Please note: The WordNet code contains several other occurences of potentially
exploitable functions like strcpy()/strcat()/...  and so even if there are no
known exploits the code needs a full security audit.

--- a/src/wn.c
+++ b/src/wn.c
@@ -206,7 +206,8 @@ static int searchwn(int ac, char *av[])
 		    outsenses += do_search(av[1], optptr->pos, optptr->search,
 					    whichsense, optptr->label);
 	    } else {
-		sprintf(tmpbuf, "wn: invalid search option: %s\n", av[j]);
+		/* Fix CVE-2008-2149: buffer overflows Andreas Tille <tille@debian.org> */
+		sprintf(tmpbuf, "wn: invalid search option: %.200s\n", av[j]);
 		display_message(tmpbuf);
 		errcount++;
 	    }


code:
Author: Anton Gladky <gladk@debian.org>
LastChanged: Tue, 26 Feb 2013 20:40:25 +0100
BugDebian: http://bugs.debian.org/700914
Description: This patch was created by oCert according to
  http://www.ocert.org/advisories/ocert-2008-014.html
 and can be downloaded from
  http://www.ocert.org/analysis/2008-014/wordnet.patch
 Unfortunately the original patch had a problem which
 caused 'wordnet test -synsn' to fail.  The critical
 part of the patch was removed from the whole patch
 set and is moved to 51_overflows_memcpy.patch which
 uses memcpy instead of the formerly used strcpy.

--- a/lib/binsrch.c
+++ b/lib/binsrch.c
@@ -28,7 +28,7 @@ char *read_index(long offset, FILE *fp)
     char *linep;

     linep = line;
-    line[0] = '0';
+    line[0] = '\0';

     fseek( fp, offset, SEEK_SET );
     fgets(linep, LINE_LEN, fp);
@@ -58,6 +58,8 @@ char *bin_search(char *searchkey, FILE *
         last_bin_search_offset = ftell( fp );
 	fgets(linep, LINE_LEN, fp);
 	length = (int)(strchr(linep, ' ') - linep);
+	if (length > (sizeof(key) - 1))
+            return(NULL);
 	strncpy(key, linep, length);
 	key[length] = '\0';
 	if(strcmp(key, searchkey) < 0) {
@@ -110,6 +112,8 @@ static int bin_search_key(char *searchke
 	line[length++] =  c;
     if (getc(fp) == EOF) {	/* only 1 line in file */
 	length = (int)(strchr(linep, ' ') - linep);
+	if (length > (sizeof(key) - 1))
+            return(0);
 	strncpy(key, linep, length);
 	key[length] = '\0';
 	if(strcmp(key, searchkey) > 0) {
@@ -132,6 +136,8 @@ static int bin_search_key(char *searchke
 	if (fgets(linep, LINE_LEN, fp) != NULL) {
   	    offset2 = ftell(fp); /* offset at start of next line */
 	    length = (int)(strchr(linep, ' ') - linep);
+	    if (length > (sizeof(key) - 1))
+                return(0);
 	    strncpy(key, linep, length);
 	    key[length] = '\0';
 	    if(strcmp(key, searchkey) < 0) {	/* further in file */
--- a/lib/morph.c
+++ b/lib/morph.c
@@ -51,21 +51,21 @@ static struct {
     char *str;
     int strlen;
 } prepositions[NUMPREPS] = {
-    "to", 2,
-    "at", 2,
-    "of", 2,
-    "on", 2,
-    "off", 3,
-    "in", 2,
-    "out", 3,
-    "up", 2,
-    "down", 4,
-    "from", 4,
-    "with", 4,
-    "into", 4,
-    "for", 3,
-    "about", 5,
-    "between", 7,
+    { "to", 2 },
+    { "at", 2 },
+    { "of", 2 },
+    { "on", 2 },
+    { "off", 3 },
+    { "in", 2 },
+    { "out", 3 },
+    { "up", 2 },
+    { "down", 4 },
+    { "from", 4 },
+    { "with", 4 },
+    { "into", 4 },
+    { "for", 3 },
+    { "about", 5 },
+    { "between", 7 }
 };

 static FILE *exc_fps[NUMPARTS + 1];
@@ -144,18 +144,19 @@ static int do_init(void)
     } else
 	sprintf(searchdir, DEFAULTPATH);
 #else
-    if ((env = getenv("WNSEARCHDIR")) != NULL)
-	strcpy(searchdir, env);
-    else if ((env = getenv("WNHOME")) != NULL)
-	sprintf(searchdir, "%s%s", env, DICTDIR);
-    else
+    if ((env = getenv("WNSEARCHDIR")) != NULL) {
+	snprintf(searchdir, sizeof(searchdir), "%s", env);
+    } else if ((env = getenv("WNHOME")) != NULL) {
+	snprintf(searchdir, sizeof(searchdir), "%s%s", env, DICTDIR);
+    } else {
 	strcpy(searchdir, DEFAULTPATH);
+    }
 #endif

     for (i = 1; i <= NUMPARTS; i++) {
-	sprintf(fname, EXCFILE, searchdir, partnames[i]);
+	snprintf(fname, sizeof(fname), EXCFILE, searchdir, partnames[i]);
 	if ((exc_fps[i] = fopen(fname, "r")) == NULL) {
-	    sprintf(msgbuf,
+	    snprintf(msgbuf, sizeof(msgbuf),
 		    "WordNet library error: Can't open exception file(%s)\n\n",
 		    fname);
 	    display_message(msgbuf);
@@ -178,13 +179,16 @@ char *morphstr(char *origstr, int pos)
     int prep;
     char *end_idx1, *end_idx2;
     char *append;
-
+
     if (pos == SATELLITE)
 	pos = ADJ;

     /* First time through for this string */

     if (origstr != NULL) {
+        if (strlen(origstr) > WORDBUF - 1)
+            return(NULL);
+
 	/* Assume string hasn't had spaces substitued with '_' */
 	strtolower(strsubst(strcpy(str, origstr), ' ', '_'));
 	searchstr[0] = '\0';
@@ -232,7 +236,7 @@ char *morphstr(char *origstr, int pos)
 		if (end_idx < 0) return(NULL);		/* shouldn't do this */
 		strncpy(word, str + st_idx, end_idx - st_idx);
 		word[end_idx - st_idx] = '\0';
-		if(tmp = morphword(word, pos))
+		if ((tmp = morphword(word, pos)) != NULL)
 		    strcat(searchstr,tmp);
 		else
 		    strcat(searchstr,word);
@@ -240,7 +244,7 @@ char *morphstr(char *origstr, int pos)
 		st_idx = end_idx + 1;
 	    }

-	    if(tmp = morphword(strcpy(word, str + st_idx), pos))
+	    if ((tmp = morphword(strcpy(word, str + st_idx), pos)) != NULL)
 		strcat(searchstr,tmp);
 	    else
 		strcat(searchstr,word);
@@ -270,16 +274,15 @@ char *morphword(char *word, int pos)
 {
     int offset, cnt;
     int i;
-    static char retval[WORDBUF];
-    char *tmp, tmpbuf[WORDBUF], *end;
-
-    sprintf(retval,"");
-    sprintf(tmpbuf, "");
-    end = "";
-
+    static char retval[WORDBUF] = "";
+    char *tmp, tmpbuf[WORDBUF] = "", *end = "";
+
     if(word == NULL)
 	return(NULL);

+    if (strlen(word) > WORDBUF - 1)
+        return(NULL);
+
     /* first look for word on exception list */

     if((tmp = exc_lookup(word, pos)) != NULL)
@@ -335,7 +338,10 @@ static char *wordbase(char *word, int en
 {
     char *pt1;
     static char copy[WORDBUF];
-
+
+    if (strlen(word) > WORDBUF - 1)
+        return(NULL);
+
     strcpy(copy, word);
     if(strend(copy,sufx[ender])) {
 	pt1=strchr(copy,'\0');
@@ -368,13 +374,14 @@ static char *exc_lookup(char *word, int
 {
     static char line[WORDBUF], *beglp, *endlp;
     char *excline;
-    int found = 0;

     if (exc_fps[pos] == NULL)
 	return(NULL);

     /* first time through load line from exception file */
     if(word != NULL){
+        if (strlen(word) > WORDBUF - 1)
+           return(NULL);
 	if ((excline = bin_search(word, exc_fps[pos])) != NULL) {
 	    strcpy(line, excline);
 	    endlp = strchr(line,' ');
@@ -403,6 +410,9 @@ static char *morphprep(char *s)
     char word[WORDBUF], end[WORDBUF];
     static char retval[WORDBUF];

+    if (strlen(s) > WORDBUF - 1)
+        return (NULL);
+
     /* Assume that the verb is the first word in the phrase.  Strip it
        off, check for validity, then try various morphs with the
        rest of the phrase tacked on, trying to find a match. */
@@ -410,7 +420,7 @@ static char *morphprep(char *s)
     rest = strchr(s, '_');
     last = strrchr(s, '_');
     if (rest != last) {		/* more than 2 words */
-	if (lastwd = morphword(last + 1, NOUN)) {
+	if ((lastwd = morphword(last + 1, NOUN)) != NULL) {
 	    strncpy(end, rest, last - rest + 1);
 	    end[last-rest+1] = '\0';
 	    strcat(end, lastwd);
--- a/lib/search.c
+++ b/lib/search.c
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
+#include <limits.h>

 #include "wn.h"

@@ -119,33 +120,22 @@ IndexPtr parse_index(long offset, int db
     if ( !line )
       line = read_index( offset, indexfps[dbase] );

-    idx = (IndexPtr)malloc(sizeof(Index));
+    idx = (IndexPtr)calloc(1, sizeof(Index));
     assert(idx);

     /* set offset of entry in index file */
     idx->idxoffset = offset;

-    idx->wd='\0';
-    idx->pos='\0';
-    idx->off_cnt=0;
-    idx->tagged_cnt = 0;
-    idx->sense_cnt=0;
-    idx->offset='\0';
-    idx->ptruse_cnt=0;
-    idx->ptruse='\0';
-
     /* get the word */
     ptrtok=strtok(line," \n");

-    idx->wd = malloc(strlen(ptrtok) + 1);
+    idx->wd = strdup(ptrtok);
     assert(idx->wd);
-    strcpy(idx->wd, ptrtok);

     /* get the part of speech */
     ptrtok=strtok(NULL," \n");
-    idx->pos = malloc(strlen(ptrtok) + 1);
+    idx->pos = strdup(ptrtok);
     assert(idx->pos);
-    strcpy(idx->pos, ptrtok);

     /* get the collins count */
     ptrtok=strtok(NULL," \n");
@@ -154,7 +144,12 @@ IndexPtr parse_index(long offset, int db
     /* get the number of pointers types */
     ptrtok=strtok(NULL," \n");
     idx->ptruse_cnt = atoi(ptrtok);
-
+
+    if (idx->ptruse_cnt < 0 || (unsigned int)idx->ptruse_cnt > UINT_MAX/sizeof(int)) {
+        free_index(idx);
+        return(NULL);
+    }
+
     if (idx->ptruse_cnt) {
 	idx->ptruse = (int *) malloc(idx->ptruse_cnt * (sizeof(int)));
 	assert(idx->ptruse);
@@ -173,9 +168,14 @@ IndexPtr parse_index(long offset, int db
     /* get the number of senses that are tagged */
     ptrtok=strtok(NULL," \n");
     idx->tagged_cnt = atoi(ptrtok);
-
+
+    if (idx->off_cnt < 0 || (unsigned long)idx->off_cnt > ULONG_MAX/sizeof(long)) {
+        free_index(idx);
+        return(NULL);
+    }
+
     /* make space for the offsets */
-    idx->offset = (long *) malloc(idx->off_cnt * (sizeof(long)));
+    idx->offset = (unsigned long *) malloc(idx->off_cnt * sizeof(long));
     assert(idx->offset);

     /* get the offsets */
@@ -197,15 +197,21 @@ IndexPtr getindex(char *searchstr, int d
     char strings[MAX_FORMS][WORDBUF]; /* vector of search strings */
     static IndexPtr offsets[MAX_FORMS];
     static int offset;
-
+
     /* This works like strrok(): if passed with a non-null string,
        prepare vector of search strings and offsets.  If string
        is null, look at current list of offsets and return next
        one, or NULL if no more alternatives for this word. */

     if (searchstr != NULL) {
+        /* Bail out if the input is too long for us to handle */
+        if (strlen(searchstr) > (WORDBUF - 1)) {
+            strcpy(msgbuf, "WordNet library error: search term is too long\n");
+                   display_message(msgbuf);
+            return(NULL);
+        }

-	offset = 0;
+    	offset = 0;
 	strtolower(searchstr);
 	for (i = 0; i < MAX_FORMS; i++) {
 	    strcpy(strings[i], searchstr);
@@ -229,11 +235,11 @@ IndexPtr getindex(char *searchstr, int d
 	/* Get offset of first entry.  Then eliminate duplicates
 	   and get offsets of unique strings. */

-	if (strings[0][0] != NULL)
+	if (strings[0] != NULL)
 	    offsets[0] = index_lookup(strings[0], dbase);

 	for (i = 1; i < MAX_FORMS; i++)
-	    if ((strings[i][0]) != NULL && (strcmp(strings[0], strings[i])))
+	    if (strings[i] != NULL && (strcmp(strings[0], strings[i])))
 		offsets[i] = index_lookup(strings[i], dbase);
     }

@@ -272,7 +278,7 @@ SynsetPtr read_synset(int dbase, long bo
 SynsetPtr parse_synset(FILE *fp, int dbase, char *word)
 {
     static char line[LINEBUF];
-    char tbuf[SMLINEBUF];
+    char tbuf[SMLINEBUF] = "";
     char *ptrtok;
     char *tmpptr;
     int foundpert = 0;
@@ -286,33 +292,11 @@ SynsetPtr parse_synset(FILE *fp, int dba
     if ((tmpptr = fgets(line, LINEBUF, fp)) == NULL)
 	return(NULL);

-    synptr = (SynsetPtr)malloc(sizeof(Synset));
+    synptr = (SynsetPtr)calloc(1, sizeof(Synset));
     assert(synptr);
-
-    synptr->hereiam = 0;
+
     synptr->sstype = DONT_KNOW;
-    synptr->fnum = 0;
-    synptr->pos = '\0';
-    synptr->wcount = 0;
-    synptr->words = '\0';
-    synptr->whichword = 0;
-    synptr->ptrcount = 0;
-    synptr->ptrtyp = '\0';
-    synptr->ptroff = '\0';
-    synptr->ppos = '\0';
-    synptr->pto = '\0';
-    synptr->pfrm = '\0';
-    synptr->fcount = 0;
-    synptr->frmid = '\0';
-    synptr->frmto = '\0';
-    synptr->defn = '\0';
-    synptr->key = 0;
-    synptr->nextss = NULL;
-    synptr->nextform = NULL;
     synptr->searchtype = -1;
-    synptr->ptrlist = NULL;
-    synptr->headword = NULL;
-    synptr->headsense = 0;

     ptrtok = line;

@@ -322,7 +306,7 @@ SynsetPtr parse_synset(FILE *fp, int dba

     /* sanity check - make sure starting file offset matches first field */
     if (synptr->hereiam != loc) {
-	sprintf(msgbuf, "WordNet library error: no synset at location %d\n",
+	sprintf(msgbuf, "WordNet library error: no synset at location %ld\n",
 		loc);
 	display_message(msgbuf);
 	free(synptr);
@@ -335,16 +319,20 @@ SynsetPtr parse_synset(FILE *fp, int dba

     /* looking at POS */
     ptrtok = strtok(NULL, " \n");
-    synptr->pos = malloc(strlen(ptrtok) + 1);
+    synptr->pos = strdup(ptrtok);
     assert(synptr->pos);
-    strcpy(synptr->pos, ptrtok);
     if (getsstype(synptr->pos) == SATELLITE)
 	synptr->sstype = INDIRECT_ANT;

     /* looking at numwords */
     ptrtok = strtok(NULL, " \n");
     synptr->wcount = strtol(ptrtok, NULL, 16);
-
+
+    if (synptr->wcount < 0 || (unsigned int)synptr->wcount > UINT_MAX/sizeof(char *)) {
+        free_syns(synptr);
+        return(NULL);
+    }
+
     synptr->words = (char **)malloc(synptr->wcount  * sizeof(char *));
     assert(synptr->words);
     synptr->wnsns = (int *)malloc(synptr->wcount * sizeof(int));
@@ -354,9 +342,8 @@ SynsetPtr parse_synset(FILE *fp, int dba

     for (i = 0; i < synptr->wcount; i++) {
 	ptrtok = strtok(NULL, " \n");
-	synptr->words[i] = malloc(strlen(ptrtok) + 1);
+	synptr->words[i] = strdup(ptrtok);
 	assert(synptr->words[i]);
-	strcpy(synptr->words[i], ptrtok);

 	/* is this the word we're looking for? */

@@ -371,6 +358,12 @@ SynsetPtr parse_synset(FILE *fp, int dba
     ptrtok = strtok(NULL," \n");
     synptr->ptrcount = atoi(ptrtok);

+    /* Should we check for long here as well? */
+    if (synptr->ptrcount < 0 || (unsigned int)synptr->ptrcount > UINT_MAX/sizeof(int)) {
+        free_syns(synptr);
+        return(NULL);
+    }
+
     if (synptr->ptrcount) {

 	/* alloc storage for the pointers */
@@ -455,21 +448,23 @@ SynsetPtr parse_synset(FILE *fp, int dba
     ptrtok = strtok(NULL," \n");
     if (ptrtok) {
 	ptrtok = strtok(NULL," \n");
-	sprintf(tbuf, "");
 	while (ptrtok != NULL) {
+	    if (strlen(ptrtok) + strlen(tbuf) + 1 + 1 > sizeof(tbuf)) {
+                free_syns(synptr);
+                return(NULL);
+	    }
 	    strcat(tbuf,ptrtok);
 	    ptrtok = strtok(NULL, " \n");
 	    if(ptrtok)
 		strcat(tbuf," ");
 	}
-	assert((1 + strlen(tbuf)) < sizeof(tbuf));
-	synptr->defn = malloc(strlen(tbuf) + 4);
+	synptr->defn = malloc(strlen(tbuf) + 3);
 	assert(synptr->defn);
 	sprintf(synptr->defn,"(%s)",tbuf);
     }

     if (keyindexfp) { 		/* we have unique keys */
-	sprintf(tmpbuf, "%c:%8.8d", partchars[dbase], synptr->hereiam);
+	sprintf(tmpbuf, "%c:%8.8ld", partchars[dbase], synptr->hereiam);
 	synptr->key = GetKeyForOffset(tmpbuf);
     }

@@ -635,7 +630,7 @@ static void traceptrs(SynsetPtr synptr,

 	    if ((ptrtyp == PERTPTR || ptrtyp == PPLPTR) &&
 		synptr->pto[i] != 0) {
-		sprintf(tbuf, " (Sense %d)\n",
+		snprintf(tbuf, sizeof(tbuf), " (Sense %d)\n",
 			cursyn->wnsns[synptr->pto[i] - 1]);
 		printsynset(prefix, cursyn, tbuf, DEFOFF, synptr->pto[i],
 			    SKIP_ANTS, PRINT_MARKER);
@@ -656,7 +651,7 @@ static void traceptrs(SynsetPtr synptr,
 		    traceptrs(cursyn, HYPERPTR, getpos(cursyn->pos), 0);
 		}
 	    } else if (ptrtyp == ANTPTR && dbase != ADJ && synptr->pto[i] != 0) {
-		sprintf(tbuf, " (Sense %d)\n",
+		snprintf(tbuf, sizeof(tbuf), " (Sense %d)\n",
 			cursyn->wnsns[synptr->pto[i] - 1]);
 		printsynset(prefix, cursyn, tbuf, DEFOFF, synptr->pto[i],
 			    SKIP_ANTS, PRINT_MARKER);
@@ -817,7 +812,7 @@ static void tracenomins(SynsetPtr synptr

 	    cursyn = read_synset(synptr->ppos[i], synptr->ptroff[i], "");

-	    sprintf(tbuf, "#%d\n",
+	    snprintf(tbuf, sizeof(tbuf), "#%d\n",
 		    cursyn->wnsns[synptr->pto[i] - 1]);
 	    printsynset(prefix, cursyn, tbuf, DEFOFF, synptr->pto[i],
 			SKIP_ANTS, SKIP_MARKER);
@@ -989,12 +984,12 @@ void getexample(char *offset, char *wd)
     char sentbuf[512];

     if (vsentfilefp != NULL) {
-	if (line = bin_search(offset, vsentfilefp)) {
+	if ((line = bin_search(offset, vsentfilefp)) != NULL) {
 	    while(*line != ' ')
 		line++;

 	    printbuffer("          EX: ");
-	    sprintf(sentbuf, line, wd);
+	    snprintf(sentbuf, sizeof(sentbuf), line, wd);
 	    printbuffer(sentbuf);
 	}
     }
@@ -1011,7 +1006,7 @@ int findexample(SynsetPtr synptr)
     if (vidxfilefp != NULL) {
 	wdnum = synptr->whichword - 1;

-	sprintf(tbuf,"%s%%%-1.1d:%-2.2d:%-2.2d::",
+	snprintf(tbuf, sizeof(tbuf), "%s%%%-1.1d:%-2.2d:%-2.2d::",
 		synptr->words[wdnum],
 		getpos(synptr->pos),
 		synptr->fnum,
@@ -1124,7 +1119,7 @@ static void freq_word(IndexPtr index)
 	if (cnt >= 17 && cnt <= 32) familiar = 6;
 	if (cnt > 32 ) familiar = 7;

-	sprintf(tmpbuf,
+	snprintf(tmpbuf, sizeof(tmpbuf),
 		"\n%s used as %s is %s (polysemy count = %d)\n",
 		index->wd, a_an[getpos(index->pos)], freqcats[familiar], cnt);
 	printbuffer(tmpbuf);
@@ -1147,6 +1142,9 @@ void wngrep (char *word_passed, int pos)
    }
    rewind(inputfile);

+   if (strlen(word_passed) + 1 > sizeof(word))
+       return;
+
    strcpy (word, word_passed);
    ToLowerCase(word);		/* map to lower case for index file search */
    strsubst (word, ' ', '_');	/* replace spaces with underscores */
@@ -1169,7 +1167,7 @@ void wngrep (char *word_passed, int pos)
             ((line[loc + wordlen] == '-') || (line[loc + wordlen] == '_')))
          ) {
             strsubst (line, '_', ' ');
-            sprintf (tmpbuf, "%s\n", line);
+            snprintf (tmpbuf, sizeof(tmpbuf), "%s\n", line);
             printbuffer (tmpbuf);
             break;
          }
@@ -1683,9 +1681,8 @@ SynsetPtr traceptrs_ds(SynsetPtr synptr,
 		cursyn = read_synset(synptr->ppos[i],
 				      synptr->ptroff[i],
 				      "");
-		synptr->headword = malloc(strlen(cursyn->words[0]) + 1);
+		synptr->headword = strdup(cursyn->words[0]);
 		assert(synptr->headword);
-		strcpy(synptr->headword, cursyn->words[0]);
 		synptr->headsense = cursyn->lexid[0];
 		free_synset(cursyn);
 		break;
@@ -2013,7 +2010,7 @@ static int getsearchsense(SynsetPtr synp
     strsubst(strcpy(wdbuf, synptr->words[whichword - 1]), ' ', '_');
     strtolower(wdbuf);

-    if (idx = index_lookup(wdbuf, getpos(synptr->pos))) {
+    if ((idx = index_lookup(wdbuf, getpos(synptr->pos))) != NULL) {
 	for (i = 0; i < idx->off_cnt; i++)
 	    if (idx->offset[i] == synptr->hereiam) {
 		free_index(idx);
@@ -2037,7 +2034,7 @@ static void printsynset(char *head, Syns
        by flags */

     if (offsetflag)		/* print synset offset */
-	sprintf(tbuf + strlen(tbuf),"{%8.8d} ", synptr->hereiam);
+	sprintf(tbuf + strlen(tbuf),"{%8.8ld} ", synptr->hereiam);
     if (fileinfoflag) {		/* print lexicographer file information */
 	sprintf(tbuf + strlen(tbuf), "<%s> ", lexfiles[synptr->fnum]);
 	prlexid = 1;		/* print lexicographer id after word */
@@ -2072,7 +2069,7 @@ static void printantsynset(SynsetPtr syn
     tbuf[0] = '\0';

     if (offsetflag)
-	sprintf(tbuf,"{%8.8d} ", synptr->hereiam);
+	sprintf(tbuf,"{%8.8ld} ", synptr->hereiam);
     if (fileinfoflag) {
 	sprintf(tbuf + strlen(tbuf),"<%s> ", lexfiles[synptr->fnum]);
 	prlexid = 1;
--- a/lib/wnutil.c
+++ b/lib/wnutil.c
@@ -48,7 +48,7 @@ int wninit(void)
     char *env;

     if (!done) {
-	if (env = getenv("WNDBVERSION")) {
+	if ((env = getenv("WNDBVERSION")) != NULL) {
 	    wnrelease = strdup(env);	/* set release */
 	    assert(wnrelease);
 	}
@@ -70,7 +70,7 @@ int re_wninit(void)

     closefps();

-    if (env = getenv("WNDBVERSION")) {
+    if ((env = getenv("WNDBVERSION")) != NULL) {
 	wnrelease = strdup(env);	/* set release */
 	assert(wnrelease);
     }
@@ -149,25 +149,25 @@ static int do_init(void)
 	sprintf(searchdir, DEFAULTPATH);
 #else
     if ((env = getenv("WNSEARCHDIR")) != NULL)
-	strcpy(searchdir, env);
+	snprintf(searchdir, sizeof(searchdir), "%s", env);
     else if ((env = getenv("WNHOME")) != NULL)
-	sprintf(searchdir, "%s%s", env, DICTDIR);
+	snprintf(searchdir, sizeof(searchdir), "%s%s", env, DICTDIR);
     else
 	strcpy(searchdir, DEFAULTPATH);
 #endif

     for (i = 1; i < NUMPARTS + 1; i++) {
-	sprintf(tmpbuf, DATAFILE, searchdir, partnames[i]);
+	snprintf(tmpbuf, sizeof(tmpbuf), DATAFILE, searchdir, partnames[i]);
 	if((datafps[i] = fopen(tmpbuf, "r")) == NULL) {
-	    sprintf(msgbuf,
+	    snprintf(msgbuf, sizeof(msgbuf),
 		    "WordNet library error: Can't open datafile(%s)\n",
 		    tmpbuf);
 	    display_message(msgbuf);
 	    openerr = -1;
 	}
-	sprintf(tmpbuf, INDEXFILE, searchdir, partnames[i]);
+	snprintf(tmpbuf, sizeof(tmpbuf), INDEXFILE, searchdir, partnames[i]);
 	if((indexfps[i] = fopen(tmpbuf, "r")) == NULL) {
-	    sprintf(msgbuf,
+	    snprintf(msgbuf, sizeof(msgbuf),
 		    "WordNet library error: Can't open indexfile(%s)\n",
 		    tmpbuf);
 	    display_message(msgbuf);
@@ -178,35 +178,35 @@ static int do_init(void)
     /* This file isn't used by the library and doesn't have to
        be present.  No error is reported if the open fails. */

-    sprintf(tmpbuf, SENSEIDXFILE, searchdir);
+    snprintf(tmpbuf, sizeof(tmpbuf), SENSEIDXFILE, searchdir);
     sensefp = fopen(tmpbuf, "r");

     /* If this file isn't present, the runtime code will skip printint out
        the number of times each sense was tagged. */

-    sprintf(tmpbuf, CNTLISTFILE, searchdir);
+    snprintf(tmpbuf, sizeof(tmpbuf), CNTLISTFILE, searchdir);
     cntlistfp = fopen(tmpbuf, "r");

     /* This file doesn't have to be present.  No error is reported if the
        open fails. */

-    sprintf(tmpbuf, KEYIDXFILE, searchdir);
+    snprintf(tmpbuf, sizeof(tmpbuf), KEYIDXFILE, searchdir);
     keyindexfp = fopen(tmpbuf, "r");

-    sprintf(tmpbuf, REVKEYIDXFILE, searchdir);
+    snprintf(tmpbuf, sizeof(tmpbuf), REVKEYIDXFILE, searchdir);
     revkeyindexfp = fopen(tmpbuf, "r");

-    sprintf(tmpbuf, VRBSENTFILE, searchdir);
+    snprintf(tmpbuf, sizeof(tmpbuf), VRBSENTFILE, searchdir);
     if ((vsentfilefp = fopen(tmpbuf, "r")) == NULL) {
-	sprintf(msgbuf,
+	snprintf(msgbuf, sizeof(msgbuf),
 "WordNet library warning: Can't open verb example sentence file(%s)\n",
 		tmpbuf);
 	display_message(msgbuf);
     }

-    sprintf(tmpbuf, VRBIDXFILE, searchdir);
+    snprintf(tmpbuf, sizeof(tmpbuf), VRBIDXFILE, searchdir);
     if ((vidxfilefp = fopen(tmpbuf, "r")) == NULL) {
-	sprintf(msgbuf,
+	snprintf(msgbuf, sizeof(msgbuf),
 "WordNet library warning: Can't open verb example sentence index file(%s)\n",
 		tmpbuf);
 	display_message(msgbuf);
--- a/src/wn.c
+++ b/src/wn.c
@@ -131,7 +131,7 @@ static void printusage(), printlicense()
        printsearches(char *, int, unsigned long);
 static int error_message(char *);

-main(int argc,char *argv[])
+int main(int argc,char *argv[])
 {
     display_message = error_message;

@@ -228,14 +228,14 @@ static int do_search(char *searchword, i
 	printf("\n%s of %s %s\n%s",
 	       label, partnames[pos], searchword, outbuf);

-    if (morphword = morphstr(searchword, pos))
+    if ((morphword = morphstr(searchword, pos)) != NULL)
 	do {
 	    outbuf = findtheinfo(morphword, pos, search, whichsense);
 	    totsenses += wnresults.printcnt;
 	    if (strlen(outbuf) > 0)
 		printf("\n%s of %s %s\n%s",
 		       label, partnames[pos], morphword, outbuf);
-	} while (morphword = morphstr(NULL, pos));
+	} while ((morphword = morphstr(NULL, pos)) != NULL);

     return(totsenses);
 }


code:
This patch was created by oCert according to
 http://www.ocert.org/advisories/ocert-2008-014.html
Unfortunately the original patch contained a bug which was
later fixed by the issuer of the patch Rob Holland <rob@ocert.org>
This part was now separated in this file.

--- a/lib/search.c
+++ b/lib/search.c
@@ -1568,7 +1568,8 @@ char *findtheinfo(char *searchstr, int d
 			bufstart[0] = '\n';
 			bufstart++;
 		    }
-		    strncpy(bufstart, tmpbuf, strlen(tmpbuf));
+                   /* Avoid writing a trailing \0 after the string */
+                   memcpy(bufstart, tmpbuf, strlen(tmpbuf));
 		    bufstart = searchbuffer + strlen(searchbuffer);
 		}
 	    }


code:
Fix build flags for ARMv7.

Taken from Debian:
https://salsa.debian.org/multimedia-team/x265/-/blob/master/debian/patches/0001-Fix-arm-flags.patch

From: Sebastian Ramacher <sramacher@debian.org>
Date: Wed, 26 Apr 2017 22:05:06 +0200
Subject: Fix arm* flags

---
 source/CMakeLists.txt | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -77,7 +77,7 @@ elseif(ARMMATCH GREATER "-1")
         add_definitions(-DX265_ARCH_ARM=1 -DX265_ARCH_ARM64=1 -DHAVE_ARMV6=0)
     else()
         message(STATUS "Detected ARM target processor")
-        add_definitions(-DX265_ARCH_ARM=1 -DX265_ARCH_ARM64=0 -DHAVE_ARMV6=1)
+        add_definitions(-DX265_ARCH_ARM=1)
     endif()
 else()
     message(STATUS "CMAKE_SYSTEM_PROCESSOR value `${CMAKE_SYSTEM_PROCESSOR}` is unknown")
@@ -252,10 +252,7 @@ if(GCC)
         else()
             find_package(Neon)
             if(CPU_HAS_NEON)
-                set(ARM_ARGS -mcpu=native -mfloat-abi=hard -mfpu=neon -marm -fPIC)
                 add_definitions(-DHAVE_NEON)
-            else()
-                set(ARM_ARGS -mcpu=native -mfloat-abi=hard -mfpu=vfp -marm)
             endif()
         endif()
     endif()


code:
Removes references to mibstore.h and miInitializeBackingStore, which
have been removed from xorg-server.  Zack Rusin <zackr@vmware.com>
wrote: "It was a noop for at least 5 years and it has been removed."
See: http://patches.openembedded.org/patch/46133/

--- xf86-video-ark-0.7.5/src/ark_driver.c.~1~	2012-07-17 00:51:36.000000000 -0400
+++ xf86-video-ark-0.7.5/src/ark_driver.c	2014-12-19 00:23:13.028931734 -0500
@@ -39,7 +39,6 @@
 #include "compiler.h"
 #include "mipointer.h"
 #include "micmap.h"
-#include "mibstore.h"
 #include "fb.h"
 #include "ark.h"

@@ -538,7 +537,6 @@

 	fbPictureInit (pScreen, 0, 0);

-	miInitializeBackingStore(pScreen);
 	xf86SetBackingStore(pScreen);

 	if (!pARK->NoAccel) {


code:
Fix test compilation with exa.h in configure when using glibc 2.20.
Inspired by a patch by Peter Hutterer <peter.hutterer@who-t.net>.
See <https://raw.githubusercontent.com/openembedded/oe-core/master/meta/recipes-graphics/xorg-driver/xf86-input-synaptics/always_include_xorg_server.h.patch>.

--- xf86-video-mach64-6.9.4/configure.~1~	2012-12-20 01:16:10.000000000 -0500
+++ xf86-video-mach64-6.9.4/configure	2014-12-19 02:48:18.040097554 -0500
@@ -18370,7 +18370,9 @@

         SAVE_CPPFLAGS="$CPPFLAGS"
         CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
-        ac_fn_c_check_header_mongrel "$LINENO" "exa.h" "ac_cv_header_exa_h" "$ac_includes_default"
+        ac_fn_c_check_header_mongrel "$LINENO" "exa.h" "ac_cv_header_exa_h" "$ac_includes_default
+#include <xorg-server.h>
+"
 if test "x$ac_cv_header_exa_h" = xyes; then :
   have_exa_h="yes"
 else


code:
Fix build against xorg-server >= 1.20.

Patch taken from upstream:
https://cgit.freedesktop.org/xorg/driver/xf86-video-savage/commit/?id=0ece556daa8a88771b669d8104396abd9166d2d0

diff --git a/src/savage_driver.c b/src/savage_driver.c
index 58a294d..3cda923 100644
--- a/src/savage_driver.c
+++ b/src/savage_driver.c
@@ -2034,8 +2034,6 @@ static Bool SavagePreInit(ScrnInfoPtr pScrn, int flags)
     xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Detected current MCLK value of %1.3f MHz\n",
 	       mclk / 1000.0);

-    pScrn->maxHValue = 2048 << 3;	/* 11 bits of h_total 8-pixel units */
-    pScrn->maxVValue = 2048;		/* 11 bits of v_total */
     pScrn->virtualX = pScrn->display->virtualX;
     pScrn->virtualY = pScrn->display->virtualY;

@@ -3637,6 +3635,14 @@ static ModeStatus SavageValidMode(SCRN_ARG_TYPE arg, DisplayModePtr pMode,
        (pMode->VDisplay > psav->PanelY)))
 	    return MODE_PANEL;

+    /* 11 bits of h_total 8-pixel units */
+    if (pMode->HTotal > (2048 << 3))
+	return MODE_BAD_HVALUE;
+
+    /* 11 bits of v_total */
+    if (pMode->VTotal > 2048)
+	return MODE_BAD_VVALUE;
+
     if (psav->UseBIOS) {
 	refresh = SavageGetRefresh(pMode);
         return (SavageMatchBiosMode(pScrn,pMode->HDisplay,


code:
From eee8fd4c489a693344da0bba14cfa54c54610b89 Mon Sep 17 00:00:00 2001
From: Maarten Lankhorst <maarten.lankhorst@ubuntu.com>
Date: Thu, 9 Mar 2017 13:31:34 +0200
Subject: [PATCH] Fix build against xorg server 1.17 on certain architectures

Fixes at least arm64, likely also hppa, m68k, sh4.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@ubuntu.com>
---
 src/regsmi.h       | 18 ++++++++++++++++++
 src/smi.h          |  2 ++
 src/smi_driver.c   | 19 +++++++++----------
 src/smilynx_crtc.c |  6 +++---
 src/smilynx_hw.c   |  5 ++---
 5 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/src/regsmi.h b/src/regsmi.h
index 5dd0320..69205ba 100644
--- a/src/regsmi.h
+++ b/src/regsmi.h
@@ -64,8 +64,13 @@ VGAIN8_INDEX(SMIPtr pSmi, int indexPort, int dataPort, CARD8 index)
 	MMIO_OUT8(pSmi->IOBase, indexPort, index);
 	return(MMIO_IN8(pSmi->IOBase, dataPort));
     } else {
+#ifdef XSERVER_LIBPCIACCESS
+	pci_io_write8(pSmi->io, indexPort, index);
+	return pci_io_read8(pSmi->io, dataPort);
+#else
 	outb(pSmi->PIOBase + indexPort, index);
 	return(inb(pSmi->PIOBase + dataPort));
+#endif
     }
 }

@@ -76,8 +81,13 @@ VGAOUT8_INDEX(SMIPtr pSmi, int indexPort, int dataPort, CARD8 index, CARD8 data)
 	MMIO_OUT8(pSmi->IOBase, indexPort, index);
 	MMIO_OUT8(pSmi->IOBase, dataPort, data);
     } else {
+#ifdef XSERVER_LIBPCIACCESS
+	pci_io_write8(pSmi->io, indexPort, index);
+	pci_io_write8(pSmi->io, dataPort, data);
+#else
 	outb(pSmi->PIOBase + indexPort, index);
 	outb(pSmi->PIOBase + dataPort, data);
+#endif
     }
 }

@@ -87,7 +97,11 @@ VGAIN8(SMIPtr pSmi, int port)
     if (pSmi->IOBase) {
 	return(MMIO_IN8(pSmi->IOBase, port));
     } else {
+#ifdef XSERVER_LIBPCIACCESS
+	return pci_io_read8(pSmi->io, port);
+#else
 	return(inb(pSmi->PIOBase + port));
+#endif
     }
 }

@@ -97,7 +111,11 @@ VGAOUT8(SMIPtr pSmi, int port, CARD8 data)
     if (pSmi->IOBase) {
 	MMIO_OUT8(pSmi->IOBase, port, data);
     } else {
+#ifdef XSERVER_LIBPCIACCESS
+	pci_io_write8(pSmi->io, port, data);
+#else
 	outb(pSmi->PIOBase + port, data);
+#endif
     }
 }

diff --git a/src/smi.h b/src/smi.h
index 2742c8d..1f20a2d 100644
--- a/src/smi.h
+++ b/src/smi.h
@@ -171,6 +171,8 @@ typedef struct
     pciVideoPtr		PciInfo;	/* PCI info vars */
 #ifndef XSERVER_LIBPCIACCESS
     PCITAG		PciTag;
+#else
+    struct pci_io_handle *io;
 #endif
     int			Chipset;	/* Chip info, set using PCI
 					   above */
diff --git a/src/smi_driver.c b/src/smi_driver.c
index 8949cae..6bdf64d 100644
--- a/src/smi_driver.c
+++ b/src/smi_driver.c
@@ -446,6 +446,9 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags)
 	pSmi->PIOBase = hwp->PIOOffset;
 #else
 	pSmi->PIOBase = 0;
+#ifdef XSERVER_LIBPCIACCESS
+	pSmi->io = hwp->io;
+#endif
 #endif

 	xf86ErrorFVerb(VERBLEV, "\tSMI_PreInit vgaCRIndex=%x, vgaIOBase=%x, "
@@ -2022,16 +2025,14 @@ SMI_EnableMmio(ScrnInfoPtr pScrn)
 	vgaHWSetStdFuncs(hwp);

 	/* Enable linear mode */
-	outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18);
-	tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA);
+	tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18);
 	pSmi->SR18Value = tmp;					/* PDR#521 */
-	outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp | 0x11);
+	VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18, tmp | 0x11);

 	/* Enable 2D/3D Engine and Video Processor */
-	outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x21);
-	tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA);
+	tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21);
 	pSmi->SR21Value = tmp;					/* PDR#521 */
-	outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp & ~0x03);
+	VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, tmp & ~0x03);
     }

     LEAVE();
@@ -2050,12 +2051,10 @@ SMI_DisableMmio(ScrnInfoPtr pScrn)
 	vgaHWSetStdFuncs(hwp);

 	/* Disable 2D/3D Engine and Video Processor */
-	outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x21);
-	outb(pSmi->PIOBase + VGA_SEQ_DATA, pSmi->SR21Value);	/* PDR#521 */
+	VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21, pSmi->SR21Value);	/* PDR#521 */

 	/* Disable linear mode */
-	outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18);
-	outb(pSmi->PIOBase + VGA_SEQ_DATA, pSmi->SR18Value);	/* PDR#521 */
+	VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18, pSmi->SR18Value);	/* PDR#521 */
     }

     LEAVE();
diff --git a/src/smilynx_crtc.c b/src/smilynx_crtc.c
index fb7183c..f4d8b4e 100644
--- a/src/smilynx_crtc.c
+++ b/src/smilynx_crtc.c
@@ -619,9 +619,9 @@ SMILynx_CrtcModeSet_bios(xf86CrtcPtr crtc,
     xf86ExecX86int10(pSmi->pInt10);

     /* Enable linear mode. */
-    outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18);
-    tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA);
-    outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp | 0x01);
+    VGAOUT8(pSmi, VGA_SEQ_INDEX, 0x18);
+    tmp = VGAIN8(pSmi, VGA_SEQ_DATA);
+    VGAOUT8(pSmi, VGA_SEQ_DATA, tmp | 0x01);

     /* Enable DPR/VPR registers. */
     tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21);
diff --git a/src/smilynx_hw.c b/src/smilynx_hw.c
index b2ee8a5..40aa5a4 100644
--- a/src/smilynx_hw.c
+++ b/src/smilynx_hw.c
@@ -365,9 +365,8 @@ SMILynx_WriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, SMIRegPtr restore)
 	xf86ExecX86int10(pSmi->pInt10);

 	/* Enable linear mode. */
-	outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x18);
-	tmp = inb(pSmi->PIOBase + VGA_SEQ_DATA);
-	outb(pSmi->PIOBase + VGA_SEQ_DATA, tmp | 0x01);
+	tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18);
+	VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x18, tmp | 0x01);

 	/* Enable DPR/VPR registers. */
 	tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x21);
--
2.7.4


code:
Removes references to mibstore.h and miInitializeBackingStore, which
have been removed from xorg-server.  Zack Rusin <zackr@vmware.com>
wrote: "It was a noop for at least 5 years and it has been removed."
See: http://patches.openembedded.org/patch/46133/

--- xf86-video-tga-1.2.2/src/tga_accel.c.~1~	2012-07-15 23:54:04.000000000 -0400
+++ xf86-video-tga-1.2.2/src/tga_accel.c	2014-12-19 01:40:27.535913013 -0500
@@ -37,7 +37,6 @@
 #include "xf86cmap.h"
 #include "mipointer.h"

-#include "mibstore.h"
 #include "miline.h"

 #include "tga_regs.h"
--- xf86-video-tga-1.2.2/src/tga_driver.c.~1~	2012-07-15 23:54:28.000000000 -0400
+++ xf86-video-tga-1.2.2/src/tga_driver.c	2014-12-19 01:40:48.756018238 -0500
@@ -46,8 +46,6 @@

 /* software cursor */
 #include "mipointer.h"
-/* backing store */
-#include "mibstore.h"

 /*  #include "mibank.h" */
 /* colormap manipulation */
@@ -1451,7 +1449,6 @@

     fbPictureInit (pScreen, 0, 0);

-    miInitializeBackingStore(pScreen);
     xf86SetBackingStore(pScreen);
     xf86SetSilkenMouse(pScreen);


code:
From: Tobias Geerinckx-Rice <me@tobias.gr>
Date: Mon, 20 May 2019 04:52:33 +0200
Subject: [PATCH] gnu: xf86-video-voodoo: Don't use PCITAG.

Copied verbatim from upstream repository[0].

[0]: https://cgit.freedesktop.org/xorg/driver/-xf86-video-voodoo/patch/?id=9172ae566a0e85313fc80ab62b4455393eefe593

From 9172ae566a0e85313fc80ab62b4455393eefe593 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Mon, 22 Sep 2014 10:56:02 +1000
Subject: don't use PCITAG in struct anymore

---
 src/voodoo.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/voodoo.h b/src/voodoo.h
index bfed497..c3eb64e 100644
--- a/src/voodoo.h
+++ b/src/voodoo.h
@@ -23,7 +23,9 @@ typedef struct {

   Bool		      Voodoo2;		/* Set if Voodoo2 */
   pciVideoPtr	      PciInfo;		/* PCI data */
+#ifndef XSERVER_LIBPCIACCESS
   PCITAG	      PciTag;
+#endif
   CARD32	      PhysBase;

   CARD32	      Width;		/* Current width */
--
cgit v1.0


code:
Search for xfce4 panel plugins in the directories specified
in XDG_DATA_DIRS and X_XFCE4_LIB_DIRS.  For discussion of the
relevant issues, see:

  https://bugzilla.xfce.org/show_bug.cgi?id=5455

Patch by Mark H Weaver <mhw@netris.org>

--- xfce4-panel-4.10.0/panel/panel-module.c.orig	2012-04-28 16:31:35.000000000 -0400
+++ xfce4-panel-4.10.0/panel/panel-module.c	2014-12-14 01:31:55.728107386 -0500
@@ -35,8 +35,14 @@
 #include <panel/panel-plugin-external-wrapper.h>
 #include <panel/panel-plugin-external-46.h>

-#define PANEL_PLUGINS_LIB_DIR (LIBDIR G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "plugins")
-#define PANEL_PLUGINS_LIB_DIR_OLD (LIBDIR G_DIR_SEPARATOR_S "panel-plugins")
+#define PANEL_PLUGINS_LIB_DIR_TAIL (G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "plugins")
+#define PANEL_PLUGINS_LIB_DIR_TAIL_OLD (G_DIR_SEPARATOR_S "panel-plugins")
+
+static const gchar *plugins_lib_dir_tails[] =
+{
+  PANEL_PLUGINS_LIB_DIR_TAIL,
+  PANEL_PLUGINS_LIB_DIR_TAIL_OLD
+};

 typedef enum _PanelModuleRunMode PanelModuleRunMode;
@@ -335,21 +341,39 @@
           /* show a messsage if the old module path key still exists */
           g_message ("Plugin %s: The \"X-XFCE-Module-Path\" key is "
                      "ignored in \"%s\", the panel will look for the "
-                     "module in %s. See bug #5455 why this decision was made",
-                     name, filename, PANEL_PLUGINS_LIB_DIR);
+                     "module in DIR%s for each DIR in $X_XFCE4_LIB_DIRS "
+                     "(%s by default).  See bug #5455 for discussion.",
+                     name, filename, PANEL_PLUGINS_LIB_DIR_TAIL, LIBDIR);
         }
 #endif

-      path = g_module_build_path (PANEL_PLUGINS_LIB_DIR, module_name);
-      found = g_file_test (path, G_FILE_TEST_EXISTS);
+      /* search for module */
+      {
+        gchar   *dirs_string;
+        gchar  **dirs;
+        int      i, j;
+
+        dirs_string = (gchar *) g_getenv ("X_XFCE4_LIB_DIRS");
+        if (!dirs_string)
+          dirs_string = LIBDIR;
+        dirs = g_strsplit (dirs_string, G_SEARCHPATH_SEPARATOR_S, 0);
+
+        found = FALSE;
+        path = NULL;
+
+        for (i = 0; !found && dirs[i] != NULL; i++)
+          for (j = 0; !found && j < G_N_ELEMENTS (plugins_lib_dir_tails); j++)
+            {
+              gchar *dir = g_strconcat (dirs[i], plugins_lib_dir_tails[j], NULL);
+
+              g_free (path);
+              path = g_module_build_path (dir, module_name);
+              found = g_file_test (path, G_FILE_TEST_EXISTS);
+              g_free (dir);
+            }

-      if (!found)
-        {
-          /* deprecated location for module plugin directories */
-          g_free (path);
-          path = g_module_build_path (PANEL_PLUGINS_LIB_DIR_OLD, module_name);
-          found = g_file_test (path, G_FILE_TEST_EXISTS);
-        }
+        g_strfreev (dirs);
+      }

       if (G_LIKELY (found))
         {
--- xfce4-panel-4.10.0/panel/panel-module-factory.c.orig	2012-04-28 16:31:35.000000000 -0400
+++ xfce4-panel-4.10.0/panel/panel-module-factory.c	2014-12-13 23:55:27.439404812 -0500
@@ -42,6 +42,11 @@
 #define PANEL_PLUGINS_DATA_DIR     (DATADIR G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "plugins")
 #define PANEL_PLUGINS_DATA_DIR_OLD (DATADIR G_DIR_SEPARATOR_S "panel-plugins")

+static const gchar *plugins_data_dir_tails[] =
+{
+  (G_DIR_SEPARATOR_S "xfce4" G_DIR_SEPARATOR_S "panel" G_DIR_SEPARATOR_S "plugins"),
+  (G_DIR_SEPARATOR_S "xfce4" G_DIR_SEPARATOR_S "panel-plugins")
+};

 static void     panel_module_factory_finalize        (GObject                  *object);
@@ -223,8 +228,22 @@
 panel_module_factory_load_modules (PanelModuleFactory *factory,
                                    gboolean            warn_if_known)
 {
+  const gchar * const * system_data_dirs;
+  int i, j;
+
   panel_return_if_fail (PANEL_IS_MODULE_FACTORY (factory));

+  system_data_dirs = g_get_system_data_dirs ();
+  for (i = 0; system_data_dirs[i] != NULL; i++)
+    for (j = 0; j < G_N_ELEMENTS (plugins_data_dir_tails); j++)
+    {
+      gchar *dir;
+
+      dir = g_strconcat (system_data_dirs[i], plugins_data_dir_tails[j], NULL);
+      panel_module_factory_load_modules_dir (factory, dir, warn_if_known);
+      g_free (dir);
+    }
+
   /* load from the new and old location */
   panel_module_factory_load_modules_dir (factory, PANEL_PLUGINS_DATA_DIR, warn_if_known);
   panel_module_factory_load_modules_dir (factory, PANEL_PLUGINS_DATA_DIR_OLD, warn_if_known);


code:
This patch make Xfce use "gnome" as the default icon theme and enable font antialias.

Taken from ArchLinux.

diff -upr xfce4-settings-4.12.0.orig/xfsettingsd/xsettings.xml xfce4-settings-4.12.0/xfsettingsd/xsettings.xml
--- xfce4-settings-4.12.0.orig/xfsettingsd/xsettings.xml	2015-02-24 03:33:11.000000000 +0200
+++ xfce4-settings-4.12.0/xfsettingsd/xsettings.xml	2015-03-01 09:52:24.376869688 +0200
@@ -6,8 +6,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <channel name="xsettings" version="1.0">
   <property name="Net" type="empty">
     <property name="ThemeName" type="empty"/>
-    <property name="IconThemeName" type="empty"/>
+    <property name="IconThemeName" type="string" value="gnome"/>
     <property name="DoubleClickTime" type="int" value="400"/>
     <property name="DoubleClickDistance" type="int" value="5"/>
     <property name="DndDragThreshold" type="int" value="8"/>
@@ -19,9 +19,9 @@
   </property>
   <property name="Xft" type="empty">
     <property name="DPI" type="empty"/>
-    <property name="Antialias" type="int" value="-1"/>
+    <property name="Antialias" type="int" value="1"/>
     <property name="Hinting" type="int" value="-1"/>
-    <property name="HintStyle" type="string" value="hintnone"/>
+    <property name="HintStyle" type="string" value="hintfull"/>
     <property name="RGBA" type="string" value="none"/>
     <!-- <property name="Lcdfilter" type="string" value="none"/> -->
   </property>


code:
This patch is required for xmonad to make use of shared libraries.
Without it, xmonad will not work since we do not (by default) use
statically linked Haskell libraries.

diff -ruN xmonad-0.15-a/src/XMonad/Core.hs xmonad-0.15-b/src/XMonad/Core.hs
--- xmonad-0.15-a/src/XMonad/Core.hs	1969-12-31 19:00:00.000000000 -0500
+++ xmonad-0.15-b/src/XMonad/Core.hs	1969-12-31 19:00:00.000000000 -0500
@@ -681,6 +681,8 @@
        compileGHC bin dir errHandle =
          runProcess "ghc" ["--make"
                           , "xmonad.hs"
+                          , "-dynamic"
+                          , "-fPIC"
                           , "-i"
                           , "-ilib"
                           , "-fforce-recomp"


code:
Author: Eric Bavier Date: 2020-01-13
Url: https://notabug.org/bavier/guix-bavier/raw/master/bavier/patches/
+xplanet-cxx11-eof.patch

diff --git a/src/libannotate/addArcs.cpp b/src/libannotate/addArcs.cpp
index 2ee06c0..4fdb343 100644
--- a/src/libannotate/addArcs.cpp
+++ b/src/libannotate/addArcs.cpp
@@ -258,7 +258,7 @@ addArcs(PlanetProperties *planetProperties, Planet *planet,
         {
             ifstream inFile(arcFile.c_str());
             char *line = new char[MAX_LINE_LENGTH];
-            while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+            while (!inFile.getline (line, MAX_LINE_LENGTH, '\n').eof())
                 readArcFile(line, planet, view, projection,
                             planetProperties, annotationMap);

@@ -292,7 +292,7 @@ addArcs(View *view, multimap<double, Annotation *> &annotationMap)
         {
             ifstream inFile(arcFile.c_str());
             char *line = new char[256];
-            while (inFile.getline (line, 256, '\n') != NULL)
+            while (!inFile.getline (line, 256, '\n').eof())
                 readArcFile(line, NULL, view, NULL, NULL, annotationMap);

             inFile.close();
diff --git a/src/libannotate/addMarkers.cpp b/src/libannotate/addMarkers.cpp
index dde51c1..b641e6a 100644
--- a/src/libannotate/addMarkers.cpp
+++ b/src/libannotate/addMarkers.cpp
@@ -429,7 +429,7 @@ addMarkers(PlanetProperties *planetProperties, Planet *planet,
         {
             ifstream inFile(markerFile.c_str());
             char *line = new char[MAX_LINE_LENGTH];
-            while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+            while (!inFile.getline (line, MAX_LINE_LENGTH, '\n').eof())
             {
                 unsigned char color[3];
                 memcpy(color, planetProperties->MarkerColor(), 3);
@@ -475,7 +475,7 @@ addMarkers(View *view, const int width, const int height,
         {
             ifstream inFile(markerFile.c_str());
             char *line = new char[MAX_LINE_LENGTH];
-            while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+            while (!inFile.getline (line, MAX_LINE_LENGTH, '\n').eof())
             {
                 unsigned char color[3];
                 memcpy(color, options->Color(), 3);
diff --git a/src/libannotate/addSatellites.cpp b/src/libannotate/addSatellites.cpp
index 2634339..6d9d378 100644
--- a/src/libannotate/addSatellites.cpp
+++ b/src/libannotate/addSatellites.cpp
@@ -488,10 +488,10 @@ loadSatelliteVector(PlanetProperties *planetProperties)
         {
             ifstream inFile(tleFile.c_str());
             char lines[3][80];
-            while (inFile.getline(lines[0], 80) != NULL)
+            while (!inFile.getline(lines[0], 80).eof())
             {
-                if ((inFile.getline(lines[1], 80) == NULL)
-                    || (inFile.getline(lines[2], 80) == NULL))
+	        if ((inFile.getline(lines[1], 80).eof())
+                    || (inFile.getline(lines[2], 80).eof()))
                 {
                     ostringstream errStr;
                     errStr << "Malformed TLE file (" << tleFile << ")?\n";
@@ -542,7 +542,7 @@ addSatellites(PlanetProperties *planetProperties, Planet *planet,
         {
             ifstream inFile(satFile.c_str());
             char *line = new char[MAX_LINE_LENGTH];
-            while (inFile.getline (line, MAX_LINE_LENGTH, '\n') != NULL)
+            while (!inFile.getline (line, MAX_LINE_LENGTH, '\n').eof())
                 readSatelliteFile(line, planet, view, projection,
                                   planetProperties, annotationMap);

diff --git a/src/libannotate/addSpiceObjects.cpp b/src/libannotate/addSpiceObjects.cpp
index 67b752c..eeadf6e 100644
--- a/src/libannotate/addSpiceObjects.cpp
+++ b/src/libannotate/addSpiceObjects.cpp
@@ -524,7 +524,7 @@ processSpiceKernels(const bool load)
         {
             ifstream inFile(kernelFile.c_str());
             char *line = new char[MAX_LINE_LENGTH];
-            while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+            while (!inFile.getline(line, MAX_LINE_LENGTH, '\n').eof())
             {
                 int ii = 0;
                 while (isDelimiter(line[ii]))
@@ -576,7 +576,7 @@ addSpiceObjects(map<double, Planet *> &planetsFromSunMap,
         {
             ifstream inFile(spiceFile.c_str());
             char *line = new char[MAX_LINE_LENGTH];
-            while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+            while (!inFile.getline(line, MAX_LINE_LENGTH, '\n').eof())
                 readSpiceFile(line, planetsFromSunMap, view, projection,
                               annotationMap);
             inFile.close();
diff --git a/src/libmultiple/RayleighScattering.cpp b/src/libmultiple/RayleighScattering.cpp
index d885173..1be8ece 100644
--- a/src/libmultiple/RayleighScattering.cpp
+++ b/src/libmultiple/RayleighScattering.cpp
@@ -369,7 +369,7 @@ RayleighScattering::readConfigFile(string configFile)

     diskTemplate_.clear();
     limbTemplate_.clear();
-    while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+    while (!inFile.getline(line, MAX_LINE_LENGTH, '\n').eof())
     {
         int i = 0;
         while (isDelimiter(line[i]))
@@ -439,7 +439,7 @@ RayleighScattering::readBlock(ifstream &inFile,
     values.clear();

     char line[MAX_LINE_LENGTH];
-    while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+    while (!inFile.getline(line, MAX_LINE_LENGTH, '\n').eof())
     {
         int i = 0;
         while (isDelimiter(line[i]))
@@ -470,7 +470,7 @@ RayleighScattering::readValue(ifstream &inFile,
                               double &value)
 {
     char line[MAX_LINE_LENGTH];
-    while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+    while (!inFile.getline(line, MAX_LINE_LENGTH, '\n').eof())
     {
         int i = 0;
         while (isDelimiter(line[i]))
diff --git a/src/libmultiple/drawStars.cpp b/src/libmultiple/drawStars.cpp
index ff07c49..aabdfed 100644
--- a/src/libmultiple/drawStars.cpp
+++ b/src/libmultiple/drawStars.cpp
@@ -41,7 +41,7 @@ drawStars(DisplayBase *display, View *view)
     ifstream inFile(starMap.c_str());

     char line[MAX_LINE_LENGTH];
-    while (inFile.getline(line, MAX_LINE_LENGTH, '\n') != NULL)
+    while (!inFile.getline(line, MAX_LINE_LENGTH, '\n').eof())
     {
         if (line[0] == '#') continue;

diff --git a/src/readConfig.cpp b/src/readConfig.cpp
index cc1964f..4650527 100644
--- a/src/readConfig.cpp
+++ b/src/readConfig.cpp
@@ -550,7 +550,7 @@ readConfigFile(string configFile, PlanetProperties *planetProperties[])

         ifstream inFile(configFile.c_str());
         char *line = new char[256];
-        while (inFile.getline(line, 256, '\n') != NULL)
+        while (!inFile.getline(line, 256, '\n').eof())
             readConfig(line, planetProperties);

         // This condition will only be true if [default] is the only


code:
Origin: $NetBSD: patch-src_libdisplay_DisplayOutput.cpp,v 1.1 2019/11/16 17:36:28 ng0 Exp $

Modified by: R Veera Kumar <vkor@vkten.in> 2020-03-28; change to patch -p1

diff -uNr xplanet-1.3.1/src/libdisplay/DisplayOutput.cpp xplanet-1.3.1.new/src/libdisplay/DisplayOutput.cpp
--- xplanet-1.3.1/src/libdisplay/DisplayOutput.cpp	2013-02-17 01:07:47.000000000 +0530
+++ xplanet-1.3.1.new/src/libdisplay/DisplayOutput.cpp	2020-03-28 22:08:44.432499170 +0530
@@ -51,7 +51,7 @@
     string outputFilename = options->OutputBase();
     int startIndex = options->OutputStartIndex();
     int stopIndex = options->NumTimes() + startIndex - 1;
-    if (stopIndex > 1)
+    if (stopIndex > 0)
     {
         const int digits = (int) (log10((double) stopIndex) + 1);
         char buffer[64];


code:
Origin: $NetBSD: patch-src_libimage_gif.c,v 1.4 2019/11/16 17:36:28 ng0 Exp $

Modified by: R Veera Kumar <vkor@vkten.in> 2020-03-28; change to patch -p1

diff -uNr xplanet-1.3.1/src/libimage/gif.c xplanet-1.3.1.new/src/libimage/gif.c
--- xplanet-1.3.1/src/libimage/gif.c	2013-02-17 01:07:47.000000000 +0530
+++ xplanet-1.3.1.new/src/libimage/gif.c	2020-03-28 22:15:24.444309199 +0530
@@ -21,7 +21,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
+#include <stdbool.h>
 #include <gif_lib.h>

 /*
@@ -178,8 +178,12 @@
 	    *BufferP++ = ColorMapEntry->Blue;
 	}
     }
-
+
+#if GIFLIB_MAJOR >= 5
+    if (DGifCloseFile(GifFile, NULL) == GIF_ERROR) {
+#else
     if (DGifCloseFile(GifFile) == GIF_ERROR) {
+#endif
 	return(0);
     }

@@ -493,7 +497,11 @@
 static void QuitGifError(GifFileType *GifFile)
 {
     fprintf(stderr, "Error writing GIF file\n");
+#if GIFLIB_MAJOR >= 5
+    if (GifFile != NULL) EGifCloseFile(GifFile, NULL);
+#else
     if (GifFile != NULL) EGifCloseFile(GifFile);
+#endif
 }

 int
@@ -589,7 +597,11 @@
 	Ptr += width;
     }

+#if GIFLIB_MAJOR >= 5
+    if (EGifCloseFile(GifFile, NULL) == GIF_ERROR)
+#else
     if (EGifCloseFile(GifFile) == GIF_ERROR)
+#endif

     {
 	QuitGifError(GifFile);


code:
Disable systemd-run if the command is not found.

diff -Naur xpra-4.0.1/xpra/scripts/main.py xpra-4.0.1.patched/xpra/scripts/main.py
--- xpra-4.0.1/xpra/scripts/main.py	2020-05-17 18:12:15.000000000 +0200
+++ xpra-4.0.1.patched/xpra/scripts/main.py	2020-06-01 12:12:18.500257507 +0200
@@ -312,16 +312,18 @@
     if not is_systemd_pid1():
         return False
     #test it:
-    cmd = ["systemd-run", "--quiet", "--user", "--scope", "--", "true"]
-    proc = Popen(cmd, stdin=None, stdout=None, stderr=None, shell=False)
-    r = pollwait(proc, timeout=1)
-    if r is None:
-        try:
-            proc.terminate()
-        except Exception:
-            pass
-    return r==0
-
+    try:
+        cmd = ["systemd-run", "--quiet", "--user", "--scope", "--", "true"]
+        proc = Popen(cmd, stdin=None, stdout=None, stderr=None, shell=False)
+        r = pollwait(proc, timeout=1)
+        if r is None:
+            try:
+                proc.terminate()
+            except Exception:
+                pass
+        return r==0
+    except FileNotFoundError:
+        return False

 def run_mode(script_file, error_cb, options, args, mode, defaults):
     #configure default logging handler:


code:
From bbd54510f0297afa2d1a81927db060cb0b791f14 Mon Sep 17 00:00:00 2001
From: Ralph Little <littlesincanada@yahoo.co.uk>
Date: Sun, 1 Sep 2019 17:34:19 -0700
Subject: [PATCH] Apply opensuse upstream patch xsane_memory_leak

Removes completely redundant memory allocation.
---
 src/xsane-batch-scan.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/src/xsane-batch-scan.c b/src/xsane-batch-scan.c
index 90cc0e0..e77caca 100644
--- a/src/xsane-batch-scan.c
+++ b/src/xsane-batch-scan.c
@@ -680,7 +680,6 @@ static GtkWidget *xsane_batch_scan_create_list_entry(Batch_Scan_Parameters *para
  GtkWidget *list_item;
  GtkWidget *hbox;
  int size = 120;
- char *data;

   list_item = gtk_list_item_new();

@@ -688,8 +687,6 @@ static GtkWidget *xsane_batch_scan_create_list_entry(Batch_Scan_Parameters *para
   gtk_container_add(GTK_CONTAINER(list_item), hbox);
   gtk_widget_show(hbox);

-  data = calloc(size, size);
-
   parameters->gtk_preview = gtk_preview_new(GTK_PREVIEW_COLOR);
   gtk_preview_size(GTK_PREVIEW(parameters->gtk_preview), size, size);
   gtk_box_pack_start(GTK_BOX(hbox), parameters->gtk_preview, FALSE, FALSE, 0);
--
2.22.0


code:
From c126eea11c4ee39cbe9c0c76f920626b618b6ee9 Mon Sep 17 00:00:00 2001
From: Ralph Little <littlesincanada@yahoo.co.uk>
Date: Sun, 1 Sep 2019 17:03:44 -0700
Subject: [PATCH] Apply debian upstream patch 0135-fix_pdf_floats

Original patch commentary:

Description: Fix floats in PDF and PostScript
 Set LC_NUMERIC to POSIX before printing floats when building
 PostScript or PDF output.
Author: Julien BLACHE <jblache@debian.org>
Forwarded: yes

------------
Looks like float printing format is affected by the current locale.
Ensures that we always get POSIX formatting of floats.
---
 src/xsane-save.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/src/xsane-save.c b/src/xsane-save.c
index f14df05..63550cc 100644
--- a/src/xsane-save.c
+++ b/src/xsane-save.c
@@ -26,6 +26,8 @@
 #include "xsane-back-gtk.h"
 #include "xsane-front-gtk.h"
 #include "xsane-save.h"
+#include <locale.h>
+#include <string.h>
 #include <time.h>
 #include <sys/wait.h>

@@ -2425,6 +2427,7 @@ static void xsane_save_ps_create_image_header(FILE *outfile,
                                               int flatedecode)
 {
  int depth;
+ char *save_locale;

   depth = image_info->depth;

@@ -2442,8 +2445,15 @@ static void xsane_save_ps_create_image_header(FILE *outfile,

   fprintf(outfile, "%d rotate\n", degree);
   fprintf(outfile, "%d %d translate\n", position_left, position_bottom);
+
+  save_locale = strdup(setlocale(LC_NUMERIC, NULL));
+  setlocale(LC_NUMERIC, "POSIX");
+
   fprintf(outfile, "%f %f scale\n", width, height);

+  setlocale(LC_NUMERIC, save_locale);
+  free(save_locale);
+
   fprintf(outfile, "<<\n");
   fprintf(outfile, " /ImageType 1\n");
   fprintf(outfile, " /Width %d\n", image_info->image_width);
@@ -3921,6 +3931,7 @@ static void xsane_save_pdf_create_page_header(FILE *outfile, struct pdf_xref *xr
  int position_left, position_bottom, box_left, box_bottom, box_right, box_top, depth;
  int left, bottom;
  float rad;
+ char *save_locale;

   DBG(DBG_proc, "xsane_save_pdf_create_page_header\n");

@@ -4035,8 +4046,16 @@ static void xsane_save_pdf_create_page_header(FILE *outfile, struct pdf_xref *xr

   fprintf(outfile, "q\n");
   fprintf(outfile, "1 0 0 1 %d %d cm\n", position_left, position_bottom); /* translate */
+
+  save_locale = strdup(setlocale(LC_NUMERIC, NULL));
+  setlocale(LC_NUMERIC, "POSIX");
+
   fprintf(outfile, "%f %f -%f %f 0 0 cm\n", cos(rad), sin(rad), sin(rad), cos(rad)); /* rotate */
   fprintf(outfile, "%f 0 0 %f 0 0 cm\n", width, height); /* scale */
+
+  setlocale(LC_NUMERIC, save_locale);
+  free(save_locale);
+
   fprintf(outfile, "BI\n");
   fprintf(outfile, "  /W %d\n", image_info->image_width);
   fprintf(outfile, "  /H %d\n", image_info->image_height);
--
2.22.0


code:
From 893a5ce1f75e5eea7c8d383038ff92a150819c9c Mon Sep 17 00:00:00 2001
From: Ralph Little <littlesincanada@yahoo.co.uk>
Date: Thu, 19 Sep 2019 22:02:33 -0700
Subject: [PATCH] xsane-*-project.c - reduced snprintf format pad to silence
 warning about too long constrant string for buffer.

---
 src/xsane-email-project.c     | 4 ++--
 src/xsane-fax-project.c       | 4 ++--
 src/xsane-multipage-project.c | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/xsane-email-project.c b/src/xsane-email-project.c
index f20cb12..ac93fc2 100644
--- a/src/xsane-email-project.c
+++ b/src/xsane-email-project.c
@@ -896,7 +896,7 @@ static void xsane_email_project_update_project_status()
   snprintf(filename, sizeof(filename), "%s/xsane-mail-list", preferences.email_project);
   projectfile = fopen(filename, "r+b"); /* r+ = read and write, position = start of file */

-  snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */
+  snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */
   fprintf(projectfile, "%s\n", buf); /* first line is status of email */

   fclose(projectfile);
@@ -936,7 +936,7 @@ void xsane_email_project_save()
   {
    char buf[TEXTBUFSIZE];

-    snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */
+    snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.email_status); /* fill 32 characters status line */
     fprintf(projectfile, "%s\n", buf); /* first line is status of email */
     gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), _(xsane.email_status));
     xsane_progress_bar_set_fraction(GTK_PROGRESS_BAR(xsane.project_progress_bar), 0.0);
diff --git a/src/xsane-fax-project.c b/src/xsane-fax-project.c
index f263313..0c60a97 100644
--- a/src/xsane-fax-project.c
+++ b/src/xsane-fax-project.c
@@ -452,7 +452,7 @@ static void xsane_fax_project_update_project_status()
   snprintf(filename, sizeof(filename), "%s/xsane-fax-list", preferences.fax_project);
   projectfile = fopen(filename, "r+b"); /* r+ = read and write, position = start of file */

-  snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */
+  snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */
   fprintf(projectfile, "%s\n", buf); /* first line is status of mail */

   fclose(projectfile);
@@ -498,7 +498,7 @@ void xsane_fax_project_save()
   {
    char buf[TEXTBUFSIZE];

-    snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */
+    snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.fax_status); /* fill 32 characters status line */
     fprintf(projectfile, "%s\n", buf); /* first line is status of mail */
     gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), _(xsane.fax_status));
     xsane_progress_bar_set_fraction(GTK_PROGRESS_BAR(xsane.project_progress_bar), 0.0);
diff --git a/src/xsane-multipage-project.c b/src/xsane-multipage-project.c
index f23e5f8..9392e00 100644
--- a/src/xsane-multipage-project.c
+++ b/src/xsane-multipage-project.c
@@ -522,7 +522,7 @@ void xsane_multipage_project_save()
   {
    char buf[TEXTBUFSIZE];

-    snprintf(buf, 32, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.multipage_status); /* fill 32 characters status line */
+    snprintf(buf, 33, "%s@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", xsane.multipage_status); /* fill 32 characters status line */
     fprintf(projectfile, "%s\n", buf); /* first line is status of multipage */
     gtk_progress_set_format_string(GTK_PROGRESS(xsane.project_progress_bar), _(xsane.multipage_status));
     xsane_progress_bar_set_fraction(GTK_PROGRESS_BAR(xsane.project_progress_bar), 0.0);
--
2.23.0


code:
From 62d9c172f258769e3a7540fe710e013bb39a704f Mon Sep 17 00:00:00 2001
From: Ralph Little <littlesincanada@yahoo.co.uk>
Date: Sat, 7 Sep 2019 12:39:45 -0700
Subject: [PATCH] Apply opensuse upstream patch 004-ipv6-support

Appears to be related to this:
https://bugzilla.redhat.com/show_bug.cgi?id=198422

-----
Changes email socket connection code to use more IP version agnostic
calls. It appears to only be used by the scan email option and
originally comes from the RedHat IPv6 awareness program mentioned
in the bug report.

In practice, I'm not sure how practical the implementation for emailing
scans in xsane is as it does not look to support encryption, pretty
much a given in today's world.
---
 src/xsane-save.c | 96 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 62 insertions(+), 34 deletions(-)

diff --git a/src/xsane-save.c b/src/xsane-save.c
index 63550cc..ff3c459 100644
--- a/src/xsane-save.c
+++ b/src/xsane-save.c
@@ -31,6 +31,8 @@
 #include <time.h>
 #include <sys/wait.h>

+#include <glib.h>
+
 /* the following test is always false */
 #ifdef _native_WIN32
 # include <winsock.h>
@@ -7540,55 +7542,81 @@ void write_email_attach_file(int fd_socket, char *boundary, FILE *infile, char *
 /* returns fd_socket if sucessfull, < 0 when error occured */
 int open_socket(char *server, int port)
 {
- int fd_socket;
- struct sockaddr_in sin;
- struct hostent *he;
+ int fd_socket, e;
+
+ struct addrinfo *ai_list, *ai;
+ struct addrinfo hints;
+ gchar *port_s;
+ gint connected;
+
+  memset(&hints, '\0', sizeof(hints));
+  hints.ai_flags = AI_ADDRCONFIG;
+  hints.ai_socktype = SOCK_STREAM;
+
+  port_s = g_strdup_printf("%d", port);
+  e = getaddrinfo(server, port_s, &hints, &ai_list);
+  g_free(port_s);

-  he = gethostbyname(server);
-  if (!he)
+  if (e != 0)
   {
-    DBG(DBG_error, "open_socket: Could not get hostname of \"%s\"\n", server);
+    DBG(DBG_error, "open_socket: Could not lookup \"%s\"\n", server);
    return -1;
   }
-  else
+
+  connected = 0;
+  for (ai = ai_list; ai != NULL && !connected; ai = ai->ai_next)
   {
-    DBG(DBG_info, "open_socket: connecting to \"%s\" = %d.%d.%d.%d\n",
-        he->h_name,
-        (unsigned char) he->h_addr_list[0][0],
-        (unsigned char) he->h_addr_list[0][1],
-        (unsigned char) he->h_addr_list[0][2],
-        (unsigned char) he->h_addr_list[0][3]);
-  }
+    gchar hostname[NI_MAXHOST];
+    gchar hostaddr[NI_MAXHOST];
+
+    /* If all else fails */
+    strncpy(hostname, "(unknown name)", NI_MAXHOST-1);
+    strncpy(hostaddr, "(unknown address)", NI_MAXHOST-1);
+
+    /* Determine canonical name and IPv4/IPv6 address */
+    (void) getnameinfo(ai->ai_addr, ai->ai_addrlen, hostname, sizeof(hostname),
+                       NULL, 0, 0);
+    (void) getnameinfo(ai->ai_addr, ai->ai_addrlen, hostaddr, sizeof(hostaddr),
+                       NULL, 0, NI_NUMERICHOST);
+
+    DBG(DBG_info, "open_socket: connecting to \"%s\" (\"%s\"): %s\n",
+        server, hostname, hostaddr);

-  if (he->h_addrtype != AF_INET)
-  {
-    DBG(DBG_error, "open_socket: Unknown address family: %d\n", he->h_addrtype);
-   return -1;
-  }
+    if ((ai->ai_family != AF_INET) && (ai->ai_family != AF_INET6))
+    {
+      DBG(DBG_error, "open_socket: Unknown address family: %d\n", ai->ai_family);
+      continue;
+    }

-  fd_socket = socket(AF_INET, SOCK_STREAM, 0);
+    fd_socket = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);

-  if (fd_socket < 0)
-  {
-    DBG(DBG_error, "open_socket: Could not create socket: %s\n", strerror(errno));
-   return -1;
-  }
+    if (fd_socket < 0)
+    {
+      DBG(DBG_error, "open_socket: Could not create socket: %s\n", strerror(errno));
+      continue;
+    }

-/*  setsockopt (dev->ctl, level, TCP_NODELAY, &on, sizeof (on)); */
+    /*  setsockopt (dev->ctl, level, TCP_NODELAY, &on, sizeof (on)); */

-  sin.sin_port = htons(port);
-  sin.sin_family = AF_INET;
-  memcpy(&sin.sin_addr, he->h_addr_list[0], he->h_length);
+    if (connect(fd_socket, ai->ai_addr, ai->ai_addrlen) != 0)
+    {
+      DBG(DBG_error, "open_socket: Could not connect with port %d of socket: %s\n", port, strerror(errno));
+      continue;
+    }
+
+    /* All went well */
+    connected = 1;
+  }

-  if (connect(fd_socket, &sin, sizeof(sin)))
+  if (!connected)
   {
-    DBG(DBG_error, "open_socket: Could not connect with port %d of socket: %s\n", ntohs(sin.sin_port), strerror(errno));
-   return -1;
+    DBG(DBG_info, "open_socket: Could not connect to any address");
+    return -1;
   }

-  DBG(DBG_info, "open_socket: Connected with port %d\n", ntohs(sin.sin_port));
+  DBG(DBG_info, "open_socket: Connected with port %d\n", port);

- return fd_socket;
+  return fd_socket;
 }

 /* ---------------------------------------------------------------------------------------------------------------------- */
--
2.22.0


code:
From 5dc1e301a165709c60c435f00ec9bb6d7d5f21f3 Mon Sep 17 00:00:00 2001
From: Ralph Little <littlesincanada@yahoo.co.uk>
Date: Tue, 27 Aug 2019 21:40:02 -0700
Subject: [PATCH] Apply debian upstream patch 0160-fix_tighten_default_umask

Original patch commentary:

Description: Change default XSane umask from 0007 to 0077
 A default umask of 0007 can be mildly insecure in a multiuser environment,
 so tighten things up a bit and go with 0077 instead.
Author: Adrien Thebo
Bug-Debian: http://bugs.debian.org/592972
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/xsane/+bug/611950

----
As above.
---
 src/xsane.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/xsane.h b/src/xsane.h
index 67f06d4..fa04418 100644
--- a/src/xsane.h
+++ b/src/xsane.h
@@ -104,7 +104,7 @@
 #define XSANE_DEBUG_ENVIRONMENT	"XSANE_DEBUG"

 #define XSANE_PROGRESS_BAR_MIN_DELTA_PERCENT 0.025
-#define XSANE_DEFAULT_UMASK		0007
+#define XSANE_DEFAULT_UMASK		0077
 #define XSANE_HOLD_TIME			200
 #define XSANE_CONTINUOUS_HOLD_TIME	10
 #define XSANE_DEFAULT_DEVICE		"SANE_DEFAULT_DEVICE"
--
2.22.0