From 9681a918ad74845ed3abc4495b93294139c5b186 Mon Sep 17 00:00:00 2001 From: Alan Jowett Date: Wed, 30 Jun 2021 11:11:27 -0600 Subject: [PATCH] Fix issues flagged by CodeQL code scan (#324) Signed-off-by: Alan Jowett --- libs/platform/ebpf_serialize.c | 2 +- tools/port_quota/port_quota.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/platform/ebpf_serialize.c b/libs/platform/ebpf_serialize.c index 4037abe87..49a25e991 100644 --- a/libs/platform/ebpf_serialize.c +++ b/libs/platform/ebpf_serialize.c @@ -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]; diff --git a/tools/port_quota/port_quota.cpp b/tools/port_quota/port_quota.cpp index da822e5e5..258a5e11d 100644 --- a/tools/port_quota/port_quota.cpp +++ b/tools/port_quota/port_quota.cpp @@ -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(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(&pid), reinterpret_cast(&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)