Fix issues flagged by CodeQL code scan (#324)

Signed-off-by: Alan Jowett <alanjo@microsoft.com>
This commit is contained in:
Alan Jowett 2021-06-30 11:11:27 -06:00 коммит произвёл GitHub
Родитель e825caaa8e
Коммит 9681a918ad
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -545,7 +545,7 @@ ebpf_deserialize_program_information(
}
local_program_info->helper_prototype = local_helper_prototype_array;
for (uint16_t helper_function_index = 0; helper_function_index < helper_function_count; helper_function_index++) {
for (uint32_t helper_function_index = 0; helper_function_index < helper_function_count; helper_function_index++) {
ebpf_serialized_helper_function_prototype_t* serialized_helper_prototype =
(ebpf_serialized_helper_function_prototype_t*)current;
ebpf_helper_function_prototype_t* helper_prototype = &local_helper_prototype_array[helper_function_index];

Просмотреть файл

@ -13,7 +13,7 @@ const unsigned char program_link[] = "port_quota::program_link";
typedef struct _process_entry
{
uint32_t count;
uint8_t name[64];
wchar_t name[32];
} process_entry_t;
int
@ -106,7 +106,7 @@ stats(int argc, char** argv)
fprintf(stderr, "Failed to look up eBPF map entry: %d\n", result);
return 1;
}
printf("%lld\t%d\t%S\n", pid, process_entry.count, reinterpret_cast<wchar_t*>(process_entry.name));
printf("%lld\t%d\t%S\n", pid, process_entry.count, process_entry.name);
result = ebpf_api_get_next_map_key(
map, sizeof(uint64_t), reinterpret_cast<uint8_t*>(&pid), reinterpret_cast<uint8_t*>(&pid));
};
@ -149,10 +149,11 @@ struct
const char* name;
const char* help;
operation_t operation;
} commands[]{{"load", "load\tLoad the port quota eBPF program", load},
{"unload", "unload\tUnload the port quota eBPF program", unload},
{"stats", "stats\tShow stats from the port quota eBPF program", stats},
{"limit", "limit value\tSet the port quota limit", limit}};
} commands[]{
{"load", "load\tLoad the port quota eBPF program", load},
{"unload", "unload\tUnload the port quota eBPF program", unload},
{"stats", "stats\tShow stats from the port quota eBPF program", stats},
{"limit", "limit value\tSet the port quota limit", limit}};
void
print_usage(char* path)