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

Pan, Xiuli xiuli.pan at intel.com
Mon Nov 2 17:50:34 PST 2015


LGTM, but the commit line is too long, could you make the newlines by
hand to make sure the commit is readable for all situation like this.
Or we could help you to break the line into serval lines.
Also it seems the patch is made from git diff? Could you try to use
[git format-patch -s] to create patches and [--subject-prefix] to make
version, then use git send-email to send the patch to the mail list. It will
help us to make the patch apply easier. 

Here my analysis may help with your commit:
When p+1 is '%' the p will be end+2 and __parse_printf_state will return
error code, then this line's parse print format will be null. It will result in
a wrong message "Parse One printf inst failed, may have some error" 
(line 584) and some lines missing randomly, for the bug only occurs when
p+1 is '%' only.

You can try to read for l584 to figure out what I am talking about, hope
can enjoy to know how your patch help us.

Thanks
Xiuli Pan

-----Original Message-----
From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of Rebecca N. Palmer
Sent: Tuesday, November 3, 2015 6:57 AM
To: beignet at lists.freedesktop.org
Subject: Re: [Beignet] [PATCH v2] GBE: Don't read past end of printf format string

When p==end (the null terminator byte), don't try to read p+1 (outside the string, so might be an invalid address or a '%' from a different object).

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

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;
       }

_______________________________________________
Beignet mailing list
Beignet at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/beignet


More information about the Beignet mailing list