Merge pull request #27421 from bluca/coredump_filter
CoredumpFilter: fix stack overflow and invalid assignment with 'all'
This commit is contained in:
@@ -46,7 +46,7 @@ int coredump_filter_mask_from_string(const char *s, uint64_t *ret) {
|
||||
}
|
||||
|
||||
if (streq(n, "all")) {
|
||||
m = UINT64_MAX;
|
||||
m = COREDUMP_FILTER_MASK_ALL;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -158,9 +158,9 @@ int parse_auxv(int log_level,
|
||||
}
|
||||
|
||||
int set_coredump_filter(uint64_t value) {
|
||||
char t[STRLEN("0xFFFFFFFF")];
|
||||
char t[HEXADECIMAL_STR_MAX(uint64_t)];
|
||||
|
||||
sprintf(t, "0x%"PRIx64, value);
|
||||
xsprintf(t, "0x%"PRIx64, value);
|
||||
|
||||
return write_string_file("/proc/self/coredump_filter", t,
|
||||
WRITE_STRING_FILE_VERIFY_ON_FAILURE|WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
|
||||
@@ -22,6 +22,9 @@ typedef enum CoredumpFilter {
|
||||
1u << COREDUMP_FILTER_ELF_HEADERS | \
|
||||
1u << COREDUMP_FILTER_PRIVATE_HUGE)
|
||||
|
||||
/* The kernel doesn't like UINT64_MAX and returns ERANGE, use UINT32_MAX to support future new flags */
|
||||
#define COREDUMP_FILTER_MASK_ALL UINT32_MAX
|
||||
|
||||
const char* coredump_filter_to_string(CoredumpFilter i) _const_;
|
||||
CoredumpFilter coredump_filter_from_string(const char *s) _pure_;
|
||||
int coredump_filter_mask_from_string(const char *s, uint64_t *ret);
|
||||
|
||||
Reference in New Issue
Block a user