Revision: 77168
          http://sourceforge.net/p/brlcad/code/77168
Author:   brlcad
Date:     2020-09-17 13:19:52 +0000 (Thu, 17 Sep 2020)
Log Message:
-----------
prevent overflow condition if caller passes a -1 or other negative/invalid 
value.  encountered during dm option processing.

Modified Paths:
--------------
    brlcad/trunk/src/libbu/argv.c

Modified: brlcad/trunk/src/libbu/argv.c
===================================================================
--- brlcad/trunk/src/libbu/argv.c       2020-09-17 03:18:42 UTC (rev 77167)
+++ brlcad/trunk/src/libbu/argv.c       2020-09-17 13:19:52 UTC (rev 77168)
@@ -167,7 +167,7 @@
 {
     register size_t i;
 
-    if (UNLIKELY(!argv || argc <= 0)) {
+    if (UNLIKELY(!argv || (ssize_t)argc < 1)) {
        return;
     }
 
@@ -188,7 +188,7 @@
 {
     size_t count = 0;
 
-    if (UNLIKELY(!argv || argc <= 0)) {
+    if (UNLIKELY(!argv || (ssize_t)argc < 1)) {
        return;
     }
 
@@ -210,7 +210,7 @@
     register size_t i;
     char **av;
 
-    if (UNLIKELY(argc < 1))
+    if (UNLIKELY((ssize_t)argc < 1))
        return (char **)0;
 
     av = (char **)bu_calloc(argc+1, sizeof(char *), "bu_copy_argv");
@@ -230,7 +230,7 @@
     char **av;
 
     /* Nothing to insert */
-    if (insertArgc < 1)
+    if ((ssize_t)insertArgc < 1)
        return bu_argv_dup(argc, argv);
 
     av = (char **)bu_calloc(ac, sizeof(char *), "bu_insert_argv");

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