0002-Add-a-typecast-to-avoid-32-bit-integer-overflow-in-t.patch 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. From 1cbb088f4be95e7a02627f64de60653ef2b13ab5 Mon Sep 17 00:00:00 2001
  2. From: drh <>
  3. Date: Sun, 16 Feb 2025 10:57:25 +0000
  4. Subject: [PATCH] Add a typecast to avoid 32-bit integer overflow in the
  5. concat_ws() function with an enormous separator values and many arguments.
  6. Fixes the following CVE:
  7. - CVE-2025-29087: In SQLite 3.44.0 through 3.49.0 before 3.49.1,
  8. the concat_ws() SQL function can cause memory to be
  9. written beyond the end of a malloc-allocated buffer.
  10. For more info see https://nvd.nist.gov/vuln/detail/CVE-2025-29087
  11. Upstream: https://sqlite.org/src/info/498e3f1cf57f164f
  12. Signed-off-by: Titouan Christophe <titouan.christophe@mind.be>
  13. ---
  14. sqlite3.c | 2 +-
  15. 1 file changed, 1 insertion(+), 1 deletion(-)
  16. diff --git a/sqlite3.c b/sqlite3.c
  17. index 80433f6..8a43734 100644
  18. --- a/sqlite3.c
  19. +++ b/sqlite3.c
  20. @@ -130954,7 +130954,7 @@ static void concatFuncCore(
  21. for(i=0; i<argc; i++){
  22. n += sqlite3_value_bytes(argv[i]);
  23. }
  24. - n += (argc-1)*nSep;
  25. + n += (argc-1)*(i64)nSep;
  26. z = sqlite3_malloc64(n+1);
  27. if( z==0 ){
  28. sqlite3_result_error_nomem(context);
  29. --
  30. 2.49.0