Blame SOURCES/sendmail-8.16.0.29-fix-covscan-issues.patch

2a7a23
diff --git a/include/sm/varargs.h b/include/sm/varargs.h
2a7a23
index 612858d..2609630 100644
2a7a23
--- a/include/sm/varargs.h
2a7a23
+++ b/include/sm/varargs.h
2a7a23
@@ -32,6 +32,11 @@
2a7a23
 #  define SM_VA_COPY(dst, src)	__va_copy((dst), (src))
2a7a23
 # else
2a7a23
 #  define SM_VA_COPY(dst, src)	memcpy(&(dst), &(src), sizeof((dst)))
2a7a23
+#  define SM_VA_END_COPY(ap)	do { } while (0)
2a7a23
+# endif
2a7a23
+
2a7a23
+# ifndef SM_VA_END_COPY
2a7a23
+#  define SM_VA_END_COPY(ap)	va_end(ap)
2a7a23
 # endif
2a7a23
 
2a7a23
 /*
2a7a23
diff --git a/libsm/vfprintf.c b/libsm/vfprintf.c
2a7a23
index 87c353c..c99d4e5 100644
2a7a23
--- a/libsm/vfprintf.c
2a7a23
+++ b/libsm/vfprintf.c
2a7a23
@@ -782,6 +782,7 @@ number:			if ((dprec = prec) >= 0)
2a7a23
 done:
2a7a23
 	FLUSH();
2a7a23
 error:
2a7a23
+	SM_VA_END_COPY(orgap);
2a7a23
 	if ((argtable != NULL) && (argtable != statargtable))
2a7a23
 		sm_free(argtable);
2a7a23
 	return sm_error(fp) ? SM_IO_EOF : ret;
2a7a23
diff --git a/sendmail/milter.c b/sendmail/milter.c
2a7a23
index 462efd2..af6dc66 100644
2a7a23
--- a/sendmail/milter.c
2a7a23
+++ b/sendmail/milter.c
2a7a23
@@ -2437,8 +2437,7 @@ milter_negotiate(m, e, milters)
2a7a23
 			sm_syslog(LOG_ERR, e->e_id,
2a7a23
 				  "Milter (%s): negotiate: returned %c instead of %c",
2a7a23
 				  m->mf_name, rcmd, SMFIC_OPTNEG);
2a7a23
-		if (response != NULL)
2a7a23
-			sm_free(response); /* XXX */
2a7a23
+		SM_FREE(response);
2a7a23
 		milter_error(m, e);
2a7a23
 		return -1;
2a7a23
 	}
2a7a23
@@ -2453,8 +2452,7 @@ milter_negotiate(m, e, milters)
2a7a23
 			sm_syslog(LOG_ERR, e->e_id,
2a7a23
 				  "Milter (%s): negotiate: did not return valid info",
2a7a23
 				  m->mf_name);
2a7a23
-		if (response != NULL)
2a7a23
-			sm_free(response); /* XXX */
2a7a23
+		SM_FREE(response);
2a7a23
 		milter_error(m, e);
2a7a23
 		return -1;
2a7a23
 	}
2a7a23
@@ -2472,8 +2470,7 @@ milter_negotiate(m, e, milters)
2a7a23
 			sm_syslog(LOG_ERR, e->e_id,
2a7a23
 				  "Milter (%s): negotiate: did not return enough info",
2a7a23
 				  m->mf_name);
2a7a23
-		if (response != NULL)
2a7a23
-			sm_free(response); /* XXX */
2a7a23
+		SM_FREE(response);
2a7a23
 		milter_error(m, e);
2a7a23
 		return -1;
2a7a23
 	}
2a7a23
@@ -2589,11 +2586,11 @@ milter_negotiate(m, e, milters)
2a7a23
 	if (tTd(64, 5))
2a7a23
 		sm_dprintf("milter_negotiate(%s): received: version %u, fflags 0x%x, pflags 0x%x\n",
2a7a23
 			m->mf_name, m->mf_fvers, m->mf_fflags, m->mf_pflags);
