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

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

Test Case IDCandidate153720
Bad / Good / MixedBadBad test case
AuthorIARPA STONESOUP Test and Evaluation team
Test suite: 102  
Application: 5  
Added byCharles Oliveira
Type of test caseSource Code
Input string
Expected Output
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 heap 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.
- Base program: PostgreSQL
- Source Taint: SHARED_MEMORY
- Data Type: TYPEDEF
- Control Flow: INFINITE_LOOP

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): 726, 727, 728, 729, 730