From 154e8291eae132ab156715fa46d64b20f25a5740 Mon Sep 17 00:00:00 2001 From: Chris PeBenito Date: Sat, 14 Jul 2018 15:12:02 -0400 Subject: [PATCH] selinuxpolicy.pxi: Fix attribute synthesis code. Closes #1 --- setools/policyrep/selinuxpolicy.pxi | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/setools/policyrep/selinuxpolicy.pxi b/setools/policyrep/selinuxpolicy.pxi index ff42038..84ac35d 100644 --- a/setools/policyrep/selinuxpolicy.pxi +++ b/setools/policyrep/selinuxpolicy.pxi @@ -894,12 +894,11 @@ cdef class SELinuxPolicy: # Synthesize a name if it is missing if self.handle.p.sym_val_to_name[sepol.SYM_TYPES][i] == NULL: # synthesize name - tmp_name = calloc(10, sizeof(char)) + tmp_name = calloc(15, sizeof(char)) if tmp_name == NULL: raise MemoryError - memset(tmp_name, 0, 10 * sizeof(char)) - snprintf(tmp_name, 9, "@ttr%04zd", i + 1) + snprintf(tmp_name, 15, "@ttr%010zd", i + 1) self.handle.p.sym_val_to_name[sepol.SYM_TYPES][i] = tmp_name @@ -965,12 +964,11 @@ cdef class SELinuxPolicy: if self.handle.p.type_val_to_struct[i] != NULL: continue - tmp_name = calloc(10, sizeof(char)) + tmp_name = calloc(15, sizeof(char)) if tmp_name == NULL: raise MemoryError - memset(tmp_name, 0, 10 * sizeof(char)) - snprintf(tmp_name, 9, "@ttr%04zd", i + 1) + snprintf(tmp_name, 15, "@ttr%010zd", i + 1) tmp_type = calloc(1, sizeof(sepol.type_datum_t)) if tmp_type == NULL: