From 68b2e4416e5c7c272af43312d4faf4e1dd62a8a2 Mon Sep 17 00:00:00 2001 From: Nicolas Iooss Date: Fri, 20 Sep 2019 07:59:55 +0200 Subject: [PATCH] libselinux: do not add rc to pos twice 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 --- 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 c835dd1b..770bc3ea 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,