Hi Alan, Christos,
I've looked at the changes that Christos suggested and also how Martin
fixed UNIXProcess_md. Here is what I believe the final change should
look like.
Comments:
1) "3. last is possibly uninitialized."
We have already fixed this in a previous changeset, see [1]
2) I made similar changes to Inet6AddressImpl as well as for Inet4
Source Changes:
diff --git a/src/solaris/native/java/net/Inet4AddressImpl.c
b/src/solaris/native/java/net/Inet4AddressImpl.c
--- a/src/solaris/native/java/net/Inet4AddressImpl.c
+++ b/src/solaris/native/java/net/Inet4AddressImpl.c
@@ -169,7 +169,7 @@ Java_java_net_Inet4AddressImpl_lookupAll
* Workaround for Solaris bug 4160367 - if a hostname contains a
* white space then 0.0.0.0 is returned
*/
- if (isspace(hostname[0])) {
+ if (isAsciiSpace(hostname[0])) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
@@ -325,7 +325,8 @@ ping4(JNIEnv *env, jint fd, struct socka
ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
struct sockaddr_in* netif, jint ttl) {
jint size;
- jint n, len, hlen1, icmplen;
+ jint n, hlen1, icmplen;
+ socklen_t len;
char sendbuf[1500];
char recvbuf[1500];
struct icmp *icmp;
diff --git a/src/solaris/native/java/net/Inet6AddressImpl.c
b/src/solaris/native/java/net/Inet6AddressImpl.c
--- a/src/solaris/native/java/net/Inet6AddressImpl.c
+++ b/src/solaris/native/java/net/Inet6AddressImpl.c
@@ -200,7 +200,7 @@ Java_java_net_Inet6AddressImpl_lookupAll
* Workaround for Solaris bug 4160367 - if a hostname contains a
* white space then 0.0.0.0 is returned
*/
- if (isspace(hostname[0])) {
+ if (isAsciiSpace(hostname[0])) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
@@ -455,7 +455,8 @@ ping6(JNIEnv *env, jint fd, struct socka
ping6(JNIEnv *env, jint fd, struct sockaddr_in6* him, jint timeout,
struct sockaddr_in6* netif, jint ttl) {
jint size;
- jint n, len;
+ jint n;
+ socklen_t len;
char sendbuf[1500];
unsigned char recvbuf[1500];
struct icmp6_hdr *icmp6;
diff --git a/src/solaris/native/java/net/net_util_md.h
b/src/solaris/native/java/net/net_util_md.h
--- a/src/solaris/native/java/net/net_util_md.h
+++ b/src/solaris/native/java/net/net_util_md.h
@@ -106,6 +106,11 @@ extern jboolean NET_addrtransAvailable()
extern jint NET_Wait(JNIEnv *env, jint fd, jint flags, jint timeout);
+static int isAsciiSpace(char c) {
+ return (((c) == '\t') || ((c) == '\r') || ((c) == '\b') ||
+ ((c) == '\n') || ((c) == ' ') );
+}
+
/************************************************************************
* Macros and constants
*/
-Chris.
[1]
http://hg.openjdk.java.net/jdk7/tl/jdk/annotate/f9cf49b7b248/src/solaris/native/java/net/Inet6AddressImpl.c
On 01/30/09 10:36, Christopher Hegarty - Sun Microsystems Ireland wrote:
Hi Alan,
Yes, I will assign 6799040 to myself and work with Christos to finalize
the networking changes.
Thanks,
-Chris.
Alan Bateman wrote:
Christos mailed core-libs-dev yesterday with a few portability
issues.Anyone have cycles to look at the Inet4AddressImpl.c changes?
I've created 6799040 to track it. Martin has already pushed a
changeset to jdk7/tl/jdk for the UNIXProcess_md.c issue.
------------------------------------------------------------------------
Subject:
[PATCH]: Portability fixes
From:
chris...@zoulas.com (Christos Zoulas)
Date:
Wed, 28 Jan 2009 14:44:37 -0500
To:
core-libs-...@openjdk.java.net
To:
core-libs-...@openjdk.java.net
Hello,
Here are some simple changes for your consideration:
1. passing possibly negative values to isdigit is undefined behavior:
http://www.opengroup.org/onlinepubs/009695399/functions/isdigit.html
2. passing possibly negative values to isspace is undefined behavior:
http://www.opengroup.org/onlinepubs/009695399/functions/isspace.html
3. last is possibly uninitialized.
4. recvfrom argument should be socklen_t not int:
http://www.opengroup.org/onlinepubs/007908775/xns/recvfrom.html
Thanks,
christos
diff -r fc30e7f4b9b3 src/solaris/native/java/lang/UNIXProcess_md.c
--- a/src/solaris/native/java/lang/UNIXProcess_md.c Fri Jan 16
11:24:18 2009 -0500
+++ b/src/solaris/native/java/lang/UNIXProcess_md.c Mon Jan 22
16:25:36 2009 -0500
@@ -377,7 +377,7 @@
*/
while ((dirp = readdir(dp)) != NULL) {
int fd;
- if (isdigit(dirp->d_name[0]) &&
+ if (isdigit((unsigned char)dirp->d_name[0]) &&
(fd = strtol(dirp->d_name, NULL, 10)) >= from_fd + 2)
close(fd);
}
diff -r fc30e7f4b9b3 src/solaris/native/java/net/Inet4AddressImpl.c
--- a/src/solaris/native/java/net/Inet4AddressImpl.c Fri Jan 16
11:24:18 2009 -0500
+++ b/src/solaris/native/java/net/Inet4AddressImpl.c Mon Jan 22
16:25:36 2009 -0500
@@ -155,7 +155,7 @@
* Workaround for Solaris bug 4160367 - if a hostname contains a
* white space then 0.0.0.0 is returned
*/
- if (isspace(hostname[0])) {
+ if (isspace((unsigned char)hostname[0])) {
JNU_ThrowByName(env, JNU_JAVANETPKG "UnknownHostException",
(char *)hostname);
JNU_ReleaseStringPlatformChars(env, host, hostname);
@@ -172,7 +172,7 @@
return NULL;
} else {
int i = 0;
- struct addrinfo *itr, *last, *iterator = res;
+ struct addrinfo *itr, *last = NULL, *iterator = res;
while (iterator != NULL) {
int skip = 0;
itr = resNew;
@@ -603,7 +603,8 @@
ping4(JNIEnv *env, jint fd, struct sockaddr_in* him, jint timeout,
struct sockaddr_in* netif, jint ttl) {
jint size;
- jint n, len, hlen1, icmplen;
+ jint n, hlen1, icmplen;
+ socklen_t len;
char sendbuf[1500];
char recvbuf[1500];
struct icmp *icmp;