Skip to content

Commit

Permalink
8252997: Null-proofing for linker_md.c
Browse files Browse the repository at this point in the history
Reviewed-by: sspitsyn
  • Loading branch information
Adam Farley authored and shipilev committed Oct 7, 2020
1 parent 97ff38c commit 4dfa411
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/jdk.jdwp.agent/unix/native/libjdwp/linker_md.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -49,11 +49,12 @@ static void dll_build_name(char* buffer, size_t buflen,
*buffer = '\0';

paths_copy = jvmtiAllocate((int)strlen(paths) + 1);
strcpy(paths_copy, paths);
if (paths_copy == NULL) {
return;
}

strcpy(paths_copy, paths);

next_token = NULL;
path = strtok_r(paths_copy, PATH_SEPARATOR, &next_token);

Expand Down
5 changes: 3 additions & 2 deletions src/jdk.jdwp.agent/windows/native/libjdwp/linker_md.c
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -46,11 +46,12 @@ static void dll_build_name(char* buffer, size_t buflen,
*buffer = '\0';

paths_copy = jvmtiAllocate((int)strlen(paths) + 1);
strcpy(paths_copy, paths);
if (paths_copy == NULL) {
return;
}

strcpy(paths_copy, paths);

next_token = NULL;
path = strtok_s(paths_copy, PATH_SEPARATOR, &next_token);

Expand Down

1 comment on commit 4dfa411

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on 4dfa411 Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.