|
|
baab13 |
From adb5eabda368cdd05e9ed02cf91ce5e02bc26e0b Mon Sep 17 00:00:00 2001
|
|
|
baab13 |
From: Jakub Filak <jfilak@redhat.com>
|
|
|
baab13 |
Date: Wed, 25 May 2016 13:35:28 +0200
|
|
|
baab13 |
Subject: [PATCH] koops: do not assume version has 3 levels
|
|
|
baab13 |
|
|
|
baab13 |
Correct commit 9023d77ad5539433146b59e5ac80e3cefcb20cf7
|
|
|
baab13 |
|
|
|
baab13 |
Some ancient kernel versions have 4 levels. This commit allows version
|
|
|
baab13 |
string to have any level equal or greater than 3. The first 3 levels
|
|
|
baab13 |
must be numbers and the rest can be almost anything - it just must
|
|
|
baab13 |
follow the logical structure of levels (i.e. dot something dot
|
|
|
baab13 |
something) - this should allow a git hash in the version string.
|
|
|
baab13 |
|
|
|
baab13 |
In order to eliminate possible false positives introduced by the
|
|
|
baab13 |
flexibility of version levels the commit adds checks for
|
|
|
baab13 |
the prefixes ' ', '(' or 'kernel-' and the suffix ' #' or ') #'.
|
|
|
baab13 |
|
|
|
baab13 |
Resolves #1378469
|
|
|
baab13 |
|
|
|
baab13 |
Signed-off-by: Jakub Filak <jfilak@redhat.com>
|
|
|
baab13 |
---
|
|
|
baab13 |
src/lib/kernel.c | 15 +++++++++++----
|
|
|
baab13 |
1 file changed, 11 insertions(+), 4 deletions(-)
|
|
|
baab13 |
|
|
|
baab13 |
diff --git a/src/lib/kernel.c b/src/lib/kernel.c
|
|
|
baab13 |
index 4e27d05..1a9d327 100644
|
|
|
baab13 |
--- a/src/lib/kernel.c
|
|
|
baab13 |
+++ b/src/lib/kernel.c
|
|
|
baab13 |
@@ -534,7 +534,10 @@ char *koops_extract_version(const char *linepointer)
|
|
|
baab13 |
|| strstr(linepointer, "REGS")
|
|
|
baab13 |
|| strstr(linepointer, "EFLAGS")
|
|
|
baab13 |
) {
|
|
|
baab13 |
- const char *regexp = "([0-9]+\\.[0-9]+\\.[0-9]+-[^ \\)]+)[ \\)]";
|
|
|
baab13 |
+ /* "(4.7.0-2.x86_64.fc25) #" */
|
|
|
baab13 |
+ /* " 4.7.0-2.x86_64.fc25 #" */
|
|
|
baab13 |
+ /* " 2.6.3.4.5-2.x86_64.fc22 #" */
|
|
|
baab13 |
+ const char *regexp = "([ \\(]|kernel-)([0-9]+\\.[0-9]+\\.[0-9]+(\\.[^.-]+)*-[^ \\)]+)\\)? #";
|
|
|
baab13 |
regex_t re;
|
|
|
baab13 |
int r = regcomp(&re, regexp, REG_EXTENDED);
|
|
|
baab13 |
if (r != 0)
|
|
|
baab13 |
@@ -545,8 +548,8 @@ char *koops_extract_version(const char *linepointer)
|
|
|
baab13 |
return NULL;
|
|
|
baab13 |
}
|
|
|
baab13 |
|
|
|
baab13 |
- regmatch_t matchptr[2];
|
|
|
baab13 |
- r = regexec(&re, linepointer, 2, matchptr, 0);
|
|
|
baab13 |
+ regmatch_t matchptr[3];
|
|
|
baab13 |
+ r = regexec(&re, linepointer, sizeof(matchptr)/sizeof(matchptr[0]), matchptr, 0);
|
|
|
baab13 |
if (r != 0)
|
|
|
baab13 |
{
|
|
|
baab13 |
if (r != REG_NOMATCH)
|
|
|
baab13 |
@@ -565,7 +568,11 @@ char *koops_extract_version(const char *linepointer)
|
|
|
baab13 |
return NULL;
|
|
|
baab13 |
}
|
|
|
baab13 |
|
|
|
baab13 |
- char *ret = xstrndup(linepointer + matchptr[1].rm_so, matchptr[1].rm_eo - matchptr[1].rm_so);
|
|
|
baab13 |
+ /* 0: entire string */
|
|
|
baab13 |
+ /* 1: version prefix */
|
|
|
baab13 |
+ /* 2: version string */
|
|
|
baab13 |
+ const regmatch_t *const ver = matchptr + 2;
|
|
|
baab13 |
+ char *ret = xstrndup(linepointer + ver->rm_so, ver->rm_eo - ver->rm_so);
|
|
|
baab13 |
|
|
|
baab13 |
regfree(&re);
|
|
|
baab13 |
return ret;
|
|
|
baab13 |
--
|
|
|
baab13 |
1.8.3.1
|
|
|
baab13 |
|