[Beignet] [PATCH] Don't read past end of printf format string

Rebecca N. Palmer rebecca_palmer at zoho.com
Sun Nov 1 15:09:12 PST 2015


Reading p+1 when p==end is an out of bounds read.

Signed-off-by: Rebecca Palmer <rebecca_palmer at zoho.com>

---
(Found by valgrind while investigating #90472; probably not the
actual cause of that crash, but still a bug.)

diff --git a/backend/src/llvm/llvm_printf_parser.cpp b/backend/src/llvm/llvm_printf_parser.cpp
index bdaed8a..f427107 100644
--- a/backend/src/llvm/llvm_printf_parser.cpp
+++ b/backend/src/llvm/llvm_printf_parser.cpp
@@ -229,7 +229,7 @@ again:
         printf("string end with %%\n");
         goto error;
       }
-      if (*(p + 1) == '%') { // %%
+      if (p + 1 < end && *(p + 1) == '%') { // %%
         p += 2;
         goto again;
       }



More information about the Beignet mailing list