diff options
author | David Shaw <[email protected]> | 2001-12-22 15:22:59 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2001-12-22 15:22:59 +0000 |
commit | 2a53bb0e24c81e7d9bc914da0f6c144ddb9bfca8 (patch) | |
tree | 014339ee7c1d6e03ef6d0775ef0f01244d03d30b | |
parent | bumbed version (diff) | |
download | gnupg-2a53bb0e24c81e7d9bc914da0f6c144ddb9bfca8.tar.gz gnupg-2a53bb0e24c81e7d9bc914da0f6c144ddb9bfca8.zip |
Some last minute tweaks - type fixes from Stefan and win32 temp files
from Timo.
-rw-r--r-- | g10/ChangeLog | 11 | ||||
-rw-r--r-- | g10/exec.c | 9 | ||||
-rw-r--r-- | g10/mkdtemp.c | 23 | ||||
-rw-r--r-- | g10/photoid.c | 8 |
4 files changed, 40 insertions, 11 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index 890ad3731..2691716e3 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,14 @@ +2001-12-22 David Shaw <[email protected]> + + * mkdtemp.c (mkdtemp): catch the empty ("") string case in case + someone repurposes mkdtemp at some point. + + * photoid.c (generate_photo_id, show_photo): some type changes + from Stefan Bellon. + + * exec.c (make_tempdir): handle Win32 systems, suggested by Timo + Schulz. + 2001-12-22 Werner Koch <[email protected]> * encode.c (encode_simple, encode_crypt): i18n 2 strings. diff --git a/g10/exec.c b/g10/exec.c index 1685cb6cb..652ed456e 100644 --- a/g10/exec.c +++ b/g10/exec.c @@ -56,6 +56,9 @@ static int make_tempdir(struct exec_info *info) { #ifdef __riscos__ tmp="<Wimp$ScrapDir>"; +#elsif HAVE_DOSISH_SYSTEM + tmp=m_alloc(1024); + GetTempPath(1023,tmp); #else tmp="/tmp"; #endif @@ -67,6 +70,10 @@ static int make_tempdir(struct exec_info *info) sprintf(info->tempdir,"%s" DIRSEP_S "gpg-XXXXXX",tmp); +#ifdef HAVE_DOSISH_SYSTEM + m_free(tmp); +#endif + if(mkdtemp(info->tempdir)==NULL) log_error(_("%s: can't create directory: %s\n"), info->tempdir,strerror(errno)); @@ -189,7 +196,7 @@ static int expand_args(struct exec_info *info,const char *args_in) /* The rules are: if there are no args, then it's a fork/exec/pipe. If there are args, but no tempfiles, then it's a fork/exec/pipe via - bash -c. If there are tempfiles, then it's a system. */ + shell -c. If there are tempfiles, then it's a system. */ int exec_write(struct exec_info **info,const char *program, const char *args_in,int writeonly,int binary) diff --git a/g10/mkdtemp.c b/g10/mkdtemp.c index 6a159c02b..625ab148f 100644 --- a/g10/mkdtemp.c +++ b/g10/mkdtemp.c @@ -13,14 +13,21 @@ char *mkdtemp(char *template) { - int attempts,index,count=0; + int attempts,idx,count=0; byte *ch; - index=strlen(template); - ch=&template[index-1]; + idx=strlen(template); + + if(idx==0) + { + errno=EINVAL; + return NULL; + } + + ch=&template[idx-1]; /* Walk backwards to count all the Xes */ - while(*ch=='X' && count<index) + while(*ch=='X' && count<idx) { count++; ch--; @@ -37,10 +44,12 @@ char *mkdtemp(char *template) /* Try 4 times to make the temp directory */ for(attempts=0;attempts<4;attempts++) { - int index=0,remaining=count; + int remaining=count; char *marker=ch; byte *randombits; + idx=0; + /* Using really random bits is probably overkill here. The worst thing that can happen with a directory name collision is that the function will return an error. */ @@ -49,7 +58,7 @@ char *mkdtemp(char *template) while(remaining>1) { - sprintf(marker,"%02X",randombits[index++]); + sprintf(marker,"%02X",randombits[idx++]); marker+=2; remaining-=2; } @@ -57,7 +66,7 @@ char *mkdtemp(char *template) /* Any leftover Xes? get_random_bits rounds up to full bytes, so this is safe. */ if(remaining>0) - sprintf(marker,"%X",randombits[index]&0xF); + sprintf(marker,"%X",randombits[idx]&0xF); m_free(randombits); diff --git a/g10/photoid.c b/g10/photoid.c index 4cc96de61..bf67c2a66 100644 --- a/g10/photoid.c +++ b/g10/photoid.c @@ -46,9 +46,10 @@ PKT_user_id *generate_photo_id(PKT_public_key *pk) { PKT_user_id *uid; - int error=1,i,len; + int error=1,i; + unsigned int len; char *filename=NULL; - unsigned char *photo=NULL; + byte *photo=NULL; byte header[16]; IOBUF file; @@ -194,7 +195,8 @@ void show_photo(const struct user_attribute *attr,PKT_public_key *pk) case 'f': /* fingerprint */ { byte array[MAX_FINGERPRINT_LEN]; - int len,i; + size_t len; + int i; fingerprint_from_pk(pk,array,&len); |