Package: ssmtp
Version: 2.61-5
Severity: important
Tags: patch

Hi,

your package ssmtp failed to autobuild on hurd-i386:

Automatic build of ssmtp_2.61-5 on beethoven by sbuild/hurd-i386 79
Build started at 20051223-1645
******************************************************************************
[...]
gcc -DSTDC_HEADERS=1 -DHAVE_LIMITS_H=1 -DHAVE_STRINGS_H=1
-DHAVE_SYSLOG_H=1 -DHAVE_UNISTD_H=1 -DHAVE_LIBNSL=1
+-DRETSIGTYPE=void -DHAVE_VPRINTF=1 -DHAVE_GETHOSTNAME=1 -DHAVE_SOCKET=1
-DHAVE_STRDUP=1 -DHAVE_STRSTR=1 -DREWRITE_DOMAIN=1
+-DHAVE_SSL=1  -DSSMTPCONFDIR=\"/etc/ssmtp\"
-DCONFIGURATION_FILE=\"/etc/ssmtp/ssmtp.conf\"
+-DREVALIASES_FILE=\"/etc/ssmtp/revaliases\"  -g -O2 -Wall   -c -o
ssmtp.o ssmtp.c
ssmtp.c: In function 'dead_letter':
ssmtp.c:145: error: 'MAXPATHLEN' undeclared (first use in this function)
ssmtp.c:145: error: (Each undeclared identifier is reported only once
ssmtp.c:145: error: for each function it appears in.)
ssmtp.c:145: warning: unused variable 'path'
ssmtp.c: In function 'basename':
ssmtp.c:223: error: 'MAXPATHLEN' undeclared (first use in this function)
ssmtp.c:223: warning: unused variable 'buf'
ssmtp.c: In function 'ssmtp':
ssmtp.c:1442: warning: pointer targets in passing argument 1 of
'to64frombits' differ in signedness
ssmtp.c:1442: warning: pointer targets in passing argument 2 of
'to64frombits' differ in signedness
ssmtp.c:1454: warning: pointer targets in passing argument 1 of
'to64frombits' differ in signedness
ssmtp.c:1454: warning: pointer targets in passing argument 2 of
'to64frombits' differ in signedness
ssmtp.c:1464: warning: pointer targets in passing argument 1 of
'to64frombits' differ in signedness
ssmtp.c:1464: warning: pointer targets in passing argument 2 of
'to64frombits' differ in signedness
make[1]: *** [ssmtp.o] Error 1
make[1]: Leaving directory `/build/buildd/ssmtp-2.61'
make: *** [build] Error 2
******************************************************************************
Build finished at 20051223-1646
FAILED [dpkg-buildpackage died]

The full build log can be found here:
http://experimental.ftbfs.de/fetch.php?&pkg=ssmtp&ver=2.61-5&arch=hurd-i386&stamp=1135352828&file=log&as=raw

MAXPATHLEN and MAXHOSTNAMELEN are not defined on GNU/Hurd, as the GNU
system does not have limitations for maximum path length or hostname
length.

The attached patch by Christopher Bodenstein and Neal Walfield fixes
this, please apply and forward upstream.


thanks,

Michael

-- 
Michael Banck
Debian Developer
[EMAIL PROTECTED]
http://www.advogato.org/person/mbanck/diary.html
diff -Naur ssmtp-2.61.orig/Makefile.in ssmtp-2.61/Makefile.in
--- ssmtp-2.61.orig/Makefile.in 2005-12-25 23:01:45.000000000 +0100
+++ ssmtp-2.61/Makefile.in      2005-12-25 23:02:00.000000000 +0100
@@ -24,7 +24,7 @@
 # Programs
 GEN_CONFIG=$(srcdir)/generate_config
 
-SRCS=ssmtp.c arpadate.c base64.c @SRCS@
+SRCS=ssmtp.c arpadate.c base64.c xgethostname.c @SRCS@
 
 OBJS=$(SRCS:.c=.o)
 
diff -Naur ssmtp-2.61.orig/ssmtp.c ssmtp-2.61/ssmtp.c
--- ssmtp-2.61.orig/ssmtp.c     2005-12-25 23:01:45.000000000 +0100
+++ ssmtp-2.61/ssmtp.c  2005-12-26 15:49:43.000000000 +0100
@@ -38,6 +38,7 @@
 #endif
 #include "ssmtp.h"
 #include <fcntl.h>
+#include "xgethostname.h"
 
 bool_t have_date = False;
 bool_t have_from = False;
@@ -60,7 +61,7 @@
 char *auth_method = (char)NULL;                /* Mechanism for SMTP 
authentication */
 char *mail_domain = (char)NULL;
 char *from = (char)NULL;               /* Use this as the From: address */
-char hostname[MAXHOSTNAMELEN] = "localhost";
+char *hostname;
 char *mailhost = "mailhub";
 char *minus_f = (char)NULL;
 char *minus_F = (char)NULL;
@@ -142,7 +143,8 @@
 */
 void dead_letter(void)
 {
-       char path[(MAXPATHLEN + 1)], buf[(BUF_SZ + 1)];
+       char *path;
+       char buf[(BUF_SZ + 1)];
        struct passwd *pw;
        uid_t uid;
        FILE *fp;
@@ -166,16 +168,21 @@
                return;
        }
 
-       if(snprintf(path, BUF_SZ, "%s/dead.letter", pw->pw_dir) == -1) {
+#define DEAD_LETTER "/dead.letter"
+       path = malloc (strlen (pw->pw_dir) + sizeof (DEAD_LETTER));
+       if (!path) {
                /* Can't use die() here since dead_letter() is called from 
die() */
                exit(1);
        }
-
+       memcpy (path, pw->pw_dir, strlen (pw->pw_dir));
+       memcpy (path + strlen (pw->pw_dir), DEAD_LETTER, sizeof (DEAD_LETTER));
+       
        if((fp = fopen(path, "a")) == (FILE *)NULL) {
                /* Perhaps the person doesn't have a homedir... */
                if(log_level > 0) {
                        log_event(LOG_ERR, "Can't open %s failing horribly!", 
path);
                }
+               free(path);
                return;
        }
 
@@ -192,6 +199,7 @@
                                "Can't close %s/dead.letter, possibly 
truncated", pw->pw_dir);
                }
        }
+       free(path);
 }
 
 /*
@@ -220,21 +228,14 @@
 */
 char *basename(char *str)
 {
-       char buf[MAXPATHLEN +1], *p;
+       char *p;
 
-       if((p = strrchr(str, '/'))) {
-               if(strncpy(buf, ++p, MAXPATHLEN) == (char *)NULL) {
-                       die("basename() -- strncpy() failed");
-               }
-       }
-       else {
-               if(strncpy(buf, str, MAXPATHLEN) == (char *)NULL) {
-                       die("basename() -- strncpy() failed");
-               }
+       p = strrchr(str, '/');
+       if (!p) {
+               p = str;
        }
-       buf[MAXPATHLEN] = (char)NULL;
 
-       return(strdup(buf));
+       return(strdup(p));
 }
 
 /*
@@ -869,8 +870,10 @@
                                }
                        }
                        else if(strcasecmp(p, "HostName") == 0) {
-                               if(strncpy(hostname, q, MAXHOSTNAMELEN) == 
NULL) {
-                                       die("parse_config() -- strncpy() 
failed");
+                               free(hostname);
+                               hostname = strdup(q);
+                               if (!hostname) {
+                                       die("parse_config() -- strdup() 
failed");
                                }
 
                                if(log_level > 0) {
@@ -1982,7 +1985,10 @@
        /* Set the globals */
        prog = basename(argv[0]);
 
-       if(gethostname(hostname, MAXHOSTNAMELEN) == -1) {
+       hostname = xgethostname();
+
+       if(!hostname) {
+               perror("xgethostname");
                die("Cannot get the name of this machine");
        }
        new_argv = parse_options(argc, argv);
diff -Naur ssmtp-2.61.orig/xgethostname.c ssmtp-2.61/xgethostname.c
--- ssmtp-2.61.orig/xgethostname.c      1970-01-01 01:00:00.000000000 +0100
+++ ssmtp-2.61/xgethostname.c   2005-12-25 23:02:00.000000000 +0100
@@ -0,0 +1,125 @@
+/* Copyright (c) 2001 Neal H Walfield <[EMAIL PROTECTED]>.
+   
+   This file is placed into the public domain.  Its distribution
+   is unlimited.
+
+   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+   IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
+   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* NAME
+
+       xgethostname - get the host name.
+
+   SYNOPSIS
+
+       char *xgethostname (void);
+
+   DESCRIPTION
+
+       The xhostname function is intended to replace gethostname(2), a
+       function used to access the host name.  The old interface is
+       inflexable given that it assumes the existance of the
+       MAXHOSTNAMELEN macro, which neither POSIX nor the proposed
+       Single Unix Specification version 3 guarantee to be defined.
+
+   RETURN VALUE
+
+       On success, a malloced, null terminated (possibly truncated)
+       string containing the host name is returned.  On failure,
+       NULL is returned and errno is set.
+ */
+
+#include <sys/param.h> /* For MAXHOSTNAMELEN */
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+
+char *
+xgethostname (void)
+{
+  int size = 0;
+  int addnull = 0;
+  char *buf;
+  int err;
+
+#ifdef MAXHOSTNAMELEN
+  size = MAXHOSTNAMELEN;
+  addnull = 1;
+#else /* MAXHOSTNAMELEN */
+#ifdef _SC_HOST_NAME_MAX
+  size = sysconf (_SC_HOST_NAME_MAX);
+  addnull = 1;
+#endif /* _SC_HOST_NAME_MAX */
+  if (size <= 0)
+    size = 256;
+#endif /* MAXHOSTNAMELEN */
+
+  buf = malloc (size + addnull);
+  if (! buf)
+    {
+      errno = ENOMEM;
+      return NULL;
+    }
+
+  err = gethostname (buf, size);
+  while (err == -1 && errno == ENAMETOOLONG)
+    {
+      free (buf);
+
+      size *= 2;
+      buf = malloc (size + addnull);
+      if (! buf)
+       {
+         errno = ENOMEM;
+         return NULL;
+       }
+      
+      err = gethostname (buf, size);
+    }
+
+  if (err)
+    {
+      if (buf)
+        free (buf);
+      errno = err;
+      return NULL;
+    }
+
+  if (addnull)
+    buf[size] = '\0';
+
+  return buf;
+}
+
+#ifdef WANT_TO_TEST_XGETHOSTNAME
+#include <stdio.h>
+#include <string.h>
+
+int
+main (int argc, char *argv[])
+{
+  char *hostname;
+
+  hostname = xgethostname ();
+  if (! hostname)
+    {
+      perror ("xgethostname");
+      return 1;
+    }
+
+  printf ("%s\n", hostname);
+  free (hostname);
+
+  return 0;
+}
+#endif /* WANT_TO_TEST_XGETHOSTNAME */
diff -Naur ssmtp-2.61.orig/xgethostname.h ssmtp-2.61/xgethostname.h
--- ssmtp-2.61.orig/xgethostname.h      1970-01-01 01:00:00.000000000 +0100
+++ ssmtp-2.61/xgethostname.h   2005-12-25 23:02:00.000000000 +0100
@@ -0,0 +1,48 @@
+/* Copyright (c) 2001 Neal H Walfield <[EMAIL PROTECTED]>.
+   
+   This file is placed into the public domain.  Its distribution
+   is unlimited.
+
+   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+   WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+   IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
+   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+   DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+   GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+   IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+   OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+   IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* NAME
+
+       xgethostname - get the host name.
+
+   SYNOPSIS
+
+       char *xgethostname (void);
+
+   DESCRIPTION
+
+       The xhostname function is intended to replace gethostname(2), a
+       function used to access the host name.  The old interface is
+       inflexable given that it assumes the existance of the
+       MAXHOSTNAMELEN macro, which neither POSIX nor the proposed
+       Single Unix Specification version 3 guarantee to be defined.
+
+   RETURN VALUE
+
+       On success, a malloced, null terminated (possibly truncated)
+       string containing the host name is returned.  On failure,
+       NULL is returned and errno is set.
+ */
+
+#ifndef XGETHOSTNAME
+#define XGETHOSTNAME
+
+char * xgethostname (void);
+
+#endif /* XGETHOSTNAME */
+

Reply via email to