SF.net SVN: fricas:[2634] trunk

0 views
Skip to first unread message

wheb...@users.sourceforge.net

unread,
Mar 6, 2020, 8:45:14 AM3/6/20
to fricas...@googlegroups.com
Revision: 2634
http://sourceforge.net/p/fricas/code/2634
Author: whebisch
Date: 2020-03-06 13:45:08 +0000 (Fri, 06 Mar 2020)
Log Message:
-----------
Prevent signed integer overflow

Modified Paths:
--------------
trunk/ChangeLog
trunk/src/graph/include/write.h
trunk/src/graph/view2D/write2d.c
trunk/src/graph/view3D/write3d.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2020-03-04 17:56:05 UTC (rev 2633)
+++ trunk/ChangeLog 2020-03-06 13:45:08 UTC (rev 2634)
@@ -1,3 +1,8 @@
+2020-03-06 Neven Sajko <nsa...@gmail.com>
+
+ * src/graph/include/write.h, src/graph/view2D/write2d.c,
+ src/graph/view3D/write3d.c: Prevent signed integer overflow
+
2020-03-04 Neven Sajko <nsa...@gmail.com>

* src/sman/sman.c: Prevent heap buffer overflow

Modified: trunk/src/graph/include/write.h
===================================================================
--- trunk/src/graph/include/write.h 2020-03-04 17:56:05 UTC (rev 2633)
+++ trunk/src/graph/include/write.h 2020-03-06 13:45:08 UTC (rev 2634)
@@ -40,3 +40,6 @@
#define Bitmap 2
#define Postscript 3
#define Image 4
+
+/* Not an output type, but must equal the greatest output type + 1 */
+#define OutTypeLimit 5

Modified: trunk/src/graph/view2D/write2d.c
===================================================================
--- trunk/src/graph/view2D/write2d.c 2020-03-04 17:56:05 UTC (rev 2633)
+++ trunk/src/graph/view2D/write2d.c 2020-03-06 13:45:08 UTC (rev 2634)
@@ -45,9 +45,6 @@
#include "Gfun.H1"
#include "strutil.h"

-
-#define numBits (8*sizeof(int))
-
int
writeViewport(int thingsToWrite)
{
@@ -141,7 +138,7 @@
} /* else */

/* write out special files */
- for (ii=1; ii<numBits; ii++) { /* write.h is one-based */
+ for (ii=1; ii<OutTypeLimit; ii++) { /* write.h is one-based */
if (thingsToWrite & (1<<ii)) {
switch (ii) {
case Pixmap:

Modified: trunk/src/graph/view3D/write3d.c
===================================================================
--- trunk/src/graph/view3D/write3d.c 2020-03-04 17:56:05 UTC (rev 2633)
+++ trunk/src/graph/view3D/write3d.c 2020-03-06 13:45:08 UTC (rev 2634)
@@ -49,8 +49,6 @@
#include "all_3d.H1"
#include "strutil.h"

- /* upper limit as to how many kinds of files could be written (numBits-1) */
-#define numBits (8*sizeof(int))
#define StellarColors 9

int
@@ -136,7 +134,7 @@
} /* else was able to open file under the given filename */

/* write out special files */
- for (ii=1; ii<numBits; ii++) { /* write.h is one-based */
+ for (ii=1; ii<OutTypeLimit; ii++) { /* write.h is one-based */
if (thingsToWrite & (1<<ii)) {
switch (ii) {
case Bitmap:

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Reply all
Reply to author
Forward
0 new messages