summaryrefslogtreecommitdiff
blob: f8bdd4e9b1798fbdd3e4f21a5646b5397fc3985d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Compensate for platforms that don't have strndup, like Solaris

Index: ssmtp-2.64/configure.in
===================================================================
--- ssmtp-2.64.orig/configure.in
+++ ssmtp-2.64/configure.in
@@ -30,7 +30,7 @@ AC_SEARCH_LIBS(socket, socket)
 dnl Checks for library functions.
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(gethostname socket strdup strstr)
+AC_CHECK_FUNCS(gethostname socket strdup strndup strstr)
 
 dnl Check for optional features
 AC_ARG_ENABLE(logfile, 
Index: ssmtp-2.64/ssmtp.c
===================================================================
--- ssmtp-2.64.orig/ssmtp.c
+++ ssmtp-2.64/ssmtp.c
@@ -846,7 +846,16 @@ char *firsttok(char **s, const char *del
 	if (!rest) {
 		return NULL;
 	}
+#ifdef HAVE_STRNDUP
 	tok=strndup(*s,rest-(*s));
+#else
+	{
+		size_t len = rest - (*s);
+		tok = malloc(sizeof(char) * (len + 1));
+		memcpy(tok, *s, len);
+		tok[len] = '\0';
+	}
+#endif
 	if (!tok) {
 		die("firsttok() -- strndup() failed");
 	}