Skip to content

Instantly share code, notes, and snippets.

@JIghtuse
Last active April 4, 2016 10:34
Show Gist options
  • Select an option

  • Save JIghtuse/aaa4bf9be99026da7be355e130cf3bba to your computer and use it in GitHub Desktop.

Select an option

Save JIghtuse/aaa4bf9be99026da7be355e130cf3bba to your computer and use it in GitHub Desktop.
#include <stdio.h>
void f()
{
char s[8] = "";
snprintf(s, sizeof(s), "ip");
}
@JIghtuse
Copy link
Author

JIghtuse commented Apr 4, 2016

$ cppcheck --debug buf.c                                                                                                                                                  
Checking buf.c...


##file buf.c
1:
2:
3: void f ( )
4: {
5: char s@1 [ 8 ] = "" ;
6: snprintf ( "" , 8 , "ip" ) ;
7: }



##Value flow
Line 5
  8 always 8
  "" always ""
Line 6
  "" always ""
  8 always 8
  "ip" always "ip"
[/tmp/buf.c:6]: (error) Buffer is accessed out of bounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment