Revision: 75607
          http://sourceforge.net/p/brlcad/code/75607
Author:   starseeker
Date:     2020-04-25 19:26:45 +0000 (Sat, 25 Apr 2020)
Log Message:
-----------
Not really sure we need to, but go ahead and check errno here.

Modified Paths:
--------------
    brlcad/trunk/src/libdm/tcl_img.cpp

Modified: brlcad/trunk/src/libdm/tcl_img.cpp
===================================================================
--- brlcad/trunk/src/libdm/tcl_img.cpp  2020-04-25 19:11:42 UTC (rev 75606)
+++ brlcad/trunk/src/libdm/tcl_img.cpp  2020-04-25 19:26:45 UTC (rev 75607)
@@ -104,10 +104,21 @@
        return TCL_ERROR;
     }
 
-    // Unpack the coordinates (TODO - check errno)
+    // Unpack the coordinates (checking errno, although it may not truly be
+    // necessary if we trust Tk to always give us valid coordinates...)
     char *p_end;
+    errno = 0;
     long xcoor = strtol(argv[1], &p_end, 10);
+    if (errno == ERANGE || (errno != 0 && xcoor == 0) || p_end == argv[1]) {
+       std::cerr << "Invalid image_paint_xy X coordinate: " << argv[1] << "\n";
+       return TCL_ERROR;
+    }
+    errno = 0;
     long ycoor = strtol(argv[2], &p_end, 10);
+    if (errno == ERANGE || (errno != 0 && xcoor == 0) || p_end == argv[1]) {
+       std::cerr << "Invalid image_paint_xy Y coordinate: " << argv[2] << "\n";
+       return TCL_ERROR;
+    }
 
     // Look up the internals of the image - we're going to directly manipulate
     // the values of the image to simulate a display manager or framebuffer

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



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to