diff options
author | David Shaw <[email protected]> | 2006-05-27 01:38:54 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2006-05-27 01:38:54 +0000 |
commit | b9c2f44336a4693e7ebb9afe011e7ff4c291ba6e (patch) | |
tree | 727cd2c55c626feda4a9162d0dcf4e4c02eca52d /g10/exec.c | |
parent | * keygen.c (gen_dsa): Allow generating DSA2 keys (allow specifying sizes > (diff) | |
download | gnupg-b9c2f44336a4693e7ebb9afe011e7ff4c291ba6e.tar.gz gnupg-b9c2f44336a4693e7ebb9afe011e7ff4c291ba6e.zip |
* exec.c (make_tempdir) [_WIN32]: Modified to properly handle
arbitrarily long temporary directory paths.
Diffstat (limited to 'g10/exec.c')
-rw-r--r-- | g10/exec.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/g10/exec.c b/g10/exec.c index 924349d25..2ad0d327c 100644 --- a/g10/exec.c +++ b/g10/exec.c @@ -129,16 +129,21 @@ static int make_tempdir(struct exec_info *info) if(tmp==NULL) { #if defined (_WIN32) - int err; + int tmp_siz; + int len=0; - tmp=xmalloc(MAX_PATH+1); - err=GetTempPath(MAX_PATH+1,tmp); - if(err==0 || err>MAX_PATH+1) - strcpy(tmp,"c:\\windows\\temp"); - else + /* Poll temp path length */ + tmp_siz=GetTempPath(0,NULL); + if(tmp_siz) { - int len=strlen(tmp); + tmp=xmalloc(tmp_siz); + len=GetTempPath(tmp_siz,tmp); + } + if(len==0) + tmp=xstrdup("c:\\windows\\temp"); + else + { /* GetTempPath may return with \ on the end */ while(len>0 && tmp[len-1]=='\\') { |