LGTM<div><br></div><div><div>--- a/test/Sema/format-strings.c</div><div>+++ b/test/Sema/format-strings.c</div><div>@@ -86,12 +86,8 @@ void check_conditional_literal(const char* s, int i) {</div><div> </div><div> void check_writeback_specifier()</div>
<div> {</div><div>-  int x;</div><div>   char *b;</div><div>-</div><div>-  printf("%n",&x); // expected-warning {{'%n' in format string discouraged}}</div><div>-  sprintf(b,"%d%%%n",1, &x); // expected-warning {{'%n' in format string dis}}</div>
<div><br></div><div>Maybe keep these ones as no-warning tests?</div><br><div class="gmail_quote">On Mon, Jul 30, 2012 at 11:28 AM, Matt Beaumont-Gay <span dir="ltr"><<a href="mailto:matthewbg@google.com" target="_blank">matthewbg@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Following on Hans's r160966...<br>
<br>
Clang currently warns about any use of the '%n' format specifier:<br>
test.cc:5:14: warning: use of '%n' in format string discouraged<br>
(potentially insecure) [-Wformat-security]<br>
  printf("%d%n", i, &n);<br>
            ~^<br>
<br>
While '%n' can be used for evil in an attacker-controlled format<br>
string, there isn't any acute danger in using it in a literal format<br>
string with an argument of the appropriate type. (If preceding format<br>
arguments are derived from untrusted input, then the value written to<br>
the '%n' argument can be somewhat controlled by an attacker, but this<br>
is no worse than any other means by which a program may set a variable<br>
based on untrusted input.) This patch removes the blanket warning for<br>
any use of '%n'; misuses of it, e.g. passing the wrong argument type,<br>
will be caught by the functionality that Hans just added.<br>
<span class="HOEnZb"><font color="#888888"><br>
-Matt<br>
</font></span><br>_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
<br></blockquote></div><br></div>