src/os/solaris/vm/attachListener_solaris.cpp
Print this page
rev 6165 : imported patch atoi.diff
@@ -27,10 +27,11 @@
#include "runtime/os.hpp"
#include "services/attachListener.hpp"
#include "services/dtraceAttacher.hpp"
#include <door.h>
+#include <limits.h>
#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/stat.h>
@@ -666,15 +667,17 @@
const char* probe = op->arg(0);
if (probe == NULL || probe[0] == '\0') {
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;
}
}
}
@@ -701,12 +704,13 @@
const char* name = op->arg(0);
assert(name != NULL, "flag name should not be null");
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;
}
}