mcstrans: fix clang warnings
Fix the following warnings from clang. mcstrans.c:1309:6: warning: variable 'groups' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (violates_constraints(l)) { ^~~~~~~~~~~~~~~~~~~~~~~ mcstrans.c:1491:9: note: uninitialized use occurs here while (groups) ^~~~~~ mcstrans.c:1309:2: note: remove the 'if' if its condition is always false if (violates_constraints(l)) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mcstrans.c:1303:6: warning: variable 'groups' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!l) ^~ mcstrans.c:1491:9: note: uninitialized use occurs here while (groups) ^~~~~~ mcstrans.c:1303:2: note: remove the 'if' if its condition is always false if (!l) ^~~~~~~ mcstrans.c:1299:6: warning: variable 'groups' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!level) ^~~~~~ mcstrans.c:1491:9: note: uninitialized use occurs here while (groups) ^~~~~~ mcstrans.c:1299:2: note: remove the 'if' if its condition is always false if (!level) ^~~~~~~~~~~ mcstrans.c:1316:2: note: variable 'groups' is declared here word_group_t *groups = NULL; ^ 3 warnings generated. mcscolor.c:334:24: warning: size argument in 'strncat' call appears to be size of the source [-Wstrncat-size] strncat(result, buf, sizeof(buf)); Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
This commit is contained in:
parent
b97d959a6a
commit
6e4bb702af
2 changed files with 4 additions and 3 deletions
|
@ -289,6 +289,7 @@ int raw_color(const security_context_t raw, char **color_str) {
|
|||
const secolor_t *items[N_COLOR];
|
||||
char *result, *components[N_COLOR];
|
||||
char buf[CHARS_PER_COLOR + 1];
|
||||
size_t result_size = (N_COLOR * CHARS_PER_COLOR) + 1;
|
||||
int rc = -1;
|
||||
|
||||
if (!color_str && !*color_str) {
|
||||
|
@ -302,7 +303,7 @@ int raw_color(const security_context_t raw, char **color_str) {
|
|||
if (parse_components(con, components) < 0)
|
||||
goto out;
|
||||
|
||||
result = malloc((N_COLOR * CHARS_PER_COLOR) + 1);
|
||||
result = malloc(result_size);
|
||||
if (!result)
|
||||
goto out;
|
||||
result[0] = '\0';
|
||||
|
@ -331,7 +332,7 @@ int raw_color(const security_context_t raw, char **color_str) {
|
|||
for (i = 0; i < N_COLOR; i++) {
|
||||
snprintf(buf, sizeof(buf), "#%06x #%06x ",
|
||||
items[i]->fg, items[i]->bg);
|
||||
strncat(result, buf, sizeof(buf));
|
||||
strncat(result, buf, result_size-1);
|
||||
}
|
||||
|
||||
*color_str = result;
|
||||
|
|
|
@ -1287,6 +1287,7 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
|
|||
|
||||
mls_level_t *l = NULL;
|
||||
char *rval = NULL;
|
||||
word_group_t *groups = NULL;
|
||||
ebitmap_t bit_diff, temp, handled, nothandled, unhandled, orig_unhandled;
|
||||
|
||||
ebitmap_init(&bit_diff);
|
||||
|
@ -1313,7 +1314,6 @@ compute_trans_from_raw(const char *level, domain_t *domain) {
|
|||
|
||||
int doInverse = l->sens > 0;
|
||||
|
||||
word_group_t *groups = NULL;
|
||||
base_classification_t *bc, *last = NULL;
|
||||
int done = 0;
|
||||
for (bc = domain->base_classifications; bc && !done; bc = bc->next) {
|
||||
|
|
Loading…
Reference in a new issue