1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-08 17:43:04 +01:00

Some last minute tweaks - type fixes from Stefan and win32 temp files

from Timo.
This commit is contained in:
David Shaw 2001-12-22 15:22:59 +00:00
parent 184f9e5739
commit 2a53bb0e24
4 changed files with 40 additions and 11 deletions

View File

@ -1,3 +1,14 @@
2001-12-22 David Shaw <dshaw@jabberwocky.com>
* 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 <wk@gnupg.org> 2001-12-22 Werner Koch <wk@gnupg.org>
* encode.c (encode_simple, encode_crypt): i18n 2 strings. * encode.c (encode_simple, encode_crypt): i18n 2 strings.

View File

@ -56,6 +56,9 @@ static int make_tempdir(struct exec_info *info)
{ {
#ifdef __riscos__ #ifdef __riscos__
tmp="<Wimp$ScrapDir>"; tmp="<Wimp$ScrapDir>";
#elsif HAVE_DOSISH_SYSTEM
tmp=m_alloc(1024);
GetTempPath(1023,tmp);
#else #else
tmp="/tmp"; tmp="/tmp";
#endif #endif
@ -67,6 +70,10 @@ static int make_tempdir(struct exec_info *info)
sprintf(info->tempdir,"%s" DIRSEP_S "gpg-XXXXXX",tmp); sprintf(info->tempdir,"%s" DIRSEP_S "gpg-XXXXXX",tmp);
#ifdef HAVE_DOSISH_SYSTEM
m_free(tmp);
#endif
if(mkdtemp(info->tempdir)==NULL) if(mkdtemp(info->tempdir)==NULL)
log_error(_("%s: can't create directory: %s\n"), log_error(_("%s: can't create directory: %s\n"),
info->tempdir,strerror(errno)); 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. /* 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 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, int exec_write(struct exec_info **info,const char *program,
const char *args_in,int writeonly,int binary) const char *args_in,int writeonly,int binary)

View File

@ -13,14 +13,21 @@
char *mkdtemp(char *template) char *mkdtemp(char *template)
{ {
int attempts,index,count=0; int attempts,idx,count=0;
byte *ch; byte *ch;
index=strlen(template); idx=strlen(template);
ch=&template[index-1];
if(idx==0)
{
errno=EINVAL;
return NULL;
}
ch=&template[idx-1];
/* Walk backwards to count all the Xes */ /* Walk backwards to count all the Xes */
while(*ch=='X' && count<index) while(*ch=='X' && count<idx)
{ {
count++; count++;
ch--; ch--;
@ -37,10 +44,12 @@ char *mkdtemp(char *template)
/* Try 4 times to make the temp directory */ /* Try 4 times to make the temp directory */
for(attempts=0;attempts<4;attempts++) for(attempts=0;attempts<4;attempts++)
{ {
int index=0,remaining=count; int remaining=count;
char *marker=ch; char *marker=ch;
byte *randombits; byte *randombits;
idx=0;
/* Using really random bits is probably overkill here. The /* Using really random bits is probably overkill here. The
worst thing that can happen with a directory name collision worst thing that can happen with a directory name collision
is that the function will return an error. */ is that the function will return an error. */
@ -49,7 +58,7 @@ char *mkdtemp(char *template)
while(remaining>1) while(remaining>1)
{ {
sprintf(marker,"%02X",randombits[index++]); sprintf(marker,"%02X",randombits[idx++]);
marker+=2; marker+=2;
remaining-=2; remaining-=2;
} }
@ -57,7 +66,7 @@ char *mkdtemp(char *template)
/* Any leftover Xes? get_random_bits rounds up to full bytes, /* Any leftover Xes? get_random_bits rounds up to full bytes,
so this is safe. */ so this is safe. */
if(remaining>0) if(remaining>0)
sprintf(marker,"%X",randombits[index]&0xF); sprintf(marker,"%X",randombits[idx]&0xF);
m_free(randombits); m_free(randombits);

View File

@ -46,9 +46,10 @@
PKT_user_id *generate_photo_id(PKT_public_key *pk) PKT_user_id *generate_photo_id(PKT_public_key *pk)
{ {
PKT_user_id *uid; PKT_user_id *uid;
int error=1,i,len; int error=1,i;
unsigned int len;
char *filename=NULL; char *filename=NULL;
unsigned char *photo=NULL; byte *photo=NULL;
byte header[16]; byte header[16];
IOBUF file; IOBUF file;
@ -194,7 +195,8 @@ void show_photo(const struct user_attribute *attr,PKT_public_key *pk)
case 'f': /* fingerprint */ case 'f': /* fingerprint */
{ {
byte array[MAX_FINGERPRINT_LEN]; byte array[MAX_FINGERPRINT_LEN];
int len,i; size_t len;
int i;
fingerprint_from_pk(pk,array,&len); fingerprint_from_pk(pk,array,&len);