0001-gweb-Fix-OOB-write-in-received_data.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From d1a5ede5d255bde8ef707f8441b997563b9312bd Mon Sep 17 00:00:00 2001
  2. From: Nathan Crandall <ncrandall@tesla.com>
  3. Date: Tue, 12 Jul 2022 08:56:34 +0200
  4. Subject: gweb: Fix OOB write in received_data()
  5. There is a mismatch of handling binary vs. C-string data with memchr
  6. and strlen, resulting in pos, count, and bytes_read to become out of
  7. sync and result in a heap overflow. Instead, do not treat the buffer
  8. as an ASCII C-string. We calculate the count based on the return value
  9. of memchr, instead of strlen.
  10. Fixes: CVE-2022-32292
  11. [Retrieved from:
  12. https://git.kernel.org/pub/scm/network/connman/connman.git/commit/?id=d1a5ede5d255bde8ef707f8441b997563b9312bd]
  13. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  14. ---
  15. gweb/gweb.c | 2 +-
  16. 1 file changed, 1 insertion(+), 1 deletion(-)
  17. diff --git a/gweb/gweb.c b/gweb/gweb.c
  18. index 12fcb1d8..13c6c5f2 100644
  19. --- a/gweb/gweb.c
  20. +++ b/gweb/gweb.c
  21. @@ -918,7 +918,7 @@ static gboolean received_data(GIOChannel *channel, GIOCondition cond,
  22. }
  23. *pos = '\0';
  24. - count = strlen((char *) ptr);
  25. + count = pos - ptr;
  26. if (count > 0 && ptr[count - 1] == '\r') {
  27. ptr[--count] = '\0';
  28. bytes_read--;
  29. --
  30. cgit