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 <eparis@redhat.com>
This commit is contained in:
Eric Paris 2012-08-27 14:43:51 -04:00
parent 247759031a
commit ee88185aff
2 changed files with 7 additions and 2 deletions

View File

@ -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++;

View File

@ -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;