changeset 6291:2ae98255c689

8038296: sun/tools/jinfo/Basic.sh: java.io.IOException: Command failed in target VM Reviewed-by: sspitsyn, coleenp, dsamersoff
author sla
date Tue, 08 Apr 2014 08:14:14 +0200
parents 841539b22165
children 8d65cf10c446
files src/os/solaris/vm/attachListener_solaris.cpp
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/solaris/vm/attachListener_solaris.cpp	Sat Apr 05 20:59:37 2014 +0000
+++ b/src/os/solaris/vm/attachListener_solaris.cpp	Tue Apr 08 08:14:14 2014 +0200
@@ -29,6 +29,7 @@
 #include "services/dtraceAttacher.hpp"
 
 #include <door.h>
+#include <limits.h>
 #include <string.h>
 #include <signal.h>
 #include <sys/types.h>
@@ -668,11 +669,13 @@
     out->print_cr("No probe specified");
     return JNI_ERR;
   } else {
-    int probe_typess = atoi(probe);
-    if (errno) {
+    char *end;
+    long val = strtol(probe, &end, 10);
+    if (end == probe || val < 0 || val > INT_MAX) {
       out->print_cr("invalid probe type");
       return JNI_ERR;
     } else {
+      int probe_typess = (int) val;
       DTrace::enable_dprobes(probe_typess);
       return JNI_OK;
     }
@@ -703,8 +706,9 @@
   bool flag = true;
   const char* arg1;
   if ((arg1 = op->arg(1)) != NULL) {
-    flag = (atoi(arg1) != 0);
-    if (errno) {
+    char *end;
+    flag = (strtol(arg1, &end, 10) != 0);
+    if (arg1 == end) {
       out->print_cr("flag value has to be an integer");
       return JNI_ERR;
     }