aboutsummaryrefslogtreecommitdiffstats
path: root/g10/exec.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--g10/exec.c19
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]=='\\')
{