File overflow.patch of Package slang

Index: slang-2.3.1a/src/slarray.c
===================================================================
--- slang-2.3.1a.orig/src/slarray.c
+++ slang-2.3.1a/src/slarray.c
@@ -22,6 +22,7 @@ USA.
 
 #include "slinclud.h"
 #include <math.h>
+#include <limits.h>
 
 /* #define SL_APP_WANTS_FOREACH */
 #include "slang.h"
@@ -368,13 +369,13 @@ SLang_create_array1 (SLtype type, int re
      {
 	SLindex_Type new_num_elements;
 	at->dims[i] = dims[i];
-	new_num_elements = dims[i] * num_elements;
-	if (dims[i] && (new_num_elements/dims[i] != num_elements))
+	if (dims[i] && (INT_MAX/dims[i] < num_elements))
 	  {
 	     throw_size_error (SL_Index_Error);
 	     free_array (at);
 	     return NULL;
 	  }
+	new_num_elements = dims[i] * num_elements;
 	num_elements = new_num_elements;
      }
 
@@ -395,13 +396,13 @@ SLang_create_array1 (SLtype type, int re
 	return at;
      }
 
-   size = (num_elements * sizeof_type);
-   if ((size/sizeof_type != num_elements) || (size < 0))
+   if (INT_MAX/sizeof_type < num_elements)
      {
 	throw_size_error (SL_INVALID_PARM);
 	free_array (at);
 	return NULL;
      }
+   size = (num_elements * sizeof_type);
 
    if (size == 0) size = 1;
 
openSUSE Build Service is sponsored by