Skip to content

Commit d03a5d9

Browse files
committed
8299593: getprotobyname should not be used
Reviewed-by: cjplummer
1 parent c444922 commit d03a5d9

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/jdk.jdwp.agent/unix/native/libdt_socket/socket_md.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -189,11 +189,9 @@ int
189189
dbgsysSetSocketOption(int fd, jint cmd, jboolean on, jvalue value)
190190
{
191191
if (cmd == TCP_NODELAY) {
192-
struct protoent *proto = getprotobyname("TCP");
193-
int tcp_level = (proto == 0 ? IPPROTO_TCP: proto->p_proto);
194192
uint32_t onl = (uint32_t)on;
195193

196-
if (setsockopt(fd, tcp_level, TCP_NODELAY,
194+
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
197195
(char *)&onl, sizeof(uint32_t)) < 0) {
198196
return SYS_ERR;
199197
}

src/jdk.jdwp.agent/windows/native/libdt_socket/socket_md.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -268,11 +268,9 @@ int
268268
dbgsysSetSocketOption(int fd, jint cmd, jboolean on, jvalue value)
269269
{
270270
if (cmd == TCP_NODELAY) {
271-
struct protoent *proto = getprotobyname("TCP");
272-
int tcp_level = (proto == 0 ? IPPROTO_TCP: proto->p_proto);
273271
long onl = (long)on;
274272

275-
if (setsockopt(fd, tcp_level, TCP_NODELAY,
273+
if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY,
276274
(char *)&onl, sizeof(long)) < 0) {
277275
return SYS_ERR;
278276
}

0 commit comments

Comments
 (0)