0001-pppd-Fix-bounds-check.patch 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 8d7970b8f3db727fe798b65f3377fe6787575426 Mon Sep 17 00:00:00 2001
  2. From: Paul Mackerras <paulus@ozlabs.org>
  3. Date: Mon, 3 Feb 2020 15:53:28 +1100
  4. Subject: [PATCH] pppd: Fix bounds check in EAP code
  5. Given that we have just checked vallen < len, it can never be the case
  6. that vallen >= len + sizeof(rhostname). This fixes the check so we
  7. actually avoid overflowing the rhostname array.
  8. Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
  9. Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
  10. ---
  11. pppd/eap.c | 4 ++--
  12. 1 file changed, 2 insertions(+), 2 deletions(-)
  13. diff --git a/pppd/eap.c b/pppd/eap.c
  14. index 94407f56..1b93db01 100644
  15. --- a/pppd/eap.c
  16. +++ b/pppd/eap.c
  17. @@ -1420,7 +1420,7 @@ int len;
  18. }
  19. /* Not so likely to happen. */
  20. - if (vallen >= len + sizeof (rhostname)) {
  21. + if (len - vallen >= sizeof (rhostname)) {
  22. dbglog("EAP: trimming really long peer name down");
  23. BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
  24. rhostname[sizeof (rhostname) - 1] = '\0';
  25. @@ -1846,7 +1846,7 @@ int len;
  26. }
  27. /* Not so likely to happen. */
  28. - if (vallen >= len + sizeof (rhostname)) {
  29. + if (len - vallen >= sizeof (rhostname)) {
  30. dbglog("EAP: trimming really long peer name down");
  31. BCOPY(inp + vallen, rhostname, sizeof (rhostname) - 1);
  32. rhostname[sizeof (rhostname) - 1] = '\0';