提交 9d21d01b 编写于 作者: M msheppar

8040810: Uninitialised memory in jdk/src/windows/native/java/net:...

8040810: Uninitialised memory in jdk/src/windows/native/java/net: net_util_md.c, TwoStacksPlainSocketImpl.c, TwoStacksPlainDatagramSocketImpl.c, DualStackPlainSocketImpl.c, DualStackPlainDatagramSocketImpl.c
Summary: explicitly initialze local function variables
Reviewed-by: alanb
上级 91bec1fd
......@@ -462,7 +462,7 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSend
*/
JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSetIntOption
(JNIEnv *env, jclass clazz, jint fd , jint cmd, jint value) {
int level, opt;
int level = 0, opt = 0;
if (NET_MapSocketOption(cmd, &level, &opt) < 0) {
JNU_ThrowByNameWithLastError(env, JNU_JAVANETPKG "SocketException",
......@@ -482,7 +482,7 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketSetI
*/
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainDatagramSocketImpl_socketGetIntOption
(JNIEnv *env, jclass clazz, jint fd, jint cmd) {
int level, opt, result=0;
int level = 0, opt = 0, result=0;
int result_len = sizeof(result);
if (NET_MapSocketOption(cmd, &level, &opt) < 0) {
......
......@@ -367,8 +367,8 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_shutdown0
JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_setIntOption
(JNIEnv *env, jclass clazz, jint fd, jint cmd, jint value) {
int level, opt;
struct linger linger;
int level = 0, opt = 0;
struct linger linger = {0, 0};
char *parg;
int arglen;
......@@ -407,9 +407,9 @@ JNIEXPORT void JNICALL Java_java_net_DualStackPlainSocketImpl_setIntOption
JNIEXPORT jint JNICALL Java_java_net_DualStackPlainSocketImpl_getIntOption
(JNIEnv *env, jclass clazz, jint fd, jint cmd) {
int level, opt;
int level = 0, opt = 0;
int result=0;
struct linger linger;
struct linger linger = {0, 0};
char *arg;
int arglen;
......
......@@ -335,6 +335,8 @@ static jboolean purgeOutstandingICMP(JNIEnv *env, jobject this, jint fd)
struct sockaddr_in rmtaddr;
int addrlen = sizeof(rmtaddr);
memset((char *)&rmtaddr, 0, sizeof(rmtaddr));
/*
* A no-op if this OS doesn't support it.
*/
......@@ -431,9 +433,11 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_bind0(JNIEnv *env, jobject this,
int ipv6_supported = ipv6_available();
SOCKETADDRESS lcladdr;
int lcladdrlen;
int lcladdrlen = sizeof(lcladdr);
int address;
memset((char *)&lcladdr, 0, sizeof(lcladdr));
family = getInetAddress_family(env, addressObj);
if (family == IPv6 && !ipv6_supported) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
......@@ -617,7 +621,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject
}
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
memset(&addr, 0, len);
memset((char *)&addr, 0, len);
connect(fd, (struct sockaddr *)&addr, len);
/*
......@@ -625,7 +629,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_disconnect0(JNIEnv *env, jobject
* to disable ICMP port unreachable handling here.
*/
if (xp_or_later) {
DWORD x1, x2; /* ignored result codes */
DWORD x1 = 0, x2 = 0; /* ignored result codes */
int t = FALSE;
WSAIoctl(fd,SIO_UDP_CONNRESET,&t,sizeof(t),&x1,sizeof(x1),&x2,0,0);
}
......@@ -655,8 +659,9 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_send(JNIEnv *env, jobject this,
SOCKETADDRESS rmtaddr;
SOCKETADDRESS *addrp = &rmtaddr;
int addrlen;
int addrlen = 0;
memset((char *)&rmtaddr, 0, sizeof(rmtaddr));
if (IS_NULL(packet)) {
JNU_ThrowNullPointerException(env, "null packet");
......@@ -1444,7 +1449,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_receive0(JNIEnv *env, jobject thi
} else if (n < 0) {
NET_ThrowCurrent(env, "Datagram receive failed");
} else {
int port;
int port = 0;
jobject packetAddress;
/*
......@@ -1822,11 +1827,11 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketNativeSetOption(JNIEnv *env
jint opt,jobject value) {
int fd=-1, fd1=-1;
int levelv4, levelv6, optnamev4, optnamev6, optlen;
int levelv4 = 0, levelv6 = 0, optnamev4 = 0, optnamev6 = 0, optlen = 0;
union {
int i;
char c;
} optval;
} optval = { 0 };
int ipv6_supported = ipv6_available();
fd = getFD(env, this);
......@@ -2193,7 +2198,7 @@ Java_java_net_TwoStacksPlainDatagramSocketImpl_socketGetOption(JNIEnv *env, jobj
int level, optname, optlen;
union {
int i;
} optval;
} optval = {0};
int ipv6_supported = ipv6_available();
fd = getFD(env, this);
......@@ -2444,12 +2449,15 @@ static void mcast_join_leave(JNIEnv *env, jobject this,
struct ipv6_mreq mname6;
struct in_addr in;
DWORD ifindex;
DWORD ifindex = 0;
int len, family;
int ipv6_supported = ipv6_available();
int cmd ;
memset((char *)&in, 0, sizeof(in));
memset((char *)&name, 0, sizeof(name));
if (IS_NULL(fdObj) && IS_NULL(fd1Obj)) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException",
"Socket closed");
......
......@@ -208,6 +208,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketConnect(JNIEnv *env, jobject this,
/* The result of the connection */
int connect_res;
memset((char *)&him, 0, sizeof(him));
if (!IS_NULL(fdObj)) {
fd = (*env)->GetIntField(env, fdObj, IO_fd_fdID);
......@@ -400,7 +401,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketBind(JNIEnv *env, jobject this,
/* fdObj is the FileDescriptor field on this */
jobject fdObj, fd1Obj;
/* fd is an int field on fdObj */
int fd, fd1, len;
int fd, fd1, len = 0;
int ipv6_supported = ipv6_available();
/* family is an int field of iaObj */
......@@ -843,12 +844,13 @@ Java_java_net_TwoStacksPlainSocketImpl_socketNativeSetOption(JNIEnv *env,
jint cmd, jboolean on,
jobject value) {
int fd, fd1;
int level, optname, optlen;
int level = 0, optname = 0, optlen = 0;
union {
int i;
struct linger ling;
} optval;
memset((char *)&optval, 0, sizeof(optval));
/*
* Get SOCKET and check that it hasn't been closed
*/
......@@ -1009,17 +1011,17 @@ Java_java_net_TwoStacksPlainSocketImpl_socketGetOption(JNIEnv *env, jobject this
jint opt, jobject iaContainerObj) {
int fd, fd1;
int level, optname, optlen;
int level = 0, optname = 0, optlen = 0;
union {
int i;
struct linger ling;
} optval;
/*
* Get SOCKET and check it hasn't been closed
*/
fd = getFD(env, this);
fd1 = getFD1(env, this);
memset((char *)&optval, 0, sizeof(optval));
if (fd < 0 && fd1 < 0) {
JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket closed");
......@@ -1043,6 +1045,7 @@ Java_java_net_TwoStacksPlainSocketImpl_socketGetOption(JNIEnv *env, jobject this
jfieldID iaFieldID;
len = sizeof(him);
memset((char *)&him, 0, len);
if (fd == -1) {
/* must be an IPV6 only socket. Case where both sockets are != -1
......
......@@ -389,8 +389,8 @@ JNIEXPORT int JNICALL
NET_SetSockOpt(int s, int level, int optname, const void *optval,
int optlen)
{
int rv;
int parg;
int rv = 0;
int parg = 0;
int plen = sizeof(parg);
if (level == IPPROTO_IP && optname == IP_TOS) {
......@@ -481,7 +481,7 @@ NET_GetSockOpt(int s, int level, int optname, void *optval,
* Sets SO_ECLUSIVEADDRUSE if SO_REUSEADDR is not already set.
*/
void setExclusiveBind(int fd) {
int parg;
int parg = 0;
int plen = sizeof(parg);
int rv = 0;
rv = NET_GetSockOpt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&parg, &plen);
......@@ -502,7 +502,7 @@ void setExclusiveBind(int fd) {
JNIEXPORT int JNICALL
NET_Bind(int s, struct sockaddr *him, int len)
{
int rv;
int rv = 0;
rv = bind(s, him, len);
if (rv == SOCKET_ERROR) {
......@@ -532,8 +532,8 @@ NET_WinBind(int s, struct sockaddr *him, int len, jboolean exclBind)
JNIEXPORT int JNICALL
NET_SocketClose(int fd) {
struct linger l;
int ret;
struct linger l = {0, 0};
int ret = 0;
int len = sizeof (l);
if (getsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&l, &len) == 0) {
if (l.l_onoff == 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册