diff mbox series

[RFC,v2,24/27] libselinux: set errno on label lookup failure

Message ID 20230814132025.45364-25-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit 6df403d5976d
Delegated to: Petr Lautrbach
Headers show
Series libselinux: rework selabel_file(5) database | expand

Commit Message

Christian Göttsche Aug. 14, 2023, 1:20 p.m. UTC
selabel_lookup(3) is expected to set errno on lookup failure, i.e. when
it returns NULL.  Set errno if a regular expression failed to compile in
compile_regex().

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
v2: add patch
---
 libselinux/src/label_file.h | 1 +
 1 file changed, 1 insertion(+)

Comments

James Carter Oct. 11, 2023, 6:50 p.m. UTC | #1
On Mon, Aug 14, 2023 at 9:42 AM Christian Göttsche
<cgzones@googlemail.com> wrote:
>
> selabel_lookup(3) is expected to set errno on lookup failure, i.e. when
> it returns NULL.  Set errno if a regular expression failed to compile in
> compile_regex().
>
> Signed-off-by: Christian Göttsche <cgzones@googlemail.com>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
> v2: add patch
> ---
>  libselinux/src/label_file.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
> index 3827b5c0..5365086b 100644
> --- a/libselinux/src/label_file.h
> +++ b/libselinux/src/label_file.h
> @@ -407,6 +407,7 @@ static inline int compile_regex(struct spec *spec, const char **errbuf)
>                         *errbuf = &regex_error_format_buffer[0];
>                 }
>                 __pthread_mutex_unlock(&spec->regex_lock);
> +               errno = EINVAL;
>                 return -1;
>         }
>
> --
> 2.40.1
>
James Carter Oct. 12, 2023, 5:57 p.m. UTC | #2
On Wed, Oct 11, 2023 at 2:50 PM James Carter <jwcart2@gmail.com> wrote:
>
> On Mon, Aug 14, 2023 at 9:42 AM Christian Göttsche
> <cgzones@googlemail.com> wrote:
> >
> > selabel_lookup(3) is expected to set errno on lookup failure, i.e. when
> > it returns NULL.  Set errno if a regular expression failed to compile in
> > compile_regex().
> >
> > Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
>
> Acked-by: James Carter <jwcart2@gmail.com>
>
Merged.
Thanks,
Jim

> > ---
> > v2: add patch
> > ---
> >  libselinux/src/label_file.h | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
> > index 3827b5c0..5365086b 100644
> > --- a/libselinux/src/label_file.h
> > +++ b/libselinux/src/label_file.h
> > @@ -407,6 +407,7 @@ static inline int compile_regex(struct spec *spec, const char **errbuf)
> >                         *errbuf = &regex_error_format_buffer[0];
> >                 }
> >                 __pthread_mutex_unlock(&spec->regex_lock);
> > +               errno = EINVAL;
> >                 return -1;
> >         }
> >
> > --
> > 2.40.1
> >
diff mbox series

Patch

diff --git a/libselinux/src/label_file.h b/libselinux/src/label_file.h
index 3827b5c0..5365086b 100644
--- a/libselinux/src/label_file.h
+++ b/libselinux/src/label_file.h
@@ -407,6 +407,7 @@  static inline int compile_regex(struct spec *spec, const char **errbuf)
 			*errbuf = &regex_error_format_buffer[0];
 		}
 		__pthread_mutex_unlock(&spec->regex_lock);
+		errno = EINVAL;
 		return -1;
 	}