2a7a23
+	SM_FREE(response);
2a7a23
 	return 0;
2a7a23
 
2a7a23
   error:
2a7a23
-	if (response != NULL)
2a7a23
-		sm_free(response); /* XXX */
2a7a23
+	SM_FREE(response);
2a7a23
 	return -1;
2a7a23
 }
2a7a23
 
2a7a23
@@ -3230,6 +3227,7 @@ milter_changeheader(m, response, rlen, e)
2a7a23
 			addheader(newstr(field), mh_value, H_USER, e,
2a7a23
 				!bitset(SMFIP_HDR_LEADSPC, m->mf_pflags));
2a7a23
 		}
2a7a23
+		SM_FREE(mh_value);
2a7a23
 		return;
2a7a23
 	}
2a7a23
 
2a7a23
@@ -3438,6 +3436,8 @@ milter_chgfrom(response, rlen, e)
2a7a23
 	{
2a7a23
 		if (tTd(64, 10))
2a7a23
 			sm_dprintf("didn't follow protocol argc=%d\n", argc);
2a7a23
+		if (argv != NULL)
2a7a23
+			free(argv);
2a7a23
 		return;
2a7a23
 	}
2a7a23
 
2a7a23
@@ -3456,6 +3456,7 @@ milter_chgfrom(response, rlen, e)
2a7a23
 				mail_esmtp_args);
2a7a23
 	}
2a7a23
 	Errors = olderrors;
2a7a23
+	free(argv);
2a7a23
 	return;
2a7a23
 }
2a7a23
 
2a7a23
@@ -3503,6 +3504,8 @@ milter_addrcpt_par(response, rlen, e)
2a7a23
 	{
2a7a23
 		if (tTd(64, 10))
2a7a23
 			sm_dprintf("didn't follow protocol argc=%d\n", argc);
2a7a23
+		if (argv != NULL)
2a7a23
+			free(argv);
2a7a23
 		return;
2a7a23
 	}
2a7a23
 	olderrors = Errors;
2a7a23
@@ -3527,6 +3530,7 @@ milter_addrcpt_par(response, rlen, e)
2a7a23
 	}
2a7a23
 
2a7a23
 	Errors = olderrors;
2a7a23
+	free(argv);
2a7a23
 	return;
2a7a23
 }
2a7a23
 
2a7a23
diff --git a/sendmail/queue.c b/sendmail/queue.c
2a7a23
index 503f296..c9153c8 100644
2a7a23
--- a/sendmail/queue.c
2a7a23
+++ b/sendmail/queue.c
2a7a23
@@ -8590,6 +8590,7 @@ split_by_recipient(e)
2a7a23
 		if (split_within_queue(ee) == SM_SPLIT_FAIL)
2a7a23
 		{
2a7a23
 			e->e_sibling = firstsibling;
2a7a23
+			SM_FREE(lsplits);
2a7a23
 			return false;
2a7a23
 		}
2a7a23
 		ee->e_flags |= EF_SPLIT;
2a7a23
@@ -8604,8 +8605,7 @@ split_by_recipient(e)
2a7a23
 				if (p == NULL)
2a7a23
 				{
2a7a23
 					/* let's try to get this done */
2a7a23
-					sm_free(lsplits);
2a7a23
-					lsplits = NULL;
2a7a23
+					SM_FREE(lsplits);
2a7a23
 				}
2a7a23
 				else
2a7a23
 					lsplits = p;
2a7a23
@@ -8627,7 +8627,7 @@ split_by_recipient(e)
2a7a23
 	{
2a7a23
 		sm_syslog(LOG_NOTICE, e->e_id, "split: count=%d, id%s=%s",
2a7a23
 			  n - 1, n > 2 ? "s" : "", lsplits);
2a7a23
-		sm_free(lsplits);
2a7a23
+		SM_FREE(lsplits);
2a7a23
 	}
2a7a23
 	split = split_within_queue(e) != SM_SPLIT_FAIL;
2a7a23
 	if (split)