Browse code

fix crash on PPC when LogFile was enabled together with LogSyslog

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@703 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/07/29 10:45:14
Showing 2 changed files
... ...
@@ -1,3 +1,8 @@
1
+Thu Jul 29 03:31:22 CEST 2004 (tk)
2
+----------------------------------
3
+  * freshclam/clamd: fix crash on PPC when LogFile was enabled together with
4
+		     LogSyslog
5
+
1 6
 Thu Jul 29 02:43:13 CEST 2004 (tk)
2 7
 ----------------------------------
3 8
   * configure: improve gethostbyname_r check; cleanups
... ...
@@ -99,7 +99,7 @@ void logg_close(void) {
99 99
 
100 100
 int logg(const char *str, ...)
101 101
 {
102
-	va_list args;
102
+	va_list args, argscpy;
103 103
 	struct flock fl;
104 104
 	char *pt, *timestr, vbuff[1025];
105 105
 	time_t currtime;
... ...
@@ -108,6 +108,8 @@ int logg(const char *str, ...)
108 108
 
109 109
 
110 110
     va_start(args, str);
111
+    /* va_copy is less portable so we just use va_start once more */
112
+    va_start(argscpy, str);
111 113
 
112 114
     if(logg_file) {
113 115
 #ifdef CL_THREAD_SAFE
... ...
@@ -193,7 +195,7 @@ int logg(const char *str, ...)
193 193
 	 *
194 194
 	 * FIXME: substitute %% instead of _
195 195
 	 */
196
-	vsnprintf(vbuff, 1024, str, args);
196
+	vsnprintf(vbuff, 1024, str, argscpy);
197 197
 	vbuff[1024] = 0;
198 198
 
199 199
 	while((pt = strchr(vbuff, '%')))
... ...
@@ -213,12 +215,13 @@ int logg(const char *str, ...)
213 213
 #endif
214 214
 
215 215
     va_end(args);
216
+    va_end(argscpy);
216 217
     return 0;
217 218
 }
218 219
 
219 220
 void mprintf(const char *str, ...)
220 221
 {
221
-	va_list args;
222
+	va_list args, argscpy;
222 223
 	FILE *fd;
223 224
 	char logbuf[512];
224 225
 
... ...
@@ -259,6 +262,8 @@ void mprintf(const char *str, ...)
259 259
 
260 260
 
261 261
     va_start(args, str);
262
+    /* va_copy is less portable so we just use va_start once more */
263
+    va_start(argscpy, str);
262 264
 
263 265
     if(*str == '!') {
264 266
 	fprintf(fd, "ERROR: ");
... ...
@@ -267,9 +272,9 @@ void mprintf(const char *str, ...)
267 267
 	fprintf(fd, "ERROR: ");
268 268
 	vfprintf(fd, ++str, args);
269 269
 #ifdef NO_SNPRINTF
270
-	vsprintf(logbuf, str, args);
270
+	vsprintf(logbuf, str, argscpy);
271 271
 #else
272
-	vsnprintf(logbuf, sizeof(logbuf), str, args);
272
+	vsnprintf(logbuf, sizeof(logbuf), str, argscpy);
273 273
 #endif
274 274
 	logg("ERROR: %s", logbuf);
275 275
     } else if(!mprintf_quiet) {
... ...
@@ -283,6 +288,7 @@ void mprintf(const char *str, ...)
283 283
     }
284 284
 
285 285
     va_end(args);
286
+    va_end(argscpy);
286 287
 
287 288
     if(fd == stdout)
288 289
 	fflush(stdout);