Message ID | 20190920055955.2780-2-nicolas.iooss@m4x.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [v2,1/2] libselinux: ensure strlen() is not called on NULL | expand |
On 9/20/19 1:59 AM, Nicolas Iooss wrote: > In regex_format_error(), when error_data->error_offset is zero, rc is > not updated and should not be added to pos again. > > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org> Acked-by: Stephen Smalley <sds@tycho.nsa.gov> > --- > libselinux/src/regex.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libselinux/src/regex.c b/libselinux/src/regex.c > index c835dd1b0e5d..770bc3ea1310 100644 > --- a/libselinux/src/regex.c > +++ b/libselinux/src/regex.c > @@ -552,10 +552,10 @@ void regex_format_error(struct regex_error_data const *error_data, char *buffer, > #endif > if (rc < 0) > abort(); > + pos += rc; > + if (pos >= buf_size) > + goto truncated; > } > - pos += rc; > - if (pos >= buf_size) > - goto truncated; > > #ifdef USE_PCRE2 > rc = pcre2_get_error_message(error_data->error_code, >
On 9/20/19 1:59 AM, Nicolas Iooss wrote: > In regex_format_error(), when error_data->error_offset is zero, rc is > not updated and should not be added to pos again. Thanks, both patches applied. > > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org> > --- > libselinux/src/regex.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/libselinux/src/regex.c b/libselinux/src/regex.c > index c835dd1b0e5d..770bc3ea1310 100644 > --- a/libselinux/src/regex.c > +++ b/libselinux/src/regex.c > @@ -552,10 +552,10 @@ void regex_format_error(struct regex_error_data const *error_data, char *buffer, > #endif > if (rc < 0) > abort(); > + pos += rc; > + if (pos >= buf_size) > + goto truncated; > } > - pos += rc; > - if (pos >= buf_size) > - goto truncated; > > #ifdef USE_PCRE2 > rc = pcre2_get_error_message(error_data->error_code, >
diff --git a/libselinux/src/regex.c b/libselinux/src/regex.c index c835dd1b0e5d..770bc3ea1310 100644 --- a/libselinux/src/regex.c +++ b/libselinux/src/regex.c @@ -552,10 +552,10 @@ void regex_format_error(struct regex_error_data const *error_data, char *buffer, #endif if (rc < 0) abort(); + pos += rc; + if (pos >= buf_size) + goto truncated; } - pos += rc; - if (pos >= buf_size) - goto truncated; #ifdef USE_PCRE2 rc = pcre2_get_error_message(error_data->error_code,
In regex_format_error(), when error_data->error_offset is zero, rc is not updated and should not be added to pos again. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org> --- libselinux/src/regex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)