comparison src/os/windows/vm/os_windows.cpp @ 6966:6cb0d32b828b

8001185: parsing of sun.boot.library.path in os::dll_build_name somewhat broken Summary: dll_dir can contain multiple paths, need to parse them correctly when loading agents Reviewed-by: dholmes, dlong Contributed-by: bill.pittore@oracle.com
author bpittore
date Wed, 07 Nov 2012 17:53:02 -0500
parents 5ec0c42da025
children 2cb439954abf f34d701e952e cd3d6a6b95d9
comparison
equal deleted inserted replaced
6932:857f3ce858dd 6966:6cb0d32b828b
1130 return false; 1130 return false;
1131 } 1131 }
1132 return GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES; 1132 return GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES;
1133 } 1133 }
1134 1134
1135 void os::dll_build_name(char *buffer, size_t buflen, 1135 bool os::dll_build_name(char *buffer, size_t buflen,
1136 const char* pname, const char* fname) { 1136 const char* pname, const char* fname) {
1137 bool retval = false;
1137 const size_t pnamelen = pname ? strlen(pname) : 0; 1138 const size_t pnamelen = pname ? strlen(pname) : 0;
1138 const char c = (pnamelen > 0) ? pname[pnamelen-1] : 0; 1139 const char c = (pnamelen > 0) ? pname[pnamelen-1] : 0;
1139 1140
1140 // Quietly truncates on buffer overflow. Should be an error. 1141 // Return error on buffer overflow.
1141 if (pnamelen + strlen(fname) + 10 > buflen) { 1142 if (pnamelen + strlen(fname) + 10 > buflen) {
1142 *buffer = '\0'; 1143 return retval;
1143 return;
1144 } 1144 }
1145 1145
1146 if (pnamelen == 0) { 1146 if (pnamelen == 0) {
1147 jio_snprintf(buffer, buflen, "%s.dll", fname); 1147 jio_snprintf(buffer, buflen, "%s.dll", fname);
1148 retval = true;
1148 } else if (c == ':' || c == '\\') { 1149 } else if (c == ':' || c == '\\') {
1149 jio_snprintf(buffer, buflen, "%s%s.dll", pname, fname); 1150 jio_snprintf(buffer, buflen, "%s%s.dll", pname, fname);
1151 retval = true;
1150 } else if (strchr(pname, *os::path_separator()) != NULL) { 1152 } else if (strchr(pname, *os::path_separator()) != NULL) {
1151 int n; 1153 int n;
1152 char** pelements = split_path(pname, &n); 1154 char** pelements = split_path(pname, &n);
1153 for (int i = 0 ; i < n ; i++) { 1155 for (int i = 0 ; i < n ; i++) {
1154 char* path = pelements[i]; 1156 char* path = pelements[i];
1162 jio_snprintf(buffer, buflen, "%s%s.dll", path, fname); 1164 jio_snprintf(buffer, buflen, "%s%s.dll", path, fname);
1163 } else { 1165 } else {
1164 jio_snprintf(buffer, buflen, "%s\\%s.dll", path, fname); 1166 jio_snprintf(buffer, buflen, "%s\\%s.dll", path, fname);
1165 } 1167 }
1166 if (file_exists(buffer)) { 1168 if (file_exists(buffer)) {
1169 retval = true;
1167 break; 1170 break;
1168 } 1171 }
1169 } 1172 }
1170 // release the storage 1173 // release the storage
1171 for (int i = 0 ; i < n ; i++) { 1174 for (int i = 0 ; i < n ; i++) {
1176 if (pelements != NULL) { 1179 if (pelements != NULL) {
1177 FREE_C_HEAP_ARRAY(char*, pelements, mtInternal); 1180 FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
1178 } 1181 }
1179 } else { 1182 } else {
1180 jio_snprintf(buffer, buflen, "%s\\%s.dll", pname, fname); 1183 jio_snprintf(buffer, buflen, "%s\\%s.dll", pname, fname);
1181 } 1184 retval = true;
1185 }
1186 return retval;
1182 } 1187 }
1183 1188
1184 // Needs to be in os specific directory because windows requires another 1189 // Needs to be in os specific directory because windows requires another
1185 // header file <direct.h> 1190 // header file <direct.h>
1186 const char* os::get_current_directory(char *buf, int buflen) { 1191 const char* os::get_current_directory(char *buf, int buflen) {