Safe and secure code for a e-voting system software
The applied CERT rules and recommendations are as follows -
- DCL04-C Not more than 1 var per declaration.
- INT01-C use size_t to represent the size of an object
- EXP20-C explicitly check if condition.
- EXP31-C. Do not modify constant values
- STR05-A. Prefer making string literals const-qualified //any attempt made to change these leads to an error
- STR30-C. Do not attempt to modify string literals
- //MEM02-A. Do not cast the return value from malloc()
- MEM03-A. Clear sensitive information stored in dynamic memory prior to //deallocation //at the end of use of ptr we need to free it ie deallocate it
- //MEM31-C. Free dynamically allocated memory exactly once
- //MEM34-C. Only free memory allocated dynamically 11.//MEM01-A. Set pointers to dynamically allocated memory to NULL after they //are released
- //MEM31-C. Free dynamically allocated memory exactly once //we need to do this
- //FIO06-A. Create files with appropriate access permissions
- //FIO11-A. Take care when specifying the mode parameter of fopen()
- //PRE08-C. Guarantee that header file names are unique.
- //DCL07-C.Include the appropriate type information in function declarators.
- //DCL05-A. Use typedefs to improve code readability
- //MSC00-A. Compile cleanly at high warning levels ??????
- //DCL06-A. Use meaningful symbolic constants to represent literal values in program logic
- //ARR31-C. Use consistent array notation across all source files
- //FIO40-C. Reset strings on fgets() failure //fn that creates number of files equal to number of candidates ?????? 22.//MSC07-A. Detect and remove dead code
- //MSC13-A. Detect and remove unused values
- //MSC12-A. Detect and remove code that has no effect
//fn to delete illegal vote 25. //MSC04-A. Use comments consistently and in a readable fashion 26. //DCL32-C. Guarantee identifiers are unique 27. /FIO31-C. Do not simultaneously open the same file multiple times 28. //FIO46-C. Do not access a closed file 29. STR31-C enough space for char data // and null terminator.
- //DCL03-A. Place const as the rightmost declaration specifier
- //DCL01-A. Do not reuse variable names in sub-scopes
- //FIO31-C. Do not simultaneously open the same file multiple times.
- FIO35-C. Use feof() and ferror() to detect end-of-file and file errors