The SAMATE Project Department of Homeland Security
Downloads:  Selected

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

Test Case IDCandidate38
Bad / GoodBadBad test case
AuthorN/A
Associated test caseN/A
ContributorSecureSoftware
LanguageC
Type of test caseSource Code
Input stringN/A
Expected OutputN/A
InstructionsN/A
Submission date2005-10-28
DescriptioniconIf the variable which is switched on is changed while the switch statement is still in progress undefined activity may occur. (from TCCLASP-5_4_6_10)
Filename
Flaw
  • (?) CWE-362: Race Condition at line 9,10,11

There is no comments :: Submit a comment :: RSS

>./Race_condition_in_switch.c
  1. #include <sys/types.h>
  2. #include <sys/stat.h>
  3. int main(argc,argv){
  4. struct stat *sb;
  5. time_t timer;
  6. lstat("bar.sh",sb);
  7. printf("%d\n",sb->st_ctime);
  8. switch(sb->st_ctime % 2){
  9. case 0: printf("One option\n");break;
  10. case 1: printf("another option\n");break;
  11. default: printf("huh\n");break;
  12. }
  13. return 0;
  14. }
  15.  
  16.  
  17.