From ee88185aff38b18b16da0d0ed38796d7142632d1 Mon Sep 17 00:00:00 2001 From: Eric Paris Date: Mon, 27 Aug 2012 14:43:51 -0400 Subject: [PATCH] libselinux: label_file: add accessors for the pcre extra data When we use an mmap backed version of data we need to declare the pcre extra data since we are only given a point to the data->buffer. Since sometimes the spec will hold a pointer to the extra data and sometimes we want to declare it on the stack I introduce and use an accessor for the extra data instead of using it directly. Signed-off-by: Eric Paris --- libselinux/src/label_file.c | 4 ++-- libselinux/src/label_file.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c index c220fbf9..1b6b8124 100644 --- a/libselinux/src/label_file.c +++ b/libselinux/src/label_file.c @@ -472,9 +472,9 @@ static struct selabel_lookup_rec *lookup(struct selabel_handle *rec, if (compile_regex(data, spec, NULL) < 0) goto finish; if (spec->stem_id == -1) - rc = pcre_exec(spec->regex, spec->sd, key, strlen(key), 0, 0, NULL, 0); + rc = pcre_exec(spec->regex, get_pcre_extra(spec), key, strlen(key), 0, 0, NULL, 0); else - rc = pcre_exec(spec->regex, spec->sd, buf, strlen(buf), 0, 0, NULL, 0); + rc = pcre_exec(spec->regex, get_pcre_extra(spec), buf, strlen(buf), 0, 0, NULL, 0); if (rc == 0) { spec->matches++; diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h index 8e78b25d..b2e463b6 100644 --- a/libselinux/src/label_file.h +++ b/libselinux/src/label_file.h @@ -42,6 +42,11 @@ struct saved_data { int alloc_stems; }; +static inline pcre_extra *get_pcre_extra(struct spec *spec) +{ + return spec->sd; +} + static inline mode_t string_to_mode(char *mode) { size_t len;