SAMATE Logo NIST Logo The SAMATE Project Department of Homeland Security
Downloads:  Download this Test Case #153813

Back to the previous page... Back to the previous page

Test Case IDCandidate153813
Bad / Good / MixedBadBad test case
AuthorIARPA STONESOUP Test and Evaluation team
Associations
Test suite: 102  
Application: 7  
Added byCharles Oliveira
LanguageC
Type of test caseSource Code
Input string
Expected Output
Instructions
See src/INSTALL file for instructions on how to install.
Submission date2015-10-06
DescriptionThis test case creates a buffer on the stack of 1024 bytes and a struct on the stack containing a 64-byte buffer and a pointer to the beginning of that buffer. It copies the taint source into the 1024-char buffer. It checks if the length of the taint source is less than the length of the 64-byte buffer. If it is, it uses strncpy to copy the taint source into the 64-byte buffer, with a maximum value of 1024 bytes. However, strncpy always writes the maximum number of bytes, and so writes 1024 bytes. This overflows the other data in the struct, including the pointer that originally pointed to the beginning of the 64-byte buffer. The test case then calls strlen on that pointer in the struct. However, since the pointer has been corrupted by the overflow, this causes a segmentation fault.
Metadata
- Base program: Subversion
- Source Taint: FILE_CONTENTS
- Data Type: ARRAY
- Data Flow: ADDRESS_AS_NONLINEAR_EXPRESSION
- Control Flow: INDIRECTLY_RECURSIVE
File(s)
Flaw

There are no comments
Have any comments on this test case? Please, .

File Contains:
CWE-806: Buffer Access Using Size of Source Buffer on line(s): 1075, 1076, 1077, 1078, 1079