234 lines
15 KiB
Text
234 lines
15 KiB
Text
/home/romenskiy2012/projects/memtest/main.c:98:13: warning: Call to function 'sscanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sscanf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
|
|
98 | if (sscanf(line, "MemAvailable: %lu kB", &available) == 1) break;
|
|
| ^~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:98:13: note: Call to function 'sscanf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sscanf_s' in case of C11
|
|
98 | if (sscanf(line, "MemAvailable: %lu kB", &available) == 1) break;
|
|
| ^~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:175:9: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
|
|
175 | sprintf(char_dynamic, "%p",(void*)&error_info->actual);
|
|
| ^~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:175:9: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
|
|
175 | sprintf(char_dynamic, "%p",(void*)&error_info->actual);
|
|
| ^~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:182:9: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
|
|
182 | sprintf(char_dynamic, "0x%08X",error_info->expected);
|
|
| ^~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:182:9: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
|
|
182 | sprintf(char_dynamic, "0x%08X",error_info->expected);
|
|
| ^~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:187:9: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
|
|
187 | sprintf(char_dynamic, "0x%08X",error_info->actual);
|
|
| ^~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:187:9: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
|
|
187 | sprintf(char_dynamic, "0x%08X",error_info->actual);
|
|
| ^~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:196:9: warning: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11 [clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling]
|
|
196 | sprintf(char_dynamic, "0x%08X",test_patterns[i]);
|
|
| ^~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:196:9: note: Call to function 'sprintf' is insecure as it does not provide security checks introduced in the C11 standard. Replace with analogous functions that support length arguments or provides boundary checks such as 'sprintf_s' in case of C11
|
|
196 | sprintf(char_dynamic, "0x%08X",test_patterns[i]);
|
|
| ^~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:304:21: warning: Call to 'malloc' has an allocation size of 0 bytes [clang-analyzer-optin.portability.UnixAPI]
|
|
304 | uint32_t *mem = malloc(mem_size);
|
|
| ^ ~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:281:34: note: Calling 'get_mem_available_mb'
|
|
281 | unsigned long int mem_size = get_mem_available_mb();
|
|
| ^~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:93:15: note: Assuming pointer value is null
|
|
93 | FILE* f = fopen("/proc/meminfo", "r");
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:93:15: note: Assuming that 'fopen' fails
|
|
93 | FILE* f = fopen("/proc/meminfo", "r");
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:94:10: note: 'f' is null
|
|
94 | if (!f) return 0;
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:94:5: note: Taking true branch
|
|
94 | if (!f) return 0;
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:94:13: note: Returning zero
|
|
94 | if (!f) return 0;
|
|
| ^~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:281:34: note: Returning from 'get_mem_available_mb'
|
|
281 | unsigned long int mem_size = get_mem_available_mb();
|
|
| ^~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:281:5: note: 'mem_size' initialized to 0
|
|
281 | unsigned long int mem_size = get_mem_available_mb();
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:282:9: note: Assuming field 'test' is 0
|
|
282 | if (args.test){
|
|
| ^~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:282:5: note: Taking false branch
|
|
282 | if (args.test){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:286:14: note: Field 'mod_status' is <= 0
|
|
286 | if (args.mod_status > 0){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:286:5: note: Taking false branch
|
|
286 | if (args.mod_status > 0){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:294:14: note: Field 'tred' is < 2
|
|
294 | if (args.tred < 2){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:294:5: note: Taking true branch
|
|
294 | if (args.tred < 2){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:295:19: note: Field 'json' is 0
|
|
295 | if (!args.json) printf("Количество потоков изменено на 2\n");
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:295:9: note: Taking true branch
|
|
295 | if (!args.json) printf("Количество потоков изменено на 2\n");
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:298:15: note: Field 'json' is 0
|
|
298 | if (!args.json)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:298:5: note: Taking true branch
|
|
298 | if (!args.json)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:304:21: note: Call to 'malloc' has an allocation size of 0 bytes
|
|
304 | uint32_t *mem = malloc(mem_size);
|
|
| ^ ~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:304:21: warning: malloc is called with a tainted (potentially attacker controlled) value. Make sure the value is bound checked [clang-analyzer-optin.taint.TaintedAlloc]
|
|
304 | uint32_t *mem = malloc(mem_size);
|
|
| ^~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:281:34: note: Calling 'get_mem_available_mb'
|
|
281 | unsigned long int mem_size = get_mem_available_mb();
|
|
| ^~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:93:15: note: Taint originated here
|
|
93 | FILE* f = fopen("/proc/meminfo", "r");
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:93:15: note: Taint propagated to the return value
|
|
93 | FILE* f = fopen("/proc/meminfo", "r");
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:93:15: note: Assuming that 'fopen' is successful
|
|
93 | FILE* f = fopen("/proc/meminfo", "r");
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:94:10: note: 'f' is non-null
|
|
94 | if (!f) return 0;
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:94:5: note: Taking false branch
|
|
94 | if (!f) return 0;
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:97:12: note: Taint propagated to the 1st argument
|
|
97 | while (fgets(line, sizeof(line), f)) {
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:97:5: note: Loop condition is true. Entering loop body
|
|
97 | while (fgets(line, sizeof(line), f)) {
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:98:13: note: Taint propagated to the 3rd argument
|
|
98 | if (sscanf(line, "MemAvailable: %lu kB", &available) == 1) break;
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:98:13: note: Assuming the condition is true
|
|
98 | if (sscanf(line, "MemAvailable: %lu kB", &available) == 1) break;
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:98:9: note: Taking true branch
|
|
98 | if (sscanf(line, "MemAvailable: %lu kB", &available) == 1) break;
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:98:68: note: Execution continues on line 100
|
|
98 | if (sscanf(line, "MemAvailable: %lu kB", &available) == 1) break;
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:101:15: note: Field 'json' is 0
|
|
101 | if (!args.json){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:101:5: note: Taking true branch
|
|
101 | if (!args.json){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:281:34: note: Returning from 'get_mem_available_mb'
|
|
281 | unsigned long int mem_size = get_mem_available_mb();
|
|
| ^~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:282:9: note: Assuming field 'test' is 0
|
|
282 | if (args.test){
|
|
| ^~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:282:5: note: Taking false branch
|
|
282 | if (args.test){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:286:14: note: Field 'mod_status' is <= 0
|
|
286 | if (args.mod_status > 0){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:286:5: note: Taking false branch
|
|
286 | if (args.mod_status > 0){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:294:14: note: Field 'tred' is < 2
|
|
294 | if (args.tred < 2){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:294:5: note: Taking true branch
|
|
294 | if (args.tred < 2){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:295:19: note: Field 'json' is 0
|
|
295 | if (!args.json) printf("Количество потоков изменено на 2\n");
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:295:9: note: Taking true branch
|
|
295 | if (!args.json) printf("Количество потоков изменено на 2\n");
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:298:15: note: Field 'json' is 0
|
|
298 | if (!args.json)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:298:5: note: Taking true branch
|
|
298 | if (!args.json)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:304:21: note: malloc is called with a tainted (potentially attacker controlled) value. Make sure the value is bound checked
|
|
304 | uint32_t *mem = malloc(mem_size);
|
|
| ^~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:325:5: warning: Potential leak of memory pointed to by 'thread' [clang-analyzer-unix.Malloc]
|
|
325 | free(mem);
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:282:9: note: Assuming field 'test' is 0
|
|
282 | if (args.test){
|
|
| ^~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:282:5: note: Taking false branch
|
|
282 | if (args.test){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:286:9: note: Assuming field 'mod_status' is <= 0
|
|
286 | if (args.mod_status > 0){
|
|
| ^~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:286:5: note: Taking false branch
|
|
286 | if (args.mod_status > 0){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:294:9: note: Assuming field 'tred' is >= 2
|
|
294 | if (args.tred < 2){
|
|
| ^~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:294:5: note: Taking false branch
|
|
294 | if (args.tred < 2){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:298:9: note: Assuming field 'json' is not equal to 0
|
|
298 | if (!args.json)
|
|
| ^~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:298:5: note: Taking false branch
|
|
298 | if (!args.json)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:305:9: note: Assuming 'mem' is non-null
|
|
305 | if (!mem) {
|
|
| ^~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:305:5: note: Taking false branch
|
|
305 | if (!mem) {
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:314:25: note: Memory is allocated
|
|
314 | pthread_t *thread = malloc(sizeof(pthread_t) * args.tred);
|
|
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:315:15: note: Field 'json' is not equal to 0
|
|
315 | if (!args.json)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:315:5: note: Taking false branch
|
|
315 | if (!args.json)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:317:22: note: 'i' is not equal to field 'tred'
|
|
317 | for (bool i = 0;(i != args.tred); i++)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:317:5: note: Loop condition is true. Entering loop body
|
|
317 | for (bool i = 0;(i != args.tred); i++)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:317:22: note: Assuming 'i' is equal to field 'tred'
|
|
317 | for (bool i = 0;(i != args.tred); i++)
|
|
| ^~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:317:5: note: Loop condition is false. Execution continues on line 320
|
|
317 | for (bool i = 0;(i != args.tred); i++)
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:320:11: note: Assuming 'iterations' is equal to 0
|
|
320 | for (;iterations != 0; iterations--){
|
|
| ^~~~~~~~~~~~~~~
|
|
/home/romenskiy2012/projects/memtest/main.c:320:5: note: Loop condition is false. Execution continues on line 325
|
|
320 | for (;iterations != 0; iterations--){
|
|
| ^
|
|
/home/romenskiy2012/projects/memtest/main.c:325:5: note: Potential leak of memory pointed to by 'thread'
|
|
325 | free(mem);
|
|
| ^
|