diff options
Diffstat (limited to 'coreutils/id.c')
-rw-r--r-- | coreutils/id.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/coreutils/id.c b/coreutils/id.c index 35f945dba..36007ae55 100644 --- a/coreutils/id.c +++ b/coreutils/id.c | |||
@@ -89,19 +89,16 @@ int id_main(int argc, char **argv) | |||
89 | 89 | ||
90 | #ifdef CONFIG_SELINUX | 90 | #ifdef CONFIG_SELINUX |
91 | if (is_selinux_enabled()) { | 91 | if (is_selinux_enabled()) { |
92 | security_context_t mysid; | 92 | security_context_t mysid; |
93 | char context[80]; | 93 | const char *context; |
94 | int len = sizeof(context); | ||
95 | 94 | ||
96 | getcon(&mysid); | 95 | context = "unknown"; |
97 | context[0] = '\0'; | 96 | getcon(&mysid); |
98 | if (mysid) { | 97 | if (mysid) { |
99 | len = strlen(mysid)+1; | 98 | context = alloca(strlen(mysid) + 1); |
100 | safe_strncpy(context, mysid, len); | 99 | strcpy((char*)context, mysid); |
101 | freecon(mysid); | 100 | freecon(mysid); |
102 | } else { | 101 | } |
103 | safe_strncpy(context, "unknown", 8); | ||
104 | } | ||
105 | printf(" context=%s", context); | 102 | printf(" context=%s", context); |
106 | } | 103 | } |
107 | #endif | 104 | #endif |