-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 This patch looks good to me. acked. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6wThEACgkQrlYvE4MpobOLRgCfWs8iAjtrApI0v3i6uhhWjKAW ynkAoMe2sEhvfJ+kTiLQH8uo5aDIgogG =gmJ8 -----END PGP SIGNATURE-----
>From 0290ee84f71be01274cda929d7ddbaca70592413 Mon Sep 17 00:00:00 2001 From: Eric Paris <eparis@xxxxxxxxxx> Date: Thu, 29 Sep 2011 17:07:54 -0400 Subject: [PATCH 44/63] policycoreutils: label_file: style changes to make Eric happy. Sometimes sticking to 80 characters sucks a lot. I don't care. Buy a wider monitor so I can read the code. Signed-off-by: Eric Paris <eparis@xxxxxxxxxx> --- libselinux/src/label_file.c | 47 ++++++++++++++++++++++--------------------- 1 files changed, 24 insertions(+), 23 deletions(-) diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c index 278e3c7..42889cf 100644 --- a/libselinux/src/label_file.c +++ b/libselinux/src/label_file.c @@ -159,15 +159,12 @@ static int nodups_specs(struct saved_data *data, const char *path) for (ii = 0; ii < data->nspec; ii++) { curr_spec = &spec_arr[ii]; for (jj = ii + 1; jj < data->nspec; jj++) { - if ((!strcmp - (spec_arr[jj].regex_str, curr_spec->regex_str)) + if ((!strcmp(spec_arr[jj].regex_str, curr_spec->regex_str)) && (!spec_arr[jj].mode || !curr_spec->mode || spec_arr[jj].mode == curr_spec->mode)) { rc = -1; errno = EINVAL; - if (strcmp - (spec_arr[jj].lr.ctx_raw, - curr_spec->lr.ctx_raw)) { + if (strcmp(spec_arr[jj].lr.ctx_raw, curr_spec->lr.ctx_raw)) { COMPAT_LOG (SELINUX_ERROR, "%s: Multiple different specifications for %s (%s and %s).\n", @@ -493,37 +490,41 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts, */ maxnspec = UINT_MAX / sizeof(spec_t); for (pass = 0; pass < 2; pass++) { - lineno = 0; data->nspec = 0; data->ncomp = 0; - while (getline(&line_buf, &line_len, fp) > 0 - && data->nspec < maxnspec) { - if (process_line(rec, path, prefix_array, line_buf, - pass, ++lineno) != 0) + + lineno = 0; + while (getline(&line_buf, &line_len, fp) > 0) { + if (data->nspec >= maxnspec) + break; + status = process_line(rec, path, prefix_array, line_buf, pass, ++lineno); + if (status) goto finish; } + if (pass == 1 && rec->validating) { status = nodups_specs(data, path); if (status) goto finish; } + lineno = 0; if (homedirfp) - while (getline(&line_buf, &line_len, homedirfp) > 0 - && data->nspec < maxnspec) { - if (process_line - (rec, homedir_path, prefix_array, - line_buf, pass, ++lineno) != 0) + while (getline(&line_buf, &line_len, homedirfp) > 0) { + if (data->nspec >= maxnspec) + break; + status = process_line(rec, homedir_path, prefix_array, line_buf, pass, ++lineno); + if (status) goto finish; } lineno = 0; if (localfp) - while (getline(&line_buf, &line_len, localfp) > 0 - && data->nspec < maxnspec) { - if (process_line - (rec, local_path, prefix_array, line_buf, - pass, ++lineno) != 0) + while (getline(&line_buf, &line_len, localfp) > 0) { + if (data->nspec >= maxnspec) + break; + status = process_line(rec, local_path, prefix_array, line_buf, pass, ++lineno); + if (status) goto finish; } @@ -532,10 +533,10 @@ static int init(struct selabel_handle *rec, struct selinux_opt *opts, status = 0; goto finish; } - if (NULL == (data->spec_arr = - malloc(sizeof(spec_t) * data->nspec))) + data->spec_arr = calloc(data->nspec, sizeof(spec_t)); + if (!data->spec_arr) goto finish; - memset(data->spec_arr, 0, sizeof(spec_t)*data->nspec); + maxnspec = data->nspec; rewind(fp); if (homedirfp) -- 1.7.7