#include <windows.h>
#include <shlobj.h>
+#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
if (cbPath) {
cbPath += 2;
path = malloc(cbPath);
- }
- if (path) {
- GetEnvironmentVariable("AFSCONF", path, cbPath);
- tlen = (int)strlen(path);
- if (path[tlen-1] != '\\') {
- strncat(path, "\\", cbPath);
- path[cbPath-1] = '\0';
+ if (path) {
+ GetEnvironmentVariable("AFSCONF", path, cbPath);
+ tlen = (int)strlen(path);
+ if (path[tlen-1] != '\\') {
+ strncat(path, "\\", cbPath);
+ path[cbPath-1] = '\0';
+ }
+ *bufPP = path;
+ return 0;
}
- *bufPP = path;
- return 0;
}
if (!StringDataRead(AFSREG_CLT_OPENAFS_KEY,
&path)) {
tlen = (int)strlen(path);
if (path[tlen-1] != '\\') {
- strncat(path, "\\", cbPath);
- path[cbPath-1] = '\0';
+ char * newPath = malloc(tlen+2);
+ if (newPath) {
+ snprintf(newPath,tlen+2,"%s\\",path);
+ free(path);
+ path = newPath;
+ }
}
*bufPP = path;
return 0;
* Try to find the All Users\Application Data\OpenAFS\Client directory.
* If it exists and it contains a CellServDB file, return that.
* Otherwise, return the Install Directory for backward compatibility.
+ * SHGetFolderPath requires wdir to be of length MAX_PATH which is 260.
*/
if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_COMMON_APPDATA, NULL,
SHGFP_TYPE_CURRENT, wdir)))