X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?a=blobdiff_plain;f=src%2Fmonitord%2Fcompress_log.c;h=c7d75f7f6bcd374b5ab41bd9851fdd2976b03511;hb=789cbc8e52da68eba3517b920ef22e000cf3c9fd;hp=7cf11bd4e6df293f405f8b506bcd9b1cac2cddfe;hpb=914feba5d54f979cd5d7e69c349c3d01f630042a;p=ossec-hids.git diff --git a/src/monitord/compress_log.c b/src/monitord/compress_log.c index 7cf11bd..c7d75f7 100755 --- a/src/monitord/compress_log.c +++ b/src/monitord/compress_log.c @@ -1,11 +1,12 @@ -/* @(#) $Id: compress_log.c,v 1.4 2009/06/24 17:06:27 dcid Exp $ */ +/* @(#) $Id: ./src/monitord/compress_log.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. * * This program is a free software; you can redistribute it * and/or modify it under the terms of the GNU General Public - * License (version 3) as published by the FSF - Free Software + * License (version 2) as published by the FSF - Free Software * Foundation */ @@ -18,19 +19,19 @@ void OS_CompressLog(char *logfile) { FILE *log; - gzFile *zlog; - + gzFile zlog; + char logfileGZ[OS_FLSIZE + 1]; int len, err; - + char buf[OS_MAXSTR + 1]; - + /* Do not compress */ if(mond.compress == 0) return; - - + + /* Clearing the memory */ memset(logfileGZ,'\0',OS_FLSIZE +1); memset(buf, '\0', OS_MAXSTR + 1); @@ -39,7 +40,7 @@ void OS_CompressLog(char *logfile) /* Setting the umask */ umask(0027); - + /* Creating the gzip file name */ snprintf(logfileGZ, OS_FLSIZE, "%s.gz", logfile); @@ -51,7 +52,7 @@ void OS_CompressLog(char *logfile) /* Do not warn in here, since the alert file may not exist. */ return; } - + /* Opening compressed file */ zlog = gzopen(logfileGZ, "w"); if(!zlog) @@ -60,7 +61,7 @@ void OS_CompressLog(char *logfile) merror(FOPEN_ERROR, ARGV0, logfileGZ); return; } - + for(;;) { len = fread(buf, 1, OS_MAXSTR, log); @@ -79,6 +80,6 @@ void OS_CompressLog(char *logfile) return; } - + /* EOF */