File tree 1 file changed +3
-8
lines changed
src/java.base/unix/native/libnet
1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -205,7 +205,6 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0
205
205
jboolean isCopy ;
206
206
const char * name_utf ;
207
207
char * colonP ;
208
- char searchName [IFNAMESIZE ];
209
208
jobject obj = NULL ;
210
209
211
210
if (name != NULL ) {
@@ -229,15 +228,11 @@ JNIEXPORT jobject JNICALL Java_java_net_NetworkInterface_getByName0
229
228
230
229
// search the list of interfaces based on name,
231
230
// if it is virtual sub interface search with parent first.
232
- strncpy (searchName , name_utf , IFNAMESIZE );
233
- searchName [IFNAMESIZE - 1 ] = '\0' ;
234
- colonP = strchr (searchName , ':' );
235
- if (colonP != NULL ) {
236
- * colonP = '\0' ;
237
- }
231
+ colonP = strchr (name_utf , ':' );
232
+ size_t limit = colonP != NULL ? (size_t )(colonP - name_utf ) : strlen (name_utf );
238
233
curr = ifs ;
239
234
while (curr != NULL ) {
240
- if (strcmp ( searchName , curr -> name ) == 0 ) {
235
+ if (strlen ( curr -> name ) == limit && memcmp ( name_utf , curr -> name , limit ) == 0 ) {
241
236
break ;
242
237
}
243
238
curr = curr -> next ;
You can’t perform that action at this time.
0 commit comments