Browse code

Avoid unlocking unlocked mutex in clamfi_abort

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

Nigel Horne authored on 2004/06/22 13:09:16
Showing 2 changed files
... ...
@@ -409,6 +409,10 @@ Changes
409 409
 		In template files support {sendmail-variable} and support \%v
410 410
 			to send the %v string
411 411
 		Tidyup handling if the quarantine directory can't be created
412
+0.73c	21/6/04	Call trylock in clamfi_abort before unlock to prevent attempt
413
+			to unlock not locked mutex since we have no control
414
+			over when clamfi_abort() is called
415
+		Remove warning message on FreeBSD5.2
412 416
 
413 417
 BUG REPORTS
414 418
 
... ...
@@ -26,6 +26,9 @@
26 26
  *
27 27
  * Change History:
28 28
  * $Log: clamav-milter.c,v $
29
+ * Revision 1.98  2004/06/22 04:09:12  nigelhorne
30
+ * Avoid unlocking unlocked mutex in clamfi_abort
31
+ *
29 32
  * Revision 1.97  2004/06/16 08:08:47  nigelhorne
30 33
  * Allow access to sendmail variables in the template file
31 34
  *
... ...
@@ -302,9 +305,9 @@
302 302
  * Revision 1.6  2003/09/28 16:37:23  nigelhorne
303 303
  * Added -f flag use MaxThreads if --max-children not set
304 304
  */
305
-static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.97 2004/06/16 08:08:47 nigelhorne Exp $";
305
+static	char	const	rcsid[] = "$Id: clamav-milter.c,v 1.98 2004/06/22 04:09:12 nigelhorne Exp $";
306 306
 
307
-#define	CM_VERSION	"0.73b"
307
+#define	CM_VERSION	"0.73c"
308 308
 
309 309
 /*#define	CONFDIR	"/usr/local/etc"*/
310 310
 
... ...
@@ -2235,8 +2238,10 @@ clamfi_abort(SMFICTX *ctx)
2235 2235
 	 *
2236 2236
 	 * TODO: There *must* be a tidier a safer way of doing this!
2237 2237
 	 */
2238
-	if((max_children > 0) && (n_children >= max_children))
2238
+	if((max_children > 0) && (n_children >= max_children)) {
2239
+		(void)pthread_mutex_trylock(&n_children_mutex);
2239 2240
 		(void)pthread_mutex_unlock(&n_children_mutex);
2241
+	}
2240 2242
 
2241 2243
 	clamfi_cleanup(ctx);
2242 2244
 
... ...
@@ -2647,7 +2652,7 @@ connect2clamd(struct privdata *privdata)
2647 2647
 		 * store message in a temporary file
2648 2648
 		 */
2649 2649
 		int ntries = 5;
2650
-		long t;
2650
+		time_t t;
2651 2651
 		int MM, YY, DD;
2652 2652
 		const struct tm *tm;
2653 2653
 
... ...
@@ -2656,7 +2661,7 @@ connect2clamd(struct privdata *privdata)
2656 2656
 		 * <Christian.Pelissier@onera.fr>. Store different days
2657 2657
 		 * in different directories to make them easier to manage
2658 2658
 		 */
2659
-		t = time((long *)0);
2659
+		t = time((time_t *)0);
2660 2660
 		tm = localtime(&t);
2661 2661
 		MM = tm->tm_mon + 1;
2662 2662
 		YY = tm->tm_year - 100;