summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-03-05 18:10:29 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-03-05 18:10:29 +0100
commit12f3823f9aa38728f29bc49d1d2dde03fd20e8af (patch)
tree2aa02d432b5adb3976ca53a86783f356d238baca /lib
parent122cfd55e01c90ca4e5cc0ac083fc87404b8e95f (diff)
downloadabrt-12f3823f9aa38728f29bc49d1d2dde03fd20e8af.tar.gz
abrt-12f3823f9aa38728f29bc49d1d2dde03fd20e8af.tar.xz
abrt-12f3823f9aa38728f29bc49d1d2dde03fd20e8af.zip
improve syslog file detection. closes bz#565983
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Plugins/KerneloopsSysLog.cpp39
1 files changed, 17 insertions, 22 deletions
diff --git a/lib/Plugins/KerneloopsSysLog.cpp b/lib/Plugins/KerneloopsSysLog.cpp
index 29e9d6f3..7c605050 100644
--- a/lib/Plugins/KerneloopsSysLog.cpp
+++ b/lib/Plugins/KerneloopsSysLog.cpp
@@ -118,6 +118,7 @@ int extract_oopses(vector_string_t &oopses, char *buffer, size_t buflen)
while (c < buffer + buflen) {
char linelevel;
char *c9;
+ char *colon;
c9 = (char*)memchr(c, '\n', buffer + buflen - c); /* a \n will always be found */
assert(c9);
@@ -125,31 +126,25 @@ int extract_oopses(vector_string_t &oopses, char *buffer, size_t buflen)
if (c9 == c)
goto next_line;
- /* in /var/log/messages, we need to strip the first part off, upto the 3rd ':' */
- /* 01234567890123456 */
-// Gaack! Some users run syslog in non-C locale:
-// 2010-02-22T09:24:08.156534-08:00 gnu-4 gnome-session[2048]: blah blah
-// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ !!!
- if ((c9 - c) > sizeof("Jul 4 11:11:11 ")
- && c[3] == ' '
- && (c[4] == ' ' || isdigit(c[4]))
- && isdigit(c[5])
- && c[6] == ' '
- && isdigit(c[7])
- && isdigit(c[8])
- && c[9] == ':'
- && isdigit(c[10])
- && isdigit(c[11])
- && c[12] == ':'
- && isdigit(c[13])
- && isdigit(c[14])
- && c[15] == ' '
+ /* Is it a syslog file (/var/log/messages or similar)?
+ * Even though _usually_ it looks like "Nov 19 12:34:38 localhost kernel: xxx",
+ * some users run syslog in non-C locale:
+ * "2010-02-22T09:24:08.156534-08:00 gnu-4 gnome-session[2048]: blah blah"
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ !!!
+ * We detect it by checking for N:NN:NN pattern in first 15 chars
+ * (and this still is not good enough... false positive: "pci 0000:15:00.0: PME# disabled")
+ */
+ colon = strchr(c, ':');
+ if (colon && colon > c && colon < c + 15
+ && isdigit(colon[-1]) /* N:... */
+ && isdigit(colon[1]) /* ...N:NN:... */
+ && isdigit(colon[2])
+ && colon[3] == ':'
+ && isdigit(colon[4]) /* ...N:NN:NN... */
+ && isdigit(colon[5])
) {
/* It's syslog file, not a bare dmesg */
- /* Skip over timestamp */
- c += 16;
-
/* Skip non-kernel lines */
char *kernel_str = strstr(c, "kernel: ");
if (kernel_str == NULL) {