diff -Nru mtink-1.0.16/debian/changelog mtink-1.0.16/debian/changelog
--- mtink-1.0.16/debian/changelog	2012-07-26 15:59:32.000000000 +0200
+++ mtink-1.0.16/debian/changelog	2013-07-31 16:41:10.000000000 +0200
@@ -1,3 +1,17 @@
+mtink (1.0.16-7) UNRELEASED; urgency=low
+
+  * QA upload.
+  * Build-depend on libmotif-dev instead of lesstif2-dev (Closes: #714664).
+  * Remove duplicate build-depend on debhelper.
+  * Fix mtinkc crash when run with an empty environment (Closes: #716125).
+  * Fix mtink crash when run with an empty environment (Closes: #716543).
+  * Compile detect/askPrinter.c with hardening flags.
+  * Fix various spelling errors reported by Lintian.
+  * Use 'set -e' in mtink.postinst.
+  * Bump Standards-Version to 3.9.4 (no changes).
+
+ -- Graham Inggs <graham@nerve.org.za>  Wed, 31 Jul 2013 11:12:34 +0200
+
 mtink (1.0.16-6) unstable; urgency=low
 
   * QA upload.
diff -Nru mtink-1.0.16/debian/control mtink-1.0.16/debian/control
--- mtink-1.0.16/debian/control	2012-07-26 16:09:32.000000000 +0200
+++ mtink-1.0.16/debian/control	2013-07-31 16:41:42.000000000 +0200
@@ -3,7 +3,6 @@
 Priority: extra
 Maintainer: Debian QA Group <packages@qa.debian.org>
 Build-Depends: cdbs,
- debhelper,
  dh-buildinfo,
  po4a,
  docbook-xml (>= 4.4),
@@ -11,9 +10,9 @@
  libxml2-utils,
  xsltproc, 
  debhelper (>= 8),
- lesstif2-dev, libgimp2.0-dev (>= 2.0.0-4), libx11-dev, 
+ libmotif-dev, libgimp2.0-dev (>= 2.0.0-4), libx11-dev, 
  libxpm-dev, libxt-dev, po-debconf
-Standards-Version: 3.9.3
+Standards-Version: 3.9.4
 Homepage: http://xwtools.automatix.de/
 
 Package: mtink
diff -Nru mtink-1.0.16/debian/mtink.postinst mtink-1.0.16/debian/mtink.postinst
--- mtink-1.0.16/debian/mtink.postinst	2012-02-07 01:27:39.000000000 +0200
+++ mtink-1.0.16/debian/mtink.postinst	2013-07-31 15:01:11.000000000 +0200
@@ -1,4 +1,5 @@
-#!/bin/sh -e
+#!/bin/sh
+set -e
 
 # load debconf library because we need to...
 . /usr/share/debconf/confmodule
diff -Nru mtink-1.0.16/debian/patches/fix-mtinkc-crash mtink-1.0.16/debian/patches/fix-mtinkc-crash
--- mtink-1.0.16/debian/patches/fix-mtinkc-crash	1970-01-01 02:00:00.000000000 +0200
+++ mtink-1.0.16/debian/patches/fix-mtinkc-crash	2013-07-31 16:35:57.000000000 +0200
@@ -0,0 +1,51 @@
+Description: fix mtinkc crash when run with an empty environment
+ Running 'env -i /usr/bin/mtinkc' results in a segfault.
+ This patch avoids operations on NULL string pointers and
+ delays calling mtink until topLevel has been created.
+Bug-Debian: http://bugs.debian.org/716125
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: No
+Last-Update: 2013-07-31
+--- a/chooser/mtinkc.c
++++ b/chooser/mtinkc.c
+@@ -193,6 +193,10 @@
+    DIR           *dir;
+    struct dirent *ent;
+ 
++   if ( home == NULL )
++   {    
++      return 0;
++   }
+    fileName = (char*)calloc(strlen(home)+100,1);
+ 
+    *nodes = (nodes_t*)calloc(sizeof(nodes_t),1);
+@@ -619,14 +623,6 @@
+    /* look for the display name if given */
+    getDisplayName(argc, argv);
+ 
+-   /* only 0 entry is the rc file, we have not to offer choices */
+-   /* call mtink now                                            */
+-   if ( n == 0 )
+-   {
+-      callCommand(n,topLevel);
+-      exit(0);
+-   }
+-   
+    /* make the topLevel */
+    mainResource = (char*)calloc(strlen(prgName)+3,1);
+    strcpy(mainResource,prgName);
+@@ -647,6 +643,14 @@
+       fprintf(stderr,"%s: can't connect to X11\n", prgName);
+       exit(1);
+    }
++   
++   /* only 0 entry is the rc file, we have not to offer choices */
++   /* call mtink now                                            */
++   if ( n == 0 )
++   {
++      callCommand(n,topLevel);
++      exit(0);
++   }   
+ 
+    /* don't map now */
+    XtVaSetValues(topLevel, XmNmappedWhenManaged, False, NULL);
diff -Nru mtink-1.0.16/debian/patches/fix-mtink-crash mtink-1.0.16/debian/patches/fix-mtink-crash
--- mtink-1.0.16/debian/patches/fix-mtink-crash	1970-01-01 02:00:00.000000000 +0200
+++ mtink-1.0.16/debian/patches/fix-mtink-crash	2013-07-31 16:36:45.000000000 +0200
@@ -0,0 +1,38 @@
+Description: fix mtink crash when run with an empty environment
+ Running 'env -i /usr/bin/mtink' results in a segfault.
+ This patch avoids operations on NULL string pointers.
+Bug-Debian: http://bugs.debian.org/716543
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: No
+Last-Update: 2013-07-31
+--- a/mainSrc/checkenv.c
++++ b/mainSrc/checkenv.c
+@@ -232,15 +232,20 @@
+    {
+       m = u;
+    }
+-   if ( strlen(m) > 256 )
+-   {
+-      return 0;
+-   }
+-   while ( *m )
+-   {
+-      if ( !isprint(*m) || isspace(*m) )
++   if ( m != NULL )
++   {
++      if( strlen(m) > 256 )
++      {
+          return 0;
+-      m++;
++      }
++      while ( *m )
++      {
++         if ( !isprint(*m) || isspace(*m) )
++         {
++            return 0;
++         }
++         m++;
++      }
+    }
+    
+    /* check the PATH variable */
diff -Nru mtink-1.0.16/debian/patches/fix-spelling-errors mtink-1.0.16/debian/patches/fix-spelling-errors
--- mtink-1.0.16/debian/patches/fix-spelling-errors	1970-01-01 02:00:00.000000000 +0200
+++ mtink-1.0.16/debian/patches/fix-spelling-errors	2013-07-31 16:37:56.000000000 +0200
@@ -0,0 +1,108 @@
+Description: fix various spelling errors reported by Lintian
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: No
+Last-Update: 2013-07-31
+--- a/mainSrc/d4lib.c
++++ b/mainSrc/d4lib.c
+@@ -148,14 +148,14 @@
+    { 0x03, "Transaction channel can´t be closed."                  ,0 },
+    { 0x04, "No sufficient resources available now."                ,0 },
+    { 0x05, "Connection denied."                                    ,1 },
+-   { 0x06, "Channel allready open."                                ,0 },
++   { 0x06, "Channel already open."                                ,0 },
+    { 0x07, "Credit overflow, previous credit remain valid."        ,0 },
+    { 0x08, "Channel is not open."                                  ,1 },
+    { 0x09, "Service not available on specified socket."            ,1 },
+    { 0x0a, "Service name to socket ID failed."                     ,1 },
+    { 0x0b, "Init transaction failed."                              ,1 },
+    { 0x0c, "Invalid packet size."                                  ,1 },
+-   { 0x0d, "Requested packed size is 0, no data can be transfered.",0 },
++   { 0x0d, "Requested packed size is 0, no data can be transferred.",0 },
+    { 0x80, "Malformed packet, ignored."                            ,1 },
+    { 0x81, "No credit for received packet, ignored"                ,0 },
+    { 0x82, "Reply don´t match with outstanding command, ignored."  ,1 },
+--- a/mainSrc/tres.c
++++ b/mainSrc/tres.c
+@@ -980,7 +980,7 @@
+    "    -v --version          print version\\n"
+    "    -l --list-printer     list known printers\\n"
+    "  Misc:\\n"
+-   "    -L                    debug ouput for D4 protocol on stderr\\n"
++   "    -L                    debug output for D4 protocol on stderr\\n"
+    "    -u                    printout with UTF-8 code\\n",
+ 
+    ".syntaxM:"
+@@ -998,7 +998,7 @@
+    "    -v --version          print version\\n"
+    "    -l --list-printer     list known printers\\n"
+    "  Misc:\\n"
+-   "    -L                    debug ouput for D4 protocol on stderr\\n"
++   "    -L                    debug output for D4 protocol on stderr\\n"
+    "    -u                    printout with UTF-8 code\\n",
+ 
+ #if 0
+@@ -1222,7 +1222,7 @@
+    "    -v --version          print version\\n"
+    "    -l --list-printer     list known printers\\n"
+    "  Misc:\\n"
+-   "    -L                    debug ouput for D4 protocol on stderr\\n"
++   "    -L                    debug output for D4 protocol on stderr\\n"
+    "    -u                    printout with UTF-8 code\\n",
+ 
+    ".syntaxM:"
+@@ -1240,7 +1240,7 @@
+    "    -v --version          print version\\n"
+    "    -l --list-printer     list known printers\\n"
+    "  Misc:\\n"
+-   "    -L                    debug ouput for D4 protocol on stderr\\n"
++   "    -L                    debug output for D4 protocol on stderr\\n"
+    "    -u                    printout with UTF-8 code\\n",
+ 
+ #if 0
+@@ -2858,7 +2858,7 @@
+    "    -v --version          skriv ut versionsnummer\\n"
+    "    -l --list-printer     skriv ut lista av kända skrivaren\\n"
+    "  Andra:\\n"
+-   "    -L                    debug ouput för D4-protokollet på stderr\\n"
++   "    -L                    debug output för D4-protokollet på stderr\\n"
+    "    -u                    utskrift med UTF-8-kod\\n",
+ 
+    ".Sv.syntaxM:"
+@@ -2876,7 +2876,7 @@
+    "    -v --version          skriv ut versionsnummer\\n"
+    "    -l --list-printer     skriv ut lista av kända skrivaren\\n"
+    "  Andra:\\n"
+-   "    -L                    debug ouput för D4-protokollet på stderr\\n"
++   "    -L                    debug output för D4-protokollet på stderr\\n"
+    "    -u                    utskrift med UTF-8-kod\\n",
+ 
+ #if 0
+@@ -3086,7 +3086,7 @@
+    "    -v --version          skriv ut versionsnummer\\n"
+    "    -l --list-printer     skriv ut lista av kÃ¤nda skrivaren\\n"
+    "  Andra:\\n"
+-   "    -L                    debug ouput fÃ¶r D4-protokollet pÃ¥ stderr\\n"
++   "    -L                    debug output fÃ¶r D4-protokollet pÃ¥ stderr\\n"
+    "    -u                    utskrift med UTF-8-kod\\n",
+ 
+    ".Sv8.syntaxM:"
+@@ -3104,7 +3104,7 @@
+    "    -v --version          skriv ut versionsnummer\\n"
+    "    -l --list-printer     skriv ut lista av kÃ¤nda skrivaren\\n"
+    "  Andra:\\n"
+-   "    -L                    debug ouput fÃ¶r D4-protokollet pÃ¥ stderr\\n"
++   "    -L                    debug output fÃ¶r D4-protokollet pÃ¥ stderr\\n"
+    "    -u                    utskrift med UTF-8-kod\\n",
+ 
+ #if 0
+--- a/html/mtinkd.html
++++ b/html/mtinkd.html
+@@ -102,7 +102,7 @@
+ name and space characters are to be replaced by the "_ " character.
+ This will be the case for the <i>Stylus Scan 2500</i> (model anme is<i>Scan_2500</i>).
+       <br>
+-This option may also be usefull for multifunction device as the <i>Stylus
++This option may also be useful for multifunction device as the <i>Stylus
+ Photo 895</i> under Linux. If the printer is powered off and then on,
+ the usb kernel will not detect the printer properly and mtinkd must be
+ at least stopped and started again.<br>
diff -Nru mtink-1.0.16/debian/patches/harden-askprinter mtink-1.0.16/debian/patches/harden-askprinter
--- mtink-1.0.16/debian/patches/harden-askprinter	1970-01-01 02:00:00.000000000 +0200
+++ mtink-1.0.16/debian/patches/harden-askprinter	2013-07-31 16:40:42.000000000 +0200
@@ -0,0 +1,15 @@
+Description: compile detect/askPrinter.c with hardening flags
+Author: Graham Inggs <graham@nerve.org.za>
+Forwarded: No
+Last-Update: 2013-07-31
+--- a/Makefile.ORG
++++ b/Makefile.ORG
+@@ -269,7 +269,7 @@
+ 
+ $(DETDIR)/askPrinter: $(DETDIR)/askPrinter.c
+ 	@echo Compile and link askPrinter.c
+-	@$(CC) -o $(DETDIR)/askPrinter $(DETDIR)/askPrinter.c -I. -I$(DETDIR)
++	@$(CC) -o $(DETDIR)/askPrinter $(DETDIR)/askPrinter.c $(CFLAGS) $(LDFLAGS) -I. -I$(DETDIR)
+ 
+ ########### utilities ######################
+ 
diff -Nru mtink-1.0.16/debian/patches/series mtink-1.0.16/debian/patches/series
--- mtink-1.0.16/debian/patches/series	2012-07-26 14:21:55.000000000 +0200
+++ mtink-1.0.16/debian/patches/series	2013-07-31 15:09:01.000000000 +0200
@@ -1,3 +1,8 @@
 mtink-fr
 mtink-1.0.14-ru_font
 lesstif-multiarch
+fix-mtinkc-crash
+fix-mtink-crash
+harden-askprinter
+fix-spelling-errors
+
diff -Nru mtink-1.0.16/debian/xml-man/en/mtinkd.xml mtink-1.0.16/debian/xml-man/en/mtinkd.xml
--- mtink-1.0.16/debian/xml-man/en/mtinkd.xml	2012-02-07 01:27:39.000000000 +0200
+++ mtink-1.0.16/debian/xml-man/en/mtinkd.xml	2013-07-31 15:01:11.000000000 +0200
@@ -71,7 +71,7 @@
     
     <para>&dhprg; is a status monitor for EPSON ink jet printer</para>
     
-    <para>It permits to watch the remaining ink while printing.</para>
+    <para>It permits one to watch the remaining ink while printing.</para>
     
     <para>As it keeps <filename>/dev/lp*</filename> open, you have to change
       your printing parameter to link the printer to
@@ -115,7 +115,7 @@
             printer is attached. The name is derived from the official name and
             space characters are to be replaced by the "_" character. This
             will be the case for the Stylus Scan 2500 (model name is Scan_2500).</para>
-          <para> This option may also be usefull for multifunction device as
+          <para> This option may also be useful for multifunction device as
             the Stylus Photo 895 under Linux. If the printer is powered off and
             then on, the usb kernel will not detect the printer properly and
             mtinkd must be at least stopped and started again.</para>
diff -Nru mtink-1.0.16/debian/xml-man/po4a/po/fr.po mtink-1.0.16/debian/xml-man/po4a/po/fr.po
--- mtink-1.0.16/debian/xml-man/po4a/po/fr.po	2012-02-07 01:32:45.000000000 +0200
+++ mtink-1.0.16/debian/xml-man/po4a/po/fr.po	2013-07-31 16:10:32.000000000 +0200
@@ -5,7 +5,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: mtink_1.0.14-3_fr\n"
-"POT-Creation-Date: 2012-02-07 00:32+0100\n"
+"POT-Creation-Date: 2013-07-31 13:52+0200\n"
 "PO-Revision-Date: 2006-11-19 22:47+0200\n"
 "Last-Translator: Sylvain Le Gall <gildor@debian.org>\n"
 "Language-Team: French <debian-l10-french@lists.debian.org>\n"
@@ -574,7 +574,7 @@
 # type: Content of: <refentry><refsect1><para>
 #. type: Content of: <refentry><refsect1><para>
 #: debian/xml-man/en/mtinkd.xml:74
-msgid "It permits to watch the remaining ink while printing."
+msgid "It permits one to watch the remaining ink while printing."
 msgstr ""
 "Cela permet de constater la quantitÃ© d'encre restante, pendant l'impression."
 
@@ -654,7 +654,7 @@
 #. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
 #: debian/xml-man/en/mtinkd.xml:118
 msgid ""
-"This option may also be usefull for multifunction device as the Stylus Photo "
+"This option may also be useful for multifunction device as the Stylus Photo "
 "895 under Linux. If the printer is powered off and then on, the usb kernel "
 "will not detect the printer properly and mtinkd must be at least stopped and "
 "started again."
diff -Nru mtink-1.0.16/debian/xml-man/po4a/po/mtink-man.pot mtink-1.0.16/debian/xml-man/po4a/po/mtink-man.pot
--- mtink-1.0.16/debian/xml-man/po4a/po/mtink-man.pot	2012-02-07 01:32:45.000000000 +0200
+++ mtink-1.0.16/debian/xml-man/po4a/po/mtink-man.pot	2013-07-31 15:48:52.000000000 +0200
@@ -7,7 +7,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2012-02-07 00:32+0100\n"
+"POT-Creation-Date: 2013-07-31 13:52+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -467,7 +467,7 @@
 
 #. type: Content of: <refentry><refsect1><para>
 #: debian/xml-man/en/mtinkd.xml:74
-msgid "It permits to watch the remaining ink while printing."
+msgid "It permits one to watch the remaining ink while printing."
 msgstr ""
 
 #. type: Content of: <refentry><refsect1><para>
@@ -521,7 +521,7 @@
 #. type: Content of: <refentry><refsect1><variablelist><varlistentry><listitem><para>
 #: debian/xml-man/en/mtinkd.xml:118
 msgid ""
-"This option may also be usefull for multifunction device as the Stylus Photo "
+"This option may also be useful for multifunction device as the Stylus Photo "
 "895 under Linux. If the printer is powered off and then on, the usb kernel "
 "will not detect the printer properly and mtinkd must be at least stopped and "
 "started again."

