You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.0 KiB

  1. From 18fdf802d31354c62a27cc5a63b196780a0d486e Mon Sep 17 00:00:00 2001
  2. From: Yousong Zhou <yszhou4tech@gmail.com>
  3. Date: Wed, 29 Apr 2015 16:30:17 +0800
  4. Subject: [PATCH 206/210] xl2tpd: start_pppd: place opts after "plugin
  5. pppol2tp.so".
  6. so that plugin options like pppol2tp_debug_mark can be recognized by
  7. pppd. While doing this also add bound check to prevent potential buffer
  8. overflow problem.
  9. ---
  10. xl2tpd.c | 22 +++++++++++-----------
  11. 1 file changed, 11 insertions(+), 11 deletions(-)
  12. diff --git a/xl2tpd.c b/xl2tpd.c
  13. index 6c945fc..017adfd 100644
  14. --- a/xl2tpd.c
  15. +++ b/xl2tpd.c
  16. @@ -382,7 +382,6 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
  17. /* char a, b; */
  18. char tty[512];
  19. char *stropt[80];
  20. - struct ppp_opts *p;
  21. #ifdef USE_KERNEL
  22. struct sockaddr_pppol2tp sax;
  23. int flags;
  24. @@ -396,16 +395,7 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
  25. struct call *sc;
  26. struct tunnel *st;
  27. - p = opts;
  28. stropt[0] = strdup (PPPD);
  29. - while (p)
  30. - {
  31. - stropt[pos] = (char *) malloc (strlen (p->option) + 1);
  32. - strncpy (stropt[pos], p->option, strlen (p->option) + 1);
  33. - pos++;
  34. - p = p->next;
  35. - }
  36. - stropt[pos] = NULL;
  37. if (c->pppd > 0)
  38. {
  39. l2tp_log(LOG_WARNING, "%s: PPP already started on call!\n", __FUNCTION__);
  40. @@ -467,7 +457,6 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
  41. snprintf (stropt[pos], 10, "%d", c->ourcid);
  42. pos++;
  43. }
  44. - stropt[pos] = NULL;
  45. }
  46. else
  47. #endif
  48. @@ -497,6 +486,17 @@ int start_pppd (struct call *c, struct ppp_opts *opts)
  49. return -EINVAL;
  50. }
  51. stropt[pos++] = strdup(tty);
  52. + }
  53. +
  54. + {
  55. + struct ppp_opts *p = opts;
  56. + int maxn_opts = sizeof(stropt) / sizeof(stropt[0]) - 1;
  57. + while (p && pos < maxn_opts)
  58. + {
  59. + stropt[pos] = strdup (p->option);
  60. + pos++;
  61. + p = p->next;
  62. + }
  63. stropt[pos] = NULL;
  64. }
  65. --
  66. 1.7.10.4