summaryrefslogtreecommitdiff
path: root/package/l2tp/l2tp-no-gnu-extensions.patch
blob: ef07e26f57f8248df1f941567ffe955783454c69 (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
--- l2tpd-0.70-pre20031121.oorig/avpsend.c	2006-12-28 16:00:26.000000000 +0100
+++ l2tpd-0.70-pre20031121/avpsend.c	2006-12-28 16:21:06.000000000 +0100
@@ -98,19 +98,26 @@ int add_hostname_avp(struct buffer *buf,
 	int sz = 0;
 	if(t->lac && t->lac->hostname[0]) {
 		strncpy(n,t->lac->hostname, sizeof(n));
-		sz = strnlen(t->lac->hostname, sizeof(t->lac->hostname));
+		sz = strlen(t->lac->hostname);
+		if (sz > sizeof(t->lac->hostname))
+			sz = sizeof(t->lac->hostname);
 	}
 	else if(t->lns && t->lns->hostname[0]) {
 		strncpy(n,t->lns->hostname, sizeof(n));
-		sz = strnlen(t->lns->hostname, sizeof(t->lns->hostname));
+		sz = strlen(t->lns->hostname);
+		if (sz > sizeof(t->lns->hostname))
+			sz = sizeof(t->lns->hostname);
 	}
 	else {
 		if(gethostname(n, STRLEN)) {
 			strcpy(n,"eriwan");
 			sz = 6;
 		}
-		else
-			sz = strnlen(n, sizeof(n));
+		else {
+			sz = strlen(n);
+			if (sz > sizeof(n))
+				sz = sizeof(n);
+		}
 	}
 	if(add_avp(buf, HOSTNAME_AVP, n, sz, 1))
 		return 1;