aboutsummaryrefslogtreecommitdiffstats
path: root/libselinux/src/label_file.c
diff options
context:
space:
mode:
authorRichard Haines <richard_c_haines@btinternet.com>2015-06-01 15:33:26 +0100
committerStephen Smalley <sds@tycho.nsa.gov>2015-06-03 10:43:33 -0400
commitaf41e2b5ff197f5e66262868fdc3a03963cd104e (patch)
treed502d36f3d05feac444d5d92be679294cd9c4556 /libselinux/src/label_file.c
parenta24fc044f4ddd7d8679f2219454d103036d312ef (diff)
downloadandroid_external_selinux-af41e2b5ff197f5e66262868fdc3a03963cd104e.tar.gz
android_external_selinux-af41e2b5ff197f5e66262868fdc3a03963cd104e.tar.bz2
android_external_selinux-af41e2b5ff197f5e66262868fdc3a03963cd104e.zip
libselinux: Add read_spec_entries function to replace sscanf
Currently sscanf is used with %ms parameters that are not supported on all platforms. The new read_spec_entries function may be used to replace these where required. This patch updates sefcontext_compile, label_file and label_android_property services to use the new function. The file and property services have been tested on Android emulator and the file service on Fedora 21. Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Diffstat (limited to 'libselinux/src/label_file.c')
-rw-r--r--libselinux/src/label_file.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
index bfb64af4..b8061f4c 100644
--- a/libselinux/src/label_file.c
+++ b/libselinux/src/label_file.c
@@ -154,22 +154,16 @@ static int process_line(struct selabel_handle *rec,
char *line_buf, unsigned lineno)
{
int items, len, rc;
- char *buf_p, *regex, *type, *context;
+ char *regex = NULL, *type = NULL, *context = NULL;
struct saved_data *data = (struct saved_data *)rec->data;
struct spec *spec_arr;
unsigned int nspec = data->nspec;
const char *errbuf = NULL;
- len = strlen(line_buf);
- if (line_buf[len - 1] == '\n')
- line_buf[len - 1] = 0;
- buf_p = line_buf;
- while (isspace(*buf_p))
- buf_p++;
- /* Skip comment lines and empty lines. */
- if (*buf_p == '#' || *buf_p == 0)
- return 0;
- items = sscanf(line_buf, "%ms %ms %ms", &regex, &type, &context);
+ items = read_spec_entries(line_buf, 3, &regex, &type, &context);
+ if (items <= 0)
+ return items;
+
if (items < 2) {
COMPAT_LOG(SELINUX_WARNING,
"%s: line %u is missing fields, skipping\n", path,