Blame SOURCES/CVE-2019-16167_memory-corruption-due-to-an-integer-overflow.patch

3d4e1f
--- sa_common.c
3d4e1f
+++ sa_common.c
3d4e1f
@@ -1249,6 +1249,11 @@
3d4e1f
 	/* Remap [unsigned] long fields */
3d4e1f
 	d = gtypes_nr[0] - ftypes_nr[0];
3d4e1f
 	if (d) {
3d4e1f
+    
3d4e1f
+    if (ftypes_nr[0] * ULL_ALIGNMENT_WIDTH < ftypes_nr[0])
3d4e1f
+			/* Overflow */
3d4e1f
+			return;
3d4e1f
+
3d4e1f
 		memmove(((char *) ps) + gtypes_nr[0] * ULL_ALIGNMENT_WIDTH,
3d4e1f
 			((char *) ps) + ftypes_nr[0] * ULL_ALIGNMENT_WIDTH,
3d4e1f
 			st_size - ftypes_nr[0] * ULL_ALIGNMENT_WIDTH);
3d4e1f
@@ -1260,7 +1265,13 @@
3d4e1f
 	/* Remap [unsigned] int fields */
3d4e1f
 	d = gtypes_nr[1] - ftypes_nr[1];
3d4e1f
 	if (d) {
3d4e1f
-		memmove(((char *) ps) + gtypes_nr[0] * ULL_ALIGNMENT_WIDTH
3d4e1f
+		
3d4e1f
+    if (gtypes_nr[0] * ULL_ALIGNMENT_WIDTH +
3d4e1f
+		  ftypes_nr[1] * UL_ALIGNMENT_WIDTH < ftypes_nr[1])
3d4e1f
+        /* Overflow */
3d4e1f
+			  return;
3d4e1f
+
3d4e1f
+    memmove(((char *) ps) + gtypes_nr[0] * ULL_ALIGNMENT_WIDTH
3d4e1f
 				      + gtypes_nr[1] * UL_ALIGNMENT_WIDTH,
3d4e1f
 			((char *) ps) + gtypes_nr[0] * ULL_ALIGNMENT_WIDTH
3d4e1f
 				      + ftypes_nr[1] * UL_ALIGNMENT_WIDTH,
3d4e1f
@@ -1275,6 +1286,13 @@
3d4e1f
 	/* Remap possible fields (like strings of chars) following int fields */
3d4e1f
 	d = gtypes_nr[2] - ftypes_nr[2];
3d4e1f
 	if (d) {
3d4e1f
+		
3d4e1f
+    if (gtypes_nr[0] * ULL_ALIGNMENT_WIDTH +
3d4e1f
+		  gtypes_nr[1] * UL_ALIGNMENT_WIDTH +
3d4e1f
+		  ftypes_nr[2] * U_ALIGNMENT_WIDTH < ftypes_nr[2])	
3d4e1f
+        /* Overflow */
3d4e1f
+			  return;
3d4e1f
+
3d4e1f
 		memmove(((char *) ps) + gtypes_nr[0] * ULL_ALIGNMENT_WIDTH
3d4e1f
 				      + gtypes_nr[1] * UL_ALIGNMENT_WIDTH
3d4e1f
 				      + gtypes_nr[2] * U_ALIGNMENT_WIDTH,