From 7035b97b4b19360d46c3190e698ac875ff99af37 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Sat, 20 Jun 2009 22:37:41 +0200 Subject: Really limit max size of log to read to 32 MB Because of MAX/MIN confusion, the buffer size was always at least 32 MB, instead of at most 32 MB as intended. --- lib/Plugins/KerneloopsScanner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/Plugins/KerneloopsScanner.cpp') diff --git a/lib/Plugins/KerneloopsScanner.cpp b/lib/Plugins/KerneloopsScanner.cpp index 05e2a18d..e95f259b 100644 --- a/lib/Plugins/KerneloopsScanner.cpp +++ b/lib/Plugins/KerneloopsScanner.cpp @@ -12,7 +12,7 @@ #include -#define MAX(A,B) ((A) > (B) ? (A) : (B)) +#define MIN(A,B) ((A) < (B) ? (A) : (B)) #define FILENAME_KERNELOOPS "kerneloops" void CKerneloopsScanner::WriteSysLog(int m_nCount) @@ -118,13 +118,13 @@ void CKerneloopsScanner::ScanSysLogFile(const char *filename, int issyslog) * to /var/log/messages before we read it in... we try to * deal with it by reading at most 1023 bytes extra. If there's * more than that.. any oops will be in dmesg anyway. - * Do not try to allocate an absurt amount of memory; ignore + * Do not try to allocate an absurd amount of memory; ignore * older log messages because they are unlikely to have * sufficiently recent data to be useful. 32MB is more * than enough; it's not worth looping through more log * if the log is larger than that. */ - buflen = MAX(statb.st_size+1024, 32*1024*1024); + buflen = MIN(statb.st_size+1024, 32*1024*1024); buffer = (char*)calloc(buflen, 1); assert(buffer != NULL); -- cgit