packages/net/xl2tpd/patches/206-xl2tpd-start_pppd-place-opts-after-plugin-pppol2tp.s.patch
Yousong Zhou 59f33d2aa7 xl2tpd: refactor for more resilience.
- Use netifd no_proto_task for notifying that xl2tpd does not have a
   protocol task running.
 - Use procd for xl2tpd service management.
 - Refreshed 2xx patches to

    - Prevent leftover regular type control result file.
    - Allow xl2tpd run as foreground process while logging via syslog.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>

 - bumped version
 - removed dependency on `ip` package as routes are setup by netifd
   if iproute2 is actually required, please depend on
   `@(PACKAGE_ip||PACKAGE_ip-full)` instead of `ip`

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
2015-05-24 12:18:38 +02:00

71 lines
2 KiB
Diff

From 18fdf802d31354c62a27cc5a63b196780a0d486e Mon Sep 17 00:00:00 2001
From: Yousong Zhou <yszhou4tech@gmail.com>
Date: Wed, 29 Apr 2015 16:30:17 +0800
Subject: [PATCH 206/210] xl2tpd: start_pppd: place opts after "plugin
pppol2tp.so".
so that plugin options like pppol2tp_debug_mark can be recognized by
pppd. While doing this also add bound check to prevent potential buffer
overflow problem.
---
xl2tpd.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/xl2tpd.c b/xl2tpd.c
index 6c945fc..017adfd 100644
--- a/xl2tpd.c
+++ b/xl2tpd.c
@@ -382,7 +382,6 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
/* char a, b; */
char tty[512];
char *stropt[80];
- struct ppp_opts *p;
#ifdef USE_KERNEL
struct sockaddr_pppol2tp sax;
int flags;
@@ -396,16 +395,7 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
struct call *sc;
struct tunnel *st;
- p = opts;
stropt[0] = strdup (PPPD);
- while (p)
- {
- stropt[pos] = (char *) malloc (strlen (p->option) + 1);
- strncpy (stropt[pos], p->option, strlen (p->option) + 1);
- pos++;
- p = p->next;
- }
- stropt[pos] = NULL;
if (c->pppd > 0)
{
l2tp_log(LOG_WARNING, "%s: PPP already started on call!\n", __FUNCTION__);
@@ -467,7 +457,6 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
snprintf (stropt[pos], 10, "%d", c->ourcid);
pos++;
}
- stropt[pos] = NULL;
}
else
#endif
@@ -497,6 +486,17 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
return -EINVAL;
}
stropt[pos++] = strdup(tty);
+ }
+
+ {
+ struct ppp_opts *p = opts;
+ int maxn_opts = sizeof(stropt) / sizeof(stropt[0]) - 1;
+ while (p && pos < maxn_opts)
+ {
+ stropt[pos] = strdup (p->option);
+ pos++;
+ p = p->next;
+ }
stropt[pos] = NULL;
}
--
1.7.10.4