summaryrefslogtreecommitdiff
path: root/lang/clisp/files/patch-modules__fastcgi__fastcgi_wrappers.c
blob: 95297b568d4200bcbdf5cc9b01f6c411c56db7b8 (plain) (blame)
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
37
38
39
40
41
--- modules/fastcgi/fastcgi_wrappers.c.orig	2018-11-12 00:05:07 UTC
+++ modules/fastcgi/fastcgi_wrappers.c
@@ -41,7 +41,26 @@ extern char **environ;
 
 /* Crank this up as needed */
 #define TEMPBUFSIZE 65536
+ 
+#ifdef __FreeBSD__
+char* t_strndup(const char* string, size_t n)
+{
+	char* copy_string = 0;
+ 
+	if(0 == string || 0 == n)
+		return 0;
+	
+	copy_string = (char*) malloc(n + 1);	
+	if(0 == copy_string)
+		return 0;
+	
+	memcpy(copy_string, string, n);
+	*(copy_string + n) = '\0';		
 
+	return copy_string;
+}
+#endif
+
 /* Local functions */
 static char * read_stdio(FILE *);
 static int    write_stdio(FILE *, char *, int);
@@ -93,7 +112,11 @@ char ** fcgi_env() {
       result[i+1] = NULL;
     }
     else {
+#ifdef __FreeBSD__
+		result[i] = t_strndup(*envp, equ - *envp);
+#else
       result[i] = strndup(*envp, equ - *envp);
+#endif
       result[i+1] = strdup(equ + 1);
     }
   }