8038296: sun/tools/jinfo/Basic.sh: java.io.IOException: Command failed in target VM
authorsla
Tue, 08 Apr 2014 08:14:14 +0200
changeset 23870 2c9e85bccffb
parent 23869 41e28d356a5b
child 23871 0456e228b90d
8038296: sun/tools/jinfo/Basic.sh: java.io.IOException: Command failed in target VM Reviewed-by: sspitsyn, coleenp, dsamersoff
hotspot/src/os/solaris/vm/attachListener_solaris.cpp
--- a/hotspot/src/os/solaris/vm/attachListener_solaris.cpp	Sat Apr 05 20:59:37 2014 +0000
+++ b/hotspot/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;
     }