[PATCH] [static analyzer] Emit buffer overflow warning in strcpy fucntion when uninitialized source array of known length(> dest length) is used
Arthur O'Dwyer
arthur.j.odwyer at gmail.com
Tue Oct 28 12:13:53 PDT 2014
Your test cases and commit message look wrong to me.
```
char x[3] = "abc";
char y[4] = "ab";
strcpy(x,y); // This should not warn, or at least should give a suppressible diagnostic,
// since no overflow occurs: "ab" fits into x just fine
char x[3] = "abc";
char y[4];
strcpy(x,y); // This should give a use-before-def diagnostic for y
char x[3] = "abc";
char y[100];
strcpy(y, x); // This should give the "overflow" diagnostic, since it definitely attempts to strcpy an array of char that is not null-terminated
```
http://reviews.llvm.org/D6012
More information about the cfe-commits
mailing list