Skip to content

Commit e857be7

Browse files
committed
fix(userspace/libsinsp): PT_MODE resize params string to the right value instead of doubling it
Signed-off-by: Lorenzo Fontana <[email protected]>
1 parent afc936a commit e857be7

File tree

5 files changed

+20
-31
lines changed

5 files changed

+20
-31
lines changed

driver/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ set(DRIVER_SOURCES
4545
event_table.c
4646
fillers_table.c
4747
flags_table.c
48-
modes_table.c
4948
main.c
5049
ppm.h
5150
ppm_events.c

driver/flags_table.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,3 +501,19 @@ const struct ppm_name_value linkat_flags[] = {
501501
{"AT_EMPTY_PATH", PPM_AT_EMPTY_PATH},
502502
{0, 0},
503503
};
504+
505+
const struct ppm_name_value chmod_mode[] = {
506+
{"S_IXOTH", PPM_S_IXOTH},
507+
{"S_IWOTH", PPM_S_IWOTH},
508+
{"S_IROTH", PPM_S_IROTH},
509+
{"S_IXGRP", PPM_S_IXGRP},
510+
{"S_IWGRP", PPM_S_IWGRP},
511+
{"S_IRGRP", PPM_S_IRGRP},
512+
{"S_IXUSR", PPM_S_IXUSR},
513+
{"S_IWUSR", PPM_S_IWUSR},
514+
{"S_IRUSR", PPM_S_IRUSR},
515+
{"S_ISVTX", PPM_S_ISVTX},
516+
{"S_ISGID", PPM_S_ISGID},
517+
{"S_ISUID", PPM_S_ISUID},
518+
{0, 0},
519+
};

driver/modes_table.c

Lines changed: 0 additions & 26 deletions
This file was deleted.

userspace/libscap/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ list(APPEND targetfiles
3232
syscall_info_table.c
3333
../../driver/dynamic_params_table.c
3434
../../driver/event_table.c
35-
../../driver/flags_table.c
36-
../../driver/modes_table.c)
35+
../../driver/flags_table.c)
3736

3837
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
3938
list(APPEND targetfiles

userspace/libsinsp/event.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,9 +2059,10 @@ const char* sinsp_evt::get_param_as_str(uint32_t id, OUT const char** resolved_s
20592059
if((mode->value == 0 && initial_val == 0) ||
20602060
(mode->value != 0 && (val & mode->value) == mode->value && val != 0))
20612061
{
2062-
if(m_resolved_paramstr_storage.size() < j + strlen(separator) + strlen(mode->name))
2062+
size_t params_len = j + strlen(separator) + strlen(mode->name);
2063+
if(m_resolved_paramstr_storage.size() < params_len)
20632064
{
2064-
m_resolved_paramstr_storage.resize(m_resolved_paramstr_storage.size() * 2);
2065+
m_resolved_paramstr_storage.resize(params_len + 1);
20652066
}
20662067

20672068
j += snprintf(&m_resolved_paramstr_storage[j],

0 commit comments

Comments
 (0)