mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-03 22:56:33 +02:00
Replace most of the remaining stdio calls by estream calls.
--
We need to use es_fopen on Windows to cope with non-ascii file names.
This is quite a large but fortunately straightforward change. At a
very few places we keep using stdio (for example due to the use of
popen).
GnuPG-bug-id: 5098
Signed-off-by: Werner Koch <wk@gnupg.org>
Backported-from-master: 390497ea11
This commit is contained in:
parent
dd5fd4a760
commit
5c6e9b44cc
20 changed files with 208 additions and 197 deletions
|
@ -308,7 +308,7 @@ check_cert_policy (ksba_cert_t cert, int listmode, estream_t fplist)
|
|||
{
|
||||
gpg_error_t err;
|
||||
char *policies;
|
||||
FILE *fp;
|
||||
estream_t fp;
|
||||
int any_critical;
|
||||
|
||||
err = ksba_cert_get_cert_policies (cert, &policies);
|
||||
|
@ -340,7 +340,7 @@ check_cert_policy (ksba_cert_t cert, int listmode, estream_t fplist)
|
|||
return 0;
|
||||
}
|
||||
|
||||
fp = fopen (opt.policy_file, "r");
|
||||
fp = es_fopen (opt.policy_file, "r");
|
||||
if (!fp)
|
||||
{
|
||||
if (opt.verbose || errno != ENOENT)
|
||||
|
@ -369,14 +369,14 @@ check_cert_policy (ksba_cert_t cert, int listmode, estream_t fplist)
|
|||
/* read line */
|
||||
do
|
||||
{
|
||||
if (!fgets (line, DIM(line)-1, fp) )
|
||||
if (!es_fgets (line, DIM(line)-1, fp) )
|
||||
{
|
||||
gpg_error_t tmperr = gpg_error (gpg_err_code_from_errno (errno));
|
||||
gpg_error_t tmperr = gpg_error_from_syserror ();
|
||||
|
||||
xfree (policies);
|
||||
if (feof (fp))
|
||||
if (es_feof (fp))
|
||||
{
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
/* With no critical policies this is only a warning */
|
||||
if (!any_critical)
|
||||
{
|
||||
|
@ -388,16 +388,16 @@ check_cert_policy (ksba_cert_t cert, int listmode, estream_t fplist)
|
|||
_("certificate policy not allowed"));
|
||||
return gpg_error (GPG_ERR_NO_POLICY_MATCH);
|
||||
}
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
return tmperr;
|
||||
}
|
||||
|
||||
if (!*line || line[strlen(line)-1] != '\n')
|
||||
{
|
||||
/* eat until end of line */
|
||||
while ( (c=getc (fp)) != EOF && c != '\n')
|
||||
while ((c = es_getc (fp)) != EOF && c != '\n')
|
||||
;
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
xfree (policies);
|
||||
return gpg_error (*line? GPG_ERR_LINE_TOO_LONG
|
||||
: GPG_ERR_INCOMPLETE_LINE);
|
||||
|
@ -417,7 +417,7 @@ check_cert_policy (ksba_cert_t cert, int listmode, estream_t fplist)
|
|||
p = strpbrk (allowed, " :\n");
|
||||
if (!*p || p == allowed)
|
||||
{
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
xfree (policies);
|
||||
return gpg_error (GPG_ERR_CONFIGURATION);
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ check_cert_policy (ksba_cert_t cert, int listmode, estream_t fplist)
|
|||
if (p[strlen (allowed)] != ':')
|
||||
continue; /* The length does not match. */
|
||||
/* Yep - it does match so return okay. */
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
xfree (policies);
|
||||
return 0;
|
||||
}
|
||||
|
|
16
sm/keydb.c
16
sm/keydb.c
|
@ -115,7 +115,7 @@ maybe_create_keybox (char *filename, int force, int *r_created)
|
|||
{
|
||||
gpg_err_code_t ec;
|
||||
dotlock_t lockhd = NULL;
|
||||
FILE *fp;
|
||||
estream_t fp;
|
||||
int rc;
|
||||
mode_t oldmask;
|
||||
char *last_slash_in_filename;
|
||||
|
@ -206,7 +206,7 @@ maybe_create_keybox (char *filename, int force, int *r_created)
|
|||
|
||||
/* The file does not yet exist, create it now. */
|
||||
oldmask = umask (077);
|
||||
fp = fopen (filename, "wb");
|
||||
fp = es_fopen (filename, "wb");
|
||||
if (!fp)
|
||||
{
|
||||
rc = gpg_error_from_syserror ();
|
||||
|
@ -223,7 +223,7 @@ maybe_create_keybox (char *filename, int force, int *r_created)
|
|||
rc = _keybox_write_header_blob (fp, 0);
|
||||
if (rc)
|
||||
{
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
log_error (_("error creating keybox '%s': %s\n"),
|
||||
filename, gpg_strerror (rc));
|
||||
goto leave;
|
||||
|
@ -234,7 +234,7 @@ maybe_create_keybox (char *filename, int force, int *r_created)
|
|||
if (r_created)
|
||||
*r_created = 1;
|
||||
|
||||
fclose (fp);
|
||||
es_fclose (fp);
|
||||
rc = 0;
|
||||
|
||||
leave:
|
||||
|
@ -301,14 +301,15 @@ keydb_add_resource (ctrl_t ctrl, const char *url, int force, int *auto_created)
|
|||
/* see whether we can determine the filetype */
|
||||
if (rt == KEYDB_RESOURCE_TYPE_NONE)
|
||||
{
|
||||
FILE *fp = fopen( filename, "rb" );
|
||||
estream_t fp;
|
||||
|
||||
fp = es_fopen( filename, "rb" );
|
||||
if (fp)
|
||||
{
|
||||
u32 magic;
|
||||
|
||||
/* FIXME: check for the keybox magic */
|
||||
if (fread (&magic, 4, 1, fp) == 1 )
|
||||
if (es_fread (&magic, 4, 1, fp) == 1 )
|
||||
{
|
||||
if (magic == 0x13579ace || magic == 0xce9a5713)
|
||||
; /* GDBM magic - no more support */
|
||||
|
@ -317,7 +318,8 @@ keydb_add_resource (ctrl_t ctrl, const char *url, int force, int *auto_created)
|
|||
}
|
||||
else /* maybe empty: assume keybox */
|
||||
rt = KEYDB_RESOURCE_TYPE_KEYBOX;
|
||||
fclose (fp);
|
||||
|
||||
es_fclose (fp);
|
||||
}
|
||||
else /* no file yet: create keybox */
|
||||
rt = KEYDB_RESOURCE_TYPE_KEYBOX;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
NULL indicates that this module has been initialized and if the
|
||||
LISTFP is also NULL, no list of qualified signatures exists. */
|
||||
static char *listname;
|
||||
static FILE *listfp;
|
||||
static estream_t listfp;
|
||||
|
||||
|
||||
/* Read the trustlist and return entry by entry. KEY must point to a
|
||||
|
@ -59,7 +59,7 @@ read_list (char *key, char *country, int *lnr)
|
|||
if (!listname)
|
||||
{
|
||||
listname = make_filename (gnupg_datadir (), "qualified.txt", NULL);
|
||||
listfp = fopen (listname, "r");
|
||||
listfp = es_fopen (listname, "r");
|
||||
if (!listfp && errno != ENOENT)
|
||||
{
|
||||
err = gpg_error_from_syserror ();
|
||||
|
@ -73,9 +73,9 @@ read_list (char *key, char *country, int *lnr)
|
|||
|
||||
do
|
||||
{
|
||||
if (!fgets (line, DIM(line)-1, listfp) )
|
||||
if (!es_fgets (line, DIM(line)-1, listfp) )
|
||||
{
|
||||
if (feof (listfp))
|
||||
if (es_feof (listfp))
|
||||
return gpg_error (GPG_ERR_EOF);
|
||||
return gpg_error_from_syserror ();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ read_list (char *key, char *country, int *lnr)
|
|||
if (!*line || line[strlen(line)-1] != '\n')
|
||||
{
|
||||
/* Eat until end of line. */
|
||||
while ( (c=getc (listfp)) != EOF && c != '\n')
|
||||
while ((c = es_getc (listfp)) != EOF && c != '\n')
|
||||
;
|
||||
return gpg_error (*line? GPG_ERR_LINE_TOO_LONG
|
||||
: GPG_ERR_INCOMPLETE_LINE);
|
||||
|
@ -163,8 +163,8 @@ gpgsm_is_in_qualified_list (ctrl_t ctrl, ksba_cert_t cert, char *country)
|
|||
if (listfp)
|
||||
{
|
||||
/* W32ce has no rewind, thus we use the equivalent code. */
|
||||
fseek (listfp, 0, SEEK_SET);
|
||||
clearerr (listfp);
|
||||
es_fseek (listfp, 0, SEEK_SET);
|
||||
es_clearerr (listfp);
|
||||
}
|
||||
while (!(err = read_list (key, mycountry, &lnr)))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue