Рефакторинг, удалени логика однопоточности. сделан режим тестирование для тестирование тестирование.
This commit is contained in:
parent
9126670a8a
commit
11a7dff4b4
4 changed files with 293 additions and 79 deletions
|
|
@ -8,6 +8,8 @@ void print_help(const char *progname) {
|
|||
printf(" -j, --json вывод в виде json\n");
|
||||
printf(" -p, --pretest-delay N указать сколько секунд ждать\n\t\t\tперед проверкой памяти после записи\n");
|
||||
printf(" --simulate-errors создаёт ошибки с вероятностью\n\t\t\t%%0.0001 каждый на 1 из 1000 проверок\n");
|
||||
printf(" -m, --mod N устанавливает уроветь привелигированости\n\t\t\t0 - not root 1 - onli root 2 - kernel mod.\n");
|
||||
printf(" --test Устанавливает mem_size на 100000000\n");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -19,12 +21,15 @@ void aaa(int* argc, char *argv[], int* pretest_delay){
|
|||
{"iterations", required_argument, 0, 'i'},
|
||||
{"json", no_argument, 0, 'j'},
|
||||
{"pretest-delay", no_argument, 0, 'p'},
|
||||
{"simulate-errors", no_argument, 0, 's'},
|
||||
{"simulate-errors", no_argument, 0, 0},
|
||||
{"mod", required_argument, 0, 'm'},
|
||||
{"test", no_argument, 0, 0},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt_long(*argc, argv, "ht:i:jp:", long_options, NULL)) != -1) {
|
||||
int long_index = 0;
|
||||
while ((opt = getopt_long(*argc, argv, "ht:i:jp:m:t", long_options, &long_index)) != -1) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
print_help(argv[0]);
|
||||
|
|
@ -41,8 +46,15 @@ void aaa(int* argc, char *argv[], int* pretest_delay){
|
|||
case 'j':
|
||||
args.json = 1;
|
||||
break;
|
||||
case 's':
|
||||
case 'm':
|
||||
args.mod_status = atoi(optarg);
|
||||
break;
|
||||
case 0: // Only long option with no short version
|
||||
if (strcmp(long_options[long_index].name, "test") == 0) {
|
||||
args.test = 1;
|
||||
} else if (strcmp(long_options[long_index].name, "simulate-errors") == 0) {
|
||||
args.simulate_errors = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
print_help(argv[0]);
|
||||
|
|
|
|||
103
main.c
103
main.c
|
|
@ -17,6 +17,8 @@ struct args_struct{
|
|||
int json;
|
||||
size_t words;
|
||||
int simulate_errors;
|
||||
int test;
|
||||
int mod_status;
|
||||
};
|
||||
struct args_struct args;
|
||||
#include "cJSON/cJSON.h"
|
||||
|
|
@ -128,7 +130,13 @@ void meseng_test_and_slip(){
|
|||
}
|
||||
}
|
||||
|
||||
void test_patern(struct tred_pizdec* meta,unsigned long* thread, int tred, int* err, int p, int test_tipe){
|
||||
void test_patern(struct tred_pizdec* meta,unsigned long* thread, int tred, int* err, int p){
|
||||
// test_list[test_list_id]
|
||||
int test_tipe = p - 2;
|
||||
if (test_tipe<=1){
|
||||
test_tipe=1;
|
||||
}
|
||||
else p = 0;
|
||||
meseng_proses(test_tipe, p);
|
||||
for (bool i = 0;(i != tred); i++){// test
|
||||
meta[i].id = p;
|
||||
|
|
@ -262,22 +270,39 @@ void mem_meta_create(struct tred_pizdec* meta, uint32_t *mem, int i){
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0) {
|
||||
perror("mlockall ошибка!\nВозможно недостаточно прав!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
args.tred = 1;
|
||||
args.iterations = 1;
|
||||
args.json = 0;
|
||||
args.simulate_errors = 0;
|
||||
args.mod_status = 0;
|
||||
|
||||
aaa(&argc, argv, &pretest_delay);
|
||||
|
||||
unsigned long int mem_size = get_mem_available_mb();
|
||||
if (args.test){
|
||||
mem_size = 100000000;
|
||||
}
|
||||
|
||||
if (args.mod_status > 0){
|
||||
if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0) {
|
||||
perror("mlockall ошибка!\nВозможно недостаточно прав!\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (args.tred < 2){
|
||||
if (!args.json) printf("Количество потоков изменено на 2\n");
|
||||
args.tred = 2;
|
||||
}
|
||||
else if (args.tred > 250){
|
||||
if (!args.json) printf("Количество потоков изменено на 250\n");
|
||||
args.tred = 250;
|
||||
}
|
||||
if (!args.json)
|
||||
printf("threads: %d\n", args.tred);
|
||||
|
||||
unsigned long int mem_size = get_mem_available_mb();
|
||||
|
||||
size_t words = mem_size / sizeof(uint32_t);
|
||||
args.words = words;
|
||||
uint32_t *mem = malloc(mem_size);
|
||||
|
|
@ -285,10 +310,7 @@ int main(int argc, char *argv[]){
|
|||
printf("Память не выделена!");
|
||||
return 1;
|
||||
}
|
||||
if (args.tred < 1){
|
||||
if (!args.json) printf("Количество потоков изменено на 1");
|
||||
args.tred = 1;
|
||||
}
|
||||
|
||||
//struct tred_pizdec* meta[];
|
||||
//pthread_t thread[];
|
||||
int err = 0, iterations = args.iterations;
|
||||
|
|
@ -296,70 +318,19 @@ int main(int argc, char *argv[]){
|
|||
pthread_t *thread = malloc(sizeof(pthread_t) * args.tred);
|
||||
if (!args.json)
|
||||
printf("iterations: %i\n", iterations);
|
||||
if (args.tred > 1){
|
||||
for (bool i = 0;(i != args.tred); i++)
|
||||
mem_meta_create(&meta[i], mem, i);
|
||||
DEBUG_PRINT("Выделена память!\n");
|
||||
}
|
||||
for (;iterations != 0; iterations--){
|
||||
if (args.tred > 1){
|
||||
for (size_t p = 0; p < sizeof(test_patterns)/sizeof(test_patterns[0]); ++p){
|
||||
test_patern(meta, thread, args.tred, &err, p, 1);// Основные паттерны 0x00000000, 0xFFFFFFFF, 0xAAAAAAAA, 0x55555555
|
||||
}
|
||||
for (int test_list_id = 0; test_list_id < sizeof(test_list)/sizeof(test_list[0]); ++test_list_id){
|
||||
test_patern(meta, thread, args.tred, &err, 0, test_list[test_list_id]);
|
||||
}
|
||||
}
|
||||
else{
|
||||
mem_meta_create(meta, mem, 0);
|
||||
meta->test_tip = 1;
|
||||
// Основные паттерны 0x00000000, 0xFFFFFFFF, 0xAAAAAAAA, 0x55555555
|
||||
for (size_t p = 0; p < sizeof(test_patterns)/sizeof(test_patterns[0]); ++p){
|
||||
//struct tred_pizdec meta = malloc(sizeof(struct tred_pizdec));
|
||||
meta->id = p;
|
||||
meseng_proses(meta->test_tip, meta->id);
|
||||
fill_pattern_multi_tred((void*)meta);
|
||||
//fill_pattern(mem, words, test_patterns[p]);
|
||||
meseng_test_and_slip();
|
||||
check_pattern_multi_tred((void*)meta);
|
||||
err += meta->return_error;
|
||||
//err += check_pattern(mem, words, test_patterns[p]);
|
||||
if (!args.json){
|
||||
if (!err){
|
||||
printf("\rOK\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
else printf("\nErrors: %d\n", err);
|
||||
}
|
||||
}
|
||||
for (int test_list_id = 0; test_list_id < sizeof(test_list)/sizeof(test_list[0]); ++test_list_id){
|
||||
meta->test_tip = test_list[test_list_id];
|
||||
meseng_proses(meta->test_tip, meta->id);
|
||||
fill_pattern_multi_tred((void*)meta);
|
||||
meseng_test_and_slip();
|
||||
check_pattern_multi_tred((void*)meta);
|
||||
if (!args.json){
|
||||
if(!meta->return_error){
|
||||
printf("\rOK\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
else printf("Errors: %d\n", meta->return_error);
|
||||
}
|
||||
err += meta->return_error;
|
||||
if (!args.json){
|
||||
if (!err){
|
||||
printf("\rOK");
|
||||
fflush(stdout);
|
||||
}
|
||||
else printf("\nErrors: %d\n", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (size_t p = 0; p < sizeof(test_patterns)/sizeof(test_patterns[0])+sizeof(test_list)/sizeof(test_list[0]); ++p)
|
||||
test_patern(meta, thread, args.tred, &err, p);
|
||||
}
|
||||
|
||||
free(mem);
|
||||
if (args.json)
|
||||
json_create(meta);
|
||||
free(meta);
|
||||
free(thread);
|
||||
//if(args.json)
|
||||
//for (bool i = 0;(args.tred != -1 || i != args.tred); i++)
|
||||
// free(meta[i]);
|
||||
|
|
|
|||
|
|
@ -59,9 +59,6 @@ void error_write_info(size_t i, struct tred_pizdec* meta, uint32_t expected){
|
|||
error_str->expected = expected;
|
||||
error_str->actual = meta->mem[i];
|
||||
if (!meta->test_stats->test_local_stats[id]->error_int){
|
||||
if (meta->test_stats->test_local_stats[id] != NULL){
|
||||
|
||||
}
|
||||
meta->test_stats->test_local_stats[id]->error_info = error_str;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
234
test.log
Normal file
234
test.log
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
/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);
|
||||
| ^
|
||||
Loading…
Add table
Add a link
Reference in a new issue