diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2009-06-20 23:22:41 +0200 |
---|---|---|
committer | Anton Arapov <aarapov@redhat.com> | 2009-06-20 23:22:41 +0200 |
commit | 7342d3896446deaf89ab5582da81457571e48fe6 (patch) | |
tree | 8461c8f4249d08c65e8aecc7785bb770912283a7 /lib/Plugins/KerneloopsScanner.cpp | |
parent | 7ea90a7e6e836257e05d2f9f6b5ad0f9aab88c23 (diff) | |
download | abrt-7342d3896446deaf89ab5582da81457571e48fe6.tar.gz abrt-7342d3896446deaf89ab5582da81457571e48fe6.tar.xz abrt-7342d3896446deaf89ab5582da81457571e48fe6.zip |
Handle logs with NUL chars better
It is not too rare that '\0' chars appear in /var/log/messages. I saw a
real-life case where kerneloops would show a popup with the same old oops
after every login. It turned out that there were NUL chars in the log which
prevented kerneloops from seeing its marker, so it always treated the old oops
in the log as new.
This patch fixes it by always going through the whole known length of the
buffer (not stopping on NUL chars) and using less string-oriented functions in
fill_lineinfo().
Diffstat (limited to 'lib/Plugins/KerneloopsScanner.cpp')
-rw-r--r-- | lib/Plugins/KerneloopsScanner.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index e95f259b..855213bc 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -104,7 +104,7 @@ void CKerneloopsScanner::ScanSysLogFile(const char *filename, int issyslog) FILE *file; int ret; int m_nFoundOopses; - size_t buflen; + size_t buflen, nread; memset(&statb, 0, sizeof(statb)); @@ -134,11 +134,11 @@ void CKerneloopsScanner::ScanSysLogFile(const char *filename, int issyslog) return; } fseek(file, -buflen, SEEK_END); - ret = fread(buffer, 1, buflen-1, file); + nread = fread(buffer, 1, buflen, file); fclose(file); - if (ret > 0) - m_nFoundOopses = m_pSysLog.ExtractOops(buffer, buflen-1, issyslog); + if (nread > 0) + m_nFoundOopses = m_pSysLog.ExtractOops(buffer, nread, issyslog); free(buffer); if (m_nFoundOopses > 0) { |