Commits

Anonymous committed 88b5ee7

add some default recursion and array length processing limits

  • Participants
  • Parent commits 5ebdb80
  • Branches onering

Comments (0)

Files changed (1)

 #include "impl.h"
 
 static gimli_hash_t derefd = NULL;
+static int max_depth = 4;
+static int max_arr = 16;
 
 static char indentstr[] =
 "                                                                      ";
     printf(" ]");
     return;
   }
+  if (depth + 1 > max_depth) {
+    printf("[ ... ]");
+    return;
+  }
 
   is_struct = 0;
   switch (gimli_type_kind(target)) {
   data.terse = 1;
   data.in_array++;
 
-  for (i = 0; i < arinfo.nelems; i++) {
+  for (i = 0; i < arinfo.nelems && i < max_arr; i++) {
     data.depth = depth + 1;
     data.addr = addr + (i * (data.size / 8));
 
     }
     print_var(&data, target, "");
   }
+  if (arinfo.nelems > max_arr) {
+    printf(" ...");
+  }
   printf("\n%.*s]", (depth + 1) * 4, indentstr);
 }
 
     return;
   }
 
+  if (data->depth + 1 > max_depth) {
+    printf(PTRFMT, ptr);
+    return;
+  }
 
   snprintf(addrkey, sizeof(addrkey), "%p:%" PRIx64, target, data->addr);
   if (gimli_hash_find(derefd, addrkey, (void**)&dummy)) {