< prev index next >
src/jdk.jdwp.agent/windows/native/libjdwp/linker_md.c
Print this page
*** 35,61 ****
#include <io.h>
#include <stdlib.h>
#include "sys.h"
#include "path_md.h"
static void dll_build_name(char* buffer, size_t buflen,
const char* paths, const char* fname) {
char *path, *paths_copy, *next_token;
paths_copy = strdup(paths);
if (paths_copy == NULL) {
return;
}
next_token = NULL;
path = strtok_s(paths_copy, PATH_SEPARATOR, &next_token);
while (path != NULL) {
! _snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
! if (_access(buffer, 0) == 0) {
break;
}
*buffer = '\0';
path = strtok_s(NULL, PATH_SEPARATOR, &next_token);
}
--- 35,66 ----
#include <io.h>
#include <stdlib.h>
#include "sys.h"
+ #include "util.h"
#include "path_md.h"
static void dll_build_name(char* buffer, size_t buflen,
const char* paths, const char* fname) {
char *path, *paths_copy, *next_token;
+ *buffer = '\0';
paths_copy = strdup(paths);
if (paths_copy == NULL) {
return;
}
next_token = NULL;
path = strtok_s(paths_copy, PATH_SEPARATOR, &next_token);
while (path != NULL) {
! size_t result_len = (size_t)_snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
! if (result_len >= buflen) {
! EXIT_ERROR(JVMTI_ERROR_INVALID_LOCATION, "One or more of the library paths supplied to jdwp, "
! "likely by sun.boot.library.path, is too long.");
! } else if (_access(buffer, 0) == 0) {
break;
}
*buffer = '\0';
path = strtok_s(NULL, PATH_SEPARATOR, &next_token);
}
*** 105,121 ****
void
dbgsysBuildLibName(char *holder, int holderlen, const char *pname, const char *fname)
{
const int pnamelen = pname ? (int)strlen(pname) : 0;
! *holder = '\0';
! /* Quietly truncates on buffer overflow. Should be an error. */
if (pnamelen + (int)strlen(fname) + 10 > holderlen) {
! return;
}
-
- if (pnamelen == 0) {
sprintf(holder, "%s.dll", fname);
} else {
dll_build_name(holder, holderlen, pname, fname);
}
}
--- 110,124 ----
void
dbgsysBuildLibName(char *holder, int holderlen, const char *pname, const char *fname)
{
const int pnamelen = pname ? (int)strlen(pname) : 0;
! if (pnamelen == 0) {
if (pnamelen + (int)strlen(fname) + 10 > holderlen) {
! EXIT_ERROR(JVMTI_ERROR_INVALID_LOCATION, "One or more of the library paths supplied to jdwp, "
! "likely by sun.boot.library.path, is too long.");
}
sprintf(holder, "%s.dll", fname);
} else {
dll_build_name(holder, holderlen, pname, fname);
}
}
< prev index next >