1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Nuked almost all trailing white space.

We better do this once and for all instead of cluttering all future
commits with diffs of trailing white spaces.  In the majority of cases
blank or single lines are affected and thus this change won't disturb
a git blame too much.  For future commits the pre-commit scripts
checks that this won't happen again.
This commit is contained in:
Werner Koch 2011-02-04 12:57:53 +01:00
parent ffd099eb19
commit b008274afd
305 changed files with 5385 additions and 5592 deletions

View File

@ -28,7 +28,7 @@ Daiki Ueno <ueno@unixuser.org> Assigns Past and Future Changes.
David Shaw <dshaw@jabberwocky.com> Assigns past and future changes. David Shaw <dshaw@jabberwocky.com> Assigns past and future changes.
(all in keyserver/, (all in keyserver/,
a lot of changes in g10/ see the ChangeLog, a lot of changes in g10/ see the ChangeLog,
bug fixes here and there) bug fixes here and there)
Dokianakis Theofanis <madf@hellug.gr> Translations [el] Dokianakis Theofanis <madf@hellug.gr> Translations [el]
@ -76,7 +76,7 @@ Marcus Brinkmann <marcus@g10code.de>
Matthew Skala <mskala@ansuz.sooke.bc.ca> Disclaimer Matthew Skala <mskala@ansuz.sooke.bc.ca> Disclaimer
(wrote cipher/twofish.c) (wrote cipher/twofish.c)
Moritz Schulte <moritz@g10code.com> Moritz Schulte <moritz@g10code.com>
(ssh support gpg-agent) (ssh support gpg-agent)
Niklas Hernaeus <nh@df.lth.se> Disclaimer Niklas Hernaeus <nh@df.lth.se> Disclaimer
@ -84,11 +84,11 @@ Niklas Hernaeus <nh@df.lth.se> Disclaimer
Nilgun Belma Buguner <nilgun@technologist.com> Translations [tr] Nilgun Belma Buguner <nilgun@technologist.com> Translations [tr]
Nils Ellmenreich <nils 'at' infosun.fmi.uni-passau.de> Nils Ellmenreich <nils 'at' infosun.fmi.uni-passau.de>
Assigns past and future changes Assigns past and future changes
(configure.in, cipher/rndlinux.c, FAQ) (configure.in, cipher/rndlinux.c, FAQ)
Paul Eggert <eggert@twinsun.com> Paul Eggert <eggert@twinsun.com>
(configuration macros for LFS) (configuration macros for LFS)
Pavel I. Shajdo <pshajdo@gmail.com> Translations [ru] Pavel I. Shajdo <pshajdo@gmail.com> Translations [ru]

View File

@ -1,18 +1,18 @@
# Makefile.am - main makefile for GnuPG # Makefile.am - main makefile for GnuPG
# Copyright (C) 2001, 2004, 2010 Free Software Foundation, Inc. # Copyright (C) 2001, 2004, 2010 Free Software Foundation, Inc.
# #
# This file is part of GnuPG. # This file is part of GnuPG.
# #
# GnuPG is free software; you can redistribute it and/or modify # GnuPG is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or # the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# GnuPG is distributed in the hope that it will be useful, # GnuPG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
@ -23,7 +23,7 @@ AUTOMAKE_OPTIONS = dist-bzip2 no-dist-gzip
DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun --enable-mailto DISTCHECK_CONFIGURE_FLAGS = --enable-symcryptrun --enable-mailto
EXTRA_DIST = scripts/config.rpath scripts/potomo autogen.sh README.GIT EXTRA_DIST = scripts/config.rpath scripts/potomo autogen.sh README.GIT
DISTCLEANFILES = g10defs.h DISTCLEANFILES = g10defs.h
if BUILD_GPGSM if BUILD_GPGSM
kbx = kbx kbx = kbx
@ -35,11 +35,11 @@ endif
if BUILD_GPG if BUILD_GPG
gpg = g10 gpg = g10
if !HAVE_W32CE_SYSTEM if !HAVE_W32CE_SYSTEM
keyserver = keyserver =
endif endif
else else
gpg = gpg =
keyserver = keyserver =
endif endif
if BUILD_GPGSM if BUILD_GPGSM
sm = sm sm = sm
@ -106,6 +106,5 @@ install-data-hook:
done done
endif endif
stowinstall: stowinstall:
$(MAKE) $(AM_MAKEFLAGS) install prefix=/usr/local/stow/gnupg $(MAKE) $(AM_MAKEFLAGS) install prefix=/usr/local/stow/gnupg

View File

@ -16,7 +16,7 @@ tools, or the tools are not installed, you may use environment
variables to override the default tool names: variables to override the default tool names:
AUTOMAKE_SUFFIX is used as a suffix for all tools from the automake AUTOMAKE_SUFFIX is used as a suffix for all tools from the automake
package. For example package. For example
AUTOMAKE_SUFFIX="-1.7" ./autogen.sh AUTOMAKE_SUFFIX="-1.7" ./autogen.sh
uses "automake-1.7" and "aclocal-1.7. uses "automake-1.7" and "aclocal-1.7.
AUTOMAKE_PREFIX is used as a prefix for all tools from the automake AUTOMAKE_PREFIX is used as a prefix for all tools from the automake
@ -47,5 +47,3 @@ if the maintainer decides that newer versions are required. The
maintainer should also make sure that the required version of automake maintainer should also make sure that the required version of automake
et al. are properly indicated at the top of configure.ac and take care et al. are properly indicated at the top of configure.ac and take care
to copy the files and not merely use symlinks. to copy the files and not merely use symlinks.

View File

@ -19,7 +19,7 @@ Release process:
================ ================
* Make sure that all new PO files are checked in. * Make sure that all new PO files are checked in.
* Decide whether you want to update the automake standard files * Decide whether you want to update the automake standard files
(Mainly config.guess and config.sub). (Mainly config.guess and config.sub).
* [1.4 only] Update gpg.texi and gpgv.texi from the trunk: * [1.4 only] Update gpg.texi and gpgv.texi from the trunk:
make -C doc update-source-from-gnupg-2 make -C doc update-source-from-gnupg-2
@ -38,14 +38,14 @@ Release process:
* Build and test the W32 version. * Build and test the W32 version.
* [2.x only] Using the final test build run a "make -C doc online". * [2.x only] Using the final test build run a "make -C doc online".
* Sign the tarball * Sign the tarball
* Get the previous tarball and run "mkdiff gnupg". * Get the previous tarball and run "mkdiff gnupg".
You might need to set a different signature key than mine. mkdiff You might need to set a different signature key than mine. mkdiff
has an option for this. has an option for this.
* If you are satisfied with the result commit a tag for the release. * If you are satisfied with the result commit a tag for the release.
* Copy the files to the FTP server * Copy the files to the FTP server
* Update the webpages - at least the file swdb.wml needs an update. * Update the webpages - at least the file swdb.wml needs an update.
* Add a new headline to NEWS. * Add a new headline to NEWS.
* Bump "my_version" up and set "my_issvn" back to "yes" in configure.ac * Bump "my_version" up and set "my_issvn" back to "yes" in configure.ac
* Write an announcement. Update https://savannah.gnu.org/projects/gnupg . * Write an announcement. Update https://savannah.gnu.org/projects/gnupg .
@ -61,7 +61,3 @@ Gotchas
from running make) you end up with different comments in the po from running make) you end up with different comments in the po
files. Check out /usr/lib/gettext/project-id for that silliness. files. Check out /usr/lib/gettext/project-id for that silliness.
As a hack we added this string into configure.ac. As a hack we added this string into configure.ac.

8
THANKS
View File

@ -109,7 +109,7 @@ Ian McKellar imckellar at harvestroad.com.au
Ingo Klöcker kloecker at kde.org Ingo Klöcker kloecker at kde.org
Ivo Timmermans itimmermans at bigfoot.com Ivo Timmermans itimmermans at bigfoot.com
Jan Krueger max at physics.otago.ac.nz Jan Krueger max at physics.otago.ac.nz
Jan Niehusmann jan at gondor.com Jan Niehusmann jan at gondor.com
Jan-0liver Wagner jan @ intevation.de Jan-0liver Wagner jan @ intevation.de
Janusz A. Urbanowicz alex at bofh.torun.pl Janusz A. Urbanowicz alex at bofh.torun.pl
James Troup james at nocrew.org James Troup james at nocrew.org
@ -141,7 +141,7 @@ Karl Fogel kfogel at guanabana.onshore.com
Karsten Thygesen karthy at kom.auc.dk Karsten Thygesen karthy at kom.auc.dk
Katsuhiro Kondou kondou at nec.co.jp Katsuhiro Kondou kondou at nec.co.jp
Kazu Yamamoto kazu at iij.ad.jp Kazu Yamamoto kazu at iij.ad.jp
Kazuyoshi Kakihara Kazuyoshi Kakihara
Keith Clayton keith at claytons.org Keith Clayton keith at claytons.org
Ken Takusagawa ken.takusagawa.2 at gmail.com Ken Takusagawa ken.takusagawa.2 at gmail.com
Kevin Ryde user42 at zip.com.au Kevin Ryde user42 at zip.com.au
@ -151,11 +151,11 @@ Klaus Singvogel ks at caldera.de
Kurt Garloff garloff at suse.de Kurt Garloff garloff at suse.de
Lars Kellogg-Stedman lars at bu.edu Lars Kellogg-Stedman lars at bu.edu
L. Sassaman rabbi at quickie.net L. Sassaman rabbi at quickie.net
M Taylor mctaylor at privacy.nb.ca M Taylor mctaylor at privacy.nb.ca
Marcel Waldvogel mwa at arl.wustl.edu Marcel Waldvogel mwa at arl.wustl.edu
Marco d'Itri md at linux.it Marco d'Itri md at linux.it
Marco Parrone marc0 at autistici.org Marco Parrone marc0 at autistici.org
Marcus Brinkmann Marcus.Brinkmann at ruhr-uni-bochum.de Marcus Brinkmann Marcus.Brinkmann at ruhr-uni-bochum.de
Mark Adler madler at alumni.caltech.edu Mark Adler madler at alumni.caltech.edu
Mark Elbrecht snowball3 at bigfoot.com Mark Elbrecht snowball3 at bigfoot.com
Mark Pettit pettit at yahoo-inc.com Mark Pettit pettit at yahoo-inc.com

View File

@ -6,12 +6,12 @@
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or # the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# GnuPG is distributed in the hope that it will be useful, # GnuPG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
@ -53,7 +53,7 @@ gpg_agent_SOURCES = \
common_libs = $(libcommon) ../gl/libgnu.a common_libs = $(libcommon) ../gl/libgnu.a
commonpth_libs = $(libcommonpth) ../gl/libgnu.a commonpth_libs = $(libcommonpth) ../gl/libgnu.a
if HAVE_W32CE_SYSTEM if HAVE_W32CE_SYSTEM
pwquery_libs = pwquery_libs =
else else
pwquery_libs = ../common/libsimple-pwquery.a pwquery_libs = ../common/libsimple-pwquery.a
endif endif
@ -109,9 +109,5 @@ TESTS = t-protect
t_common_ldadd = $(common_libs) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \ t_common_ldadd = $(common_libs) $(LIBGCRYPT_LIBS) $(GPG_ERROR_LIBS) \
$(LIBINTL) $(LIBICONV) $(NETLIBS) $(LIBINTL) $(LIBICONV) $(NETLIBS)
t_protect_SOURCES = t-protect.c protect.c t_protect_SOURCES = t-protect.c protect.c
t_protect_LDADD = $(t_common_ldadd) t_protect_LDADD = $(t_common_ldadd)

View File

@ -118,7 +118,7 @@ struct
#define DBG_CACHE_VALUE 64 /* debug the caching */ #define DBG_CACHE_VALUE 64 /* debug the caching */
#define DBG_MEMSTAT_VALUE 128 /* show memory statistics */ #define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
#define DBG_HASHING_VALUE 512 /* debug hashing operations */ #define DBG_HASHING_VALUE 512 /* debug hashing operations */
#define DBG_ASSUAN_VALUE 1024 #define DBG_ASSUAN_VALUE 1024
#define DBG_COMMAND (opt.debug & DBG_COMMAND_VALUE) #define DBG_COMMAND (opt.debug & DBG_COMMAND_VALUE)
#define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE) #define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
@ -131,14 +131,14 @@ struct server_local_s;
struct scd_local_s; struct scd_local_s;
/* Collection of data per session (aka connection). */ /* Collection of data per session (aka connection). */
struct server_control_s struct server_control_s
{ {
/* Private data used to fire up the connection thread. We use this /* Private data used to fire up the connection thread. We use this
structure do avoid an extra allocation for just a few bytes. */ structure do avoid an extra allocation for just a few bytes. */
struct { struct {
gnupg_fd_t fd; gnupg_fd_t fd;
} thread_startup; } thread_startup;
/* Private data of the server (command.c). */ /* Private data of the server (command.c). */
struct server_local_s *server_local; struct server_local_s *server_local;
@ -165,7 +165,7 @@ struct server_control_s
}; };
struct pin_entry_info_s struct pin_entry_info_s
{ {
int min_digits; /* min. number of digits required or 0 for freeform entry */ int min_digits; /* min. number of digits required or 0 for freeform entry */
int max_digits; /* max. number of allowed digits allowed*/ int max_digits; /* max. number of allowed digits allowed*/
@ -180,7 +180,7 @@ struct pin_entry_info_s
}; };
enum enum
{ {
PRIVATE_KEY_UNKNOWN = 0, PRIVATE_KEY_UNKNOWN = 0,
PRIVATE_KEY_CLEAR = 1, PRIVATE_KEY_CLEAR = 1,
@ -191,7 +191,7 @@ enum
/* Values for the cache_mode arguments. */ /* Values for the cache_mode arguments. */
typedef enum typedef enum
{ {
CACHE_MODE_IGNORE = 0, /* Special mode to bypass the cache. */ CACHE_MODE_IGNORE = 0, /* Special mode to bypass the cache. */
CACHE_MODE_ANY, /* Any mode except ignore matches. */ CACHE_MODE_ANY, /* Any mode except ignore matches. */
@ -231,7 +231,7 @@ void start_command_handler_ssh (ctrl_t, gnupg_fd_t);
/*-- findkey.c --*/ /*-- findkey.c --*/
int agent_write_private_key (const unsigned char *grip, int agent_write_private_key (const unsigned char *grip,
const void *buffer, size_t length, int force); const void *buffer, size_t length, int force);
gpg_error_t agent_key_from_file (ctrl_t ctrl, gpg_error_t agent_key_from_file (ctrl_t ctrl,
const char *cache_nonce, const char *cache_nonce,
const char *desc_text, const char *desc_text,
const unsigned char *grip, const unsigned char *grip,
@ -240,7 +240,7 @@ gpg_error_t agent_key_from_file (ctrl_t ctrl,
lookup_ttl_t lookup_ttl, lookup_ttl_t lookup_ttl,
gcry_sexp_t *result, gcry_sexp_t *result,
char **r_passphrase); char **r_passphrase);
gpg_error_t agent_public_key_from_file (ctrl_t ctrl, gpg_error_t agent_public_key_from_file (ctrl_t ctrl,
const unsigned char *grip, const unsigned char *grip,
gcry_sexp_t *result); gcry_sexp_t *result);
int agent_is_dsa_key (gcry_sexp_t s_key); int agent_is_dsa_key (gcry_sexp_t s_key);
@ -307,7 +307,7 @@ unsigned long get_standard_s2k_count (void);
int agent_protect (const unsigned char *plainkey, const char *passphrase, int agent_protect (const unsigned char *plainkey, const char *passphrase,
unsigned char **result, size_t *resultlen); unsigned char **result, size_t *resultlen);
int agent_unprotect (const unsigned char *protectedkey, const char *passphrase, int agent_unprotect (const unsigned char *protectedkey, const char *passphrase,
gnupg_isotime_t protected_at, gnupg_isotime_t protected_at,
unsigned char **result, size_t *resultlen); unsigned char **result, size_t *resultlen);
int agent_private_key_type (const unsigned char *privatekey); int agent_private_key_type (const unsigned char *privatekey);
unsigned char *make_shadow_info (const char *serialno, const char *idstring); unsigned char *make_shadow_info (const char *serialno, const char *idstring);
@ -316,7 +316,7 @@ int agent_shadow_key (const unsigned char *pubkey,
unsigned char **result); unsigned char **result);
int agent_get_shadow_info (const unsigned char *shadowkey, int agent_get_shadow_info (const unsigned char *shadowkey,
unsigned char const **shadow_info); unsigned char const **shadow_info);
gpg_error_t parse_shadow_info (const unsigned char *shadow_info, gpg_error_t parse_shadow_info (const unsigned char *shadow_info,
char **r_hexsn, char **r_idstr); char **r_hexsn, char **r_idstr);
gpg_error_t s2k_hash_passphrase (const char *passphrase, int hashalgo, gpg_error_t s2k_hash_passphrase (const char *passphrase, int hashalgo,
int s2kmode, int s2kmode,
@ -335,7 +335,7 @@ void agent_reload_trustlist (void);
/*-- divert-scd.c --*/ /*-- divert-scd.c --*/
int divert_pksign (ctrl_t ctrl, int divert_pksign (ctrl_t ctrl,
const unsigned char *digest, size_t digestlen, int algo, const unsigned char *digest, size_t digestlen, int algo,
const unsigned char *shadow_info, unsigned char **r_sig); const unsigned char *shadow_info, unsigned char **r_sig);
int divert_pkdecrypt (ctrl_t ctrl, int divert_pkdecrypt (ctrl_t ctrl,

View File

@ -126,7 +126,7 @@ init_encryption (void)
if (err) if (err)
log_error ("error initializing cache encryption context: %s\n", log_error ("error initializing cache encryption context: %s\n",
gpg_strerror (err)); gpg_strerror (err));
if (!pth_mutex_release (&encryption_lock)) if (!pth_mutex_release (&encryption_lock))
log_fatal ("failed to release cache encryption mutex\n"); log_fatal ("failed to release cache encryption mutex\n");
@ -148,7 +148,7 @@ new_data (const char *string, struct secret_data_s **r_data)
struct secret_data_s *d, *d_enc; struct secret_data_s *d, *d_enc;
size_t length; size_t length;
int total; int total;
*r_data = NULL; *r_data = NULL;
err = init_encryption (); err = init_encryption ();
@ -222,7 +222,7 @@ housekeeping (void)
for (r=thecache; r; r = r->next) for (r=thecache; r; r = r->next)
{ {
unsigned long maxttl; unsigned long maxttl;
switch (r->cache_mode) switch (r->cache_mode)
{ {
case CACHE_MODE_SSH: maxttl = opt.max_cache_ttl_ssh; break; case CACHE_MODE_SSH: maxttl = opt.max_cache_ttl_ssh; break;
@ -334,7 +334,7 @@ agent_put_cache (const char *key, cache_mode_t cache_mode,
} }
if (data) if (data)
{ {
r->created = r->accessed = gnupg_get_time (); r->created = r->accessed = gnupg_get_time ();
r->ttl = ttl; r->ttl = ttl;
r->cache_mode = cache_mode; r->cache_mode = cache_mode;
err = new_data (data, &r->pw); err = new_data (data, &r->pw);
@ -350,7 +350,7 @@ agent_put_cache (const char *key, cache_mode_t cache_mode,
else else
{ {
strcpy (r->key, key); strcpy (r->key, key);
r->created = r->accessed = gnupg_get_time (); r->created = r->accessed = gnupg_get_time ();
r->ttl = ttl; r->ttl = ttl;
r->cache_mode = cache_mode; r->cache_mode = cache_mode;
err = new_data (data, &r->pw); err = new_data (data, &r->pw);
@ -428,4 +428,3 @@ agent_get_cache (const char *key, cache_mode_t cache_mode)
return NULL; return NULL;
} }

View File

@ -147,7 +147,7 @@ agent_reset_query (ctrl_t ctrl)
disconnect that pinentry - we do this after the unlock so that a disconnect that pinentry - we do this after the unlock so that a
stalled pinentry does not block other threads. Fixme: We should stalled pinentry does not block other threads. Fixme: We should
have a timeout in Assuan for the disconnect operation. */ have a timeout in Assuan for the disconnect operation. */
static int static int
unlock_pinentry (int rc) unlock_pinentry (int rc)
{ {
assuan_context_t ctx = entry_ctx; assuan_context_t ctx = entry_ctx;
@ -175,7 +175,7 @@ atfork_cb (void *opaque, int where)
{ {
int iterator = 0; int iterator = 0;
const char *name, *assname, *value; const char *name, *assname, *value;
gcry_control (GCRYCTL_TERM_SECMEM); gcry_control (GCRYCTL_TERM_SECMEM);
while ((name = session_env_list_stdenvnames (&iterator, &assname))) while ((name = session_env_list_stdenvnames (&iterator, &assname)))
@ -184,7 +184,7 @@ atfork_cb (void *opaque, int where)
ones which do have an assuan name but are conveyed using ones which do have an assuan name but are conveyed using
environment variables, update the environment of the environment variables, update the environment of the
forked process. */ forked process. */
if (!assname if (!assname
|| !strcmp (name, "XAUTHORITY") || !strcmp (name, "XAUTHORITY")
|| !strcmp (name, "PINENTRY_USER_DATA")) || !strcmp (name, "PINENTRY_USER_DATA"))
{ {
@ -250,12 +250,12 @@ start_pinentry (ctrl_t ctrl)
entry_owner = ctrl; entry_owner = ctrl;
if (entry_ctx) if (entry_ctx)
return 0; return 0;
if (opt.verbose) if (opt.verbose)
log_info ("starting a new PIN Entry\n"); log_info ("starting a new PIN Entry\n");
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
fflush (stdout); fflush (stdout);
fflush (stderr); fflush (stderr);
#endif #endif
@ -300,7 +300,7 @@ start_pinentry (ctrl_t ctrl)
} }
else else
argv[1] = NULL; argv[1] = NULL;
i=0; i=0;
if (!opt.running_detached) if (!opt.running_detached)
{ {
@ -342,7 +342,7 @@ start_pinentry (ctrl_t ctrl)
if (DBG_ASSUAN) if (DBG_ASSUAN)
log_debug ("connection to PIN entry established\n"); log_debug ("connection to PIN entry established\n");
rc = assuan_transact (entry_ctx, rc = assuan_transact (entry_ctx,
opt.no_grab? "OPTION no-grab":"OPTION grab", opt.no_grab? "OPTION no-grab":"OPTION grab",
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -426,7 +426,7 @@ start_pinentry (ctrl_t ctrl)
} }
} }
/* Tell the pinentry the name of a file it shall touch after having /* Tell the pinentry the name of a file it shall touch after having
messed with the tty. This is optional and only supported by messed with the tty. This is optional and only supported by
newer pinentries and thus we do no error checking. */ newer pinentries and thus we do no error checking. */
@ -438,7 +438,7 @@ start_pinentry (ctrl_t ctrl)
if (tmpstr) if (tmpstr)
{ {
char *optstr; char *optstr;
if (asprintf (&optstr, "OPTION touch-file=%s", tmpstr ) < 0 ) if (asprintf (&optstr, "OPTION touch-file=%s", tmpstr ) < 0 )
; ;
else else
@ -454,7 +454,7 @@ start_pinentry (ctrl_t ctrl)
it will send the pid back and we will use an inquire to notify it will send the pid back and we will use an inquire to notify
our client. The client may answer the inquiry either with END or our client. The client may answer the inquiry either with END or
with CAN to cancel the pinentry. */ with CAN to cancel the pinentry. */
rc = assuan_transact (entry_ctx, "GETINFO pid", rc = assuan_transact (entry_ctx, "GETINFO pid",
getinfo_pid_cb, &pinentry_pid, getinfo_pid_cb, &pinentry_pid,
NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL);
if (rc) if (rc)
@ -542,7 +542,7 @@ all_digitsp( const char *s)
for (; *s && *s >= '0' && *s <= '9'; s++) for (; *s && *s >= '0' && *s <= '9'; s++)
; ;
return !*s; return !*s;
} }
/* Return a new malloced string by unescaping the string S. Escaping /* Return a new malloced string by unescaping the string S. Escaping
@ -561,7 +561,7 @@ unescape_passphrase_string (const unsigned char *s)
while (*s && !spacep (s)) while (*s && !spacep (s))
{ {
if (*s == '%' && s[1] && s[2]) if (*s == '%' && s[1] && s[2])
{ {
s++; s++;
*d = xtoi_2 (s); *d = xtoi_2 (s);
if (!*d) if (!*d)
@ -577,7 +577,7 @@ unescape_passphrase_string (const unsigned char *s)
else else
*d++ = *s++; *d++ = *s++;
} }
*d = 0; *d = 0;
return buffer; return buffer;
} }
@ -619,7 +619,7 @@ inq_quality (void *opaque, const char *line)
line += 7; line += 7;
while (*line == ' ') while (*line == ' ')
line++; line++;
pin = unescape_passphrase_string (line); pin = unescape_passphrase_string (line);
if (!pin) if (!pin)
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
@ -651,7 +651,7 @@ setup_qualitybar (void)
char line[ASSUAN_LINELENGTH]; char line[ASSUAN_LINELENGTH];
char *tmpstr, *tmpstr2; char *tmpstr, *tmpstr2;
const char *tooltip; const char *tooltip;
/* TRANSLATORS: This string is displayed by Pinentry as the label /* TRANSLATORS: This string is displayed by Pinentry as the label
for the quality bar. */ for the quality bar. */
tmpstr = try_percent_escape (_("Quality:"), "\t\r\n\f\v"); tmpstr = try_percent_escape (_("Quality:"), "\t\r\n\f\v");
@ -664,7 +664,7 @@ setup_qualitybar (void)
; /* Ignore Unknown Command from old Pinentry versions. */ ; /* Ignore Unknown Command from old Pinentry versions. */
else if (rc) else if (rc)
return rc; return rc;
tmpstr2 = gnupg_get_help_string ("pinentry.qualitybar.tooltip", 0); tmpstr2 = gnupg_get_help_string ("pinentry.qualitybar.tooltip", 0);
if (tmpstr2) if (tmpstr2)
tooltip = tmpstr2; tooltip = tmpstr2;
@ -715,7 +715,7 @@ close_button_status_cb (void *opaque, const char *line)
if ( !strcmp (line, "close") ) if ( !strcmp (line, "close") )
*flag = 1; *flag = 1;
} }
return 0; return 0;
} }
@ -738,7 +738,7 @@ agent_askpin (ctrl_t ctrl,
int is_pin = 0; int is_pin = 0;
int saveflag; int saveflag;
int close_button; int close_button;
if (opt.batch) if (opt.batch)
return 0; /* fixme: we should return BAD PIN */ return 0; /* fixme: we should return BAD PIN */
@ -784,7 +784,7 @@ agent_askpin (ctrl_t ctrl,
} }
if (initial_errtext) if (initial_errtext)
{ {
snprintf (line, DIM(line)-1, "SETERROR %s", initial_errtext); snprintf (line, DIM(line)-1, "SETERROR %s", initial_errtext);
line[DIM(line)-1] = 0; line[DIM(line)-1] = 0;
rc = assuan_transact (entry_ctx, line, rc = assuan_transact (entry_ctx, line,
@ -801,7 +801,7 @@ agent_askpin (ctrl_t ctrl,
parm.buffer = (unsigned char*)pininfo->pin; parm.buffer = (unsigned char*)pininfo->pin;
if (errtext) if (errtext)
{ {
/* TRANLATORS: The string is appended to an error message in /* TRANLATORS: The string is appended to an error message in
the pinentry. The %s is the actual error message, the the pinentry. The %s is the actual error message, the
two %d give the current and maximum number of tries. */ two %d give the current and maximum number of tries. */
@ -814,7 +814,7 @@ agent_askpin (ctrl_t ctrl,
return unlock_pinentry (rc); return unlock_pinentry (rc);
errtext = NULL; errtext = NULL;
} }
saveflag = assuan_get_flag (entry_ctx, ASSUAN_CONFIDENTIAL); saveflag = assuan_get_flag (entry_ctx, ASSUAN_CONFIDENTIAL);
assuan_begin_confidential (entry_ctx); assuan_begin_confidential (entry_ctx);
close_button = 0; close_button = 0;
@ -879,7 +879,7 @@ agent_askpin (ctrl_t ctrl,
/* Ask for the passphrase using the supplied arguments. The returned /* Ask for the passphrase using the supplied arguments. The returned
passphrase needs to be freed by the caller. */ passphrase needs to be freed by the caller. */
int int
agent_get_passphrase (ctrl_t ctrl, agent_get_passphrase (ctrl_t ctrl,
char **retpass, const char *desc, const char *prompt, char **retpass, const char *desc, const char *prompt,
const char *errtext, int with_qualitybar) const char *errtext, int with_qualitybar)
@ -893,7 +893,7 @@ agent_get_passphrase (ctrl_t ctrl,
*retpass = NULL; *retpass = NULL;
if (opt.batch) if (opt.batch)
return gpg_error (GPG_ERR_BAD_PASSPHRASE); return gpg_error (GPG_ERR_BAD_PASSPHRASE);
rc = start_pinentry (ctrl); rc = start_pinentry (ctrl);
if (rc) if (rc)
@ -973,9 +973,9 @@ agent_get_passphrase (ctrl_t ctrl,
displayed to allow the user to easily return a GPG_ERR_CANCELED. displayed to allow the user to easily return a GPG_ERR_CANCELED.
if the Pinentry does not support this, the user can still cancel by if the Pinentry does not support this, the user can still cancel by
closing the Pinentry window. */ closing the Pinentry window. */
int int
agent_get_confirmation (ctrl_t ctrl, agent_get_confirmation (ctrl_t ctrl,
const char *desc, const char *ok, const char *desc, const char *ok,
const char *notok, int with_cancel) const char *notok, int with_cancel)
{ {
int rc; int rc;
@ -1049,7 +1049,7 @@ agent_get_confirmation (ctrl_t ctrl,
text OK_BTN (which may be NULL to use the default of "OK") and waut text OK_BTN (which may be NULL to use the default of "OK") and waut
for the user to hit this button. The return value is not for the user to hit this button. The return value is not
relevant. */ relevant. */
int int
agent_show_message (ctrl_t ctrl, const char *desc, const char *ok_btn) agent_show_message (ctrl_t ctrl, const char *desc, const char *ok_btn)
{ {
int rc; int rc;
@ -1083,7 +1083,7 @@ agent_show_message (ctrl_t ctrl, const char *desc, const char *ok_btn)
if (rc) if (rc)
return unlock_pinentry (rc); return unlock_pinentry (rc);
} }
rc = assuan_transact (entry_ctx, "CONFIRM --one-button", NULL, NULL, NULL, rc = assuan_transact (entry_ctx, "CONFIRM --one-button", NULL, NULL, NULL,
NULL, NULL, NULL); NULL, NULL, NULL);
if (rc && gpg_err_source (rc) && gpg_err_code (rc) == GPG_ERR_ASS_CANCELED) if (rc && gpg_err_source (rc) && gpg_err_code (rc) == GPG_ERR_ASS_CANCELED)
@ -1103,7 +1103,7 @@ popup_message_thread (void *arg)
allow the use of old Pinentries. Those old Pinentries will then allow the use of old Pinentries. Those old Pinentries will then
show an additional Cancel button but that is mostly a visual show an additional Cancel button but that is mostly a visual
annoyance. */ annoyance. */
assuan_transact (entry_ctx, "CONFIRM --one-button", assuan_transact (entry_ctx, "CONFIRM --one-button",
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
popup_finished = 1; popup_finished = 1;
return NULL; return NULL;
@ -1116,7 +1116,7 @@ popup_message_thread (void *arg)
as the message is not anymore required because the message is as the message is not anymore required because the message is
system modal and all other attempts to use the pinentry will fail system modal and all other attempts to use the pinentry will fail
(after a timeout). */ (after a timeout). */
int int
agent_popup_message_start (ctrl_t ctrl, const char *desc, const char *ok_btn) agent_popup_message_start (ctrl_t ctrl, const char *desc, const char *ok_btn)
{ {
int rc; int rc;
@ -1177,7 +1177,7 @@ agent_popup_message_stop (ctrl_t ctrl)
if (!popup_tid || !entry_ctx) if (!popup_tid || !entry_ctx)
{ {
log_debug ("agent_popup_message_stop called with no active popup\n"); log_debug ("agent_popup_message_stop called with no active popup\n");
return; return;
} }
pid = assuan_get_pid (entry_ctx); pid = assuan_get_pid (entry_ctx);
@ -1192,7 +1192,7 @@ agent_popup_message_stop (ctrl_t ctrl)
&& pid != 0) && pid != 0)
{ {
HANDLE process = (HANDLE) pid; HANDLE process = (HANDLE) pid;
/* Arbitrary error code. */ /* Arbitrary error code. */
TerminateProcess (process, 1); TerminateProcess (process, 1);
} }
@ -1221,5 +1221,3 @@ agent_popup_message_stop (ctrl_t ctrl)
/* Now we can close the connection. */ /* Now we can close the connection. */
unlock_pinentry (0); unlock_pinentry (0);
} }

View File

@ -85,7 +85,7 @@ struct learn_parm_s
void *sinfo_cb_arg; void *sinfo_cb_arg;
}; };
struct inq_needpin_s struct inq_needpin_s
{ {
assuan_context_t ctx; assuan_context_t ctx;
int (*getpin_cb)(void *, const char *, char*, size_t); int (*getpin_cb)(void *, const char *, char*, size_t);
@ -169,7 +169,7 @@ agent_scd_dump_state (void)
dump_mutex_state (&start_scd_lock); dump_mutex_state (&start_scd_lock);
log_printf ("\n"); log_printf ("\n");
log_info ("agent_scd_dump_state: primary_scd_ctx=%p pid=%ld reusable=%d\n", log_info ("agent_scd_dump_state: primary_scd_ctx=%p pid=%ld reusable=%d\n",
primary_scd_ctx, primary_scd_ctx,
(long)assuan_get_pid (primary_scd_ctx), (long)assuan_get_pid (primary_scd_ctx),
primary_scd_ctx_reusable); primary_scd_ctx_reusable);
if (socket_name) if (socket_name)
@ -184,7 +184,7 @@ agent_scd_dump_state (void)
called and error checked before any SCD operation. CTRL is the called and error checked before any SCD operation. CTRL is the
usual connection context and RC the error code to be passed trhough usual connection context and RC the error code to be passed trhough
the function. */ the function. */
static int static int
unlock_scd (ctrl_t ctrl, int rc) unlock_scd (ctrl_t ctrl, int rc)
{ {
if (ctrl->scd_local->locked != 1) if (ctrl->scd_local->locked != 1)
@ -313,7 +313,7 @@ start_scd (ctrl_t ctrl)
/* Nope, it has not been started. Fire it up now. */ /* Nope, it has not been started. Fire it up now. */
if (opt.verbose) if (opt.verbose)
log_info ("no running SCdaemon - starting it\n"); log_info ("no running SCdaemon - starting it\n");
if (fflush (NULL)) if (fflush (NULL))
{ {
#ifndef HAVE_W32_SYSTEM #ifndef HAVE_W32_SYSTEM
@ -402,9 +402,9 @@ start_scd (ctrl_t ctrl)
if (opt.sigusr2_enabled) if (opt.sigusr2_enabled)
{ {
char buf[100]; char buf[100];
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
snprintf (buf, sizeof buf, "OPTION event-signal=%lx", snprintf (buf, sizeof buf, "OPTION event-signal=%lx",
(unsigned long)get_agent_scd_notify_event ()); (unsigned long)get_agent_scd_notify_event ());
#else #else
snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2); snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2);
@ -422,7 +422,7 @@ start_scd (ctrl_t ctrl)
unlock_scd (ctrl, err); unlock_scd (ctrl, err);
if (ctx) if (ctx)
assuan_release (ctx); assuan_release (ctx);
} }
else else
{ {
ctrl->scd_local->ctx = ctx; ctrl->scd_local->ctx = ctx;
@ -511,7 +511,7 @@ agent_scd_check_aliveness (void)
sl->ctx = NULL; sl->ctx = NULL;
} }
} }
primary_scd_ctx = NULL; primary_scd_ctx = NULL;
primary_scd_ctx_reusable = 0; primary_scd_ctx_reusable = 0;
@ -560,7 +560,7 @@ agent_reset_scd (ctrl_t ctrl)
assuan_release (ctrl->scd_local->ctx); assuan_release (ctrl->scd_local->ctx);
ctrl->scd_local->ctx = NULL; ctrl->scd_local->ctx = NULL;
} }
/* Remove the local context from our list and release it. */ /* Remove the local context from our list and release it. */
if (!scd_local_list) if (!scd_local_list)
BUG (); BUG ();
@ -569,7 +569,7 @@ agent_reset_scd (ctrl_t ctrl)
else else
{ {
struct scd_local_s *sl; struct scd_local_s *sl;
for (sl=scd_local_list; sl->next_local; sl = sl->next_local) for (sl=scd_local_list; sl->next_local; sl = sl->next_local)
if (sl->next_local == ctrl->scd_local) if (sl->next_local == ctrl->scd_local)
break; break;
@ -609,7 +609,7 @@ learn_status_cb (void *opaque, const char *line)
{ {
parm->sinfo_cb (parm->sinfo_cb_arg, keyword, keywordlen, line); parm->sinfo_cb (parm->sinfo_cb_arg, keyword, keywordlen, line);
} }
return 0; return 0;
} }
@ -676,7 +676,7 @@ get_serialno_cb (void *opaque, const char *line)
memcpy (*serialno, line, n); memcpy (*serialno, line, n);
(*serialno)[n] = 0; (*serialno)[n] = 0;
} }
return 0; return 0;
} }
@ -716,7 +716,7 @@ membuf_data_cb (void *opaque, const void *buffer, size_t length)
put_membuf (data, buffer, length); put_membuf (data, buffer, length);
return 0; return 0;
} }
/* Handle the NEEDPIN inquiry. */ /* Handle the NEEDPIN inquiry. */
static gpg_error_t static gpg_error_t
inq_needpin (void *opaque, const char *line) inq_needpin (void *opaque, const char *line)
@ -731,7 +731,7 @@ inq_needpin (void *opaque, const char *line)
line += 7; line += 7;
while (*line == ' ') while (*line == ' ')
line++; line++;
pinlen = 90; pinlen = 90;
pin = gcry_malloc_secure (pinlen); pin = gcry_malloc_secure (pinlen);
if (!pin) if (!pin)
@ -748,7 +748,7 @@ inq_needpin (void *opaque, const char *line)
line += 17; line += 17;
while (*line == ' ') while (*line == ' ')
line++; line++;
rc = parm->getpin_cb (parm->getpin_cb_arg, line, NULL, 1); rc = parm->getpin_cb (parm->getpin_cb_arg, line, NULL, 1);
} }
else if (!strncmp (line, "DISMISSKEYPADPROMPT", 19) else if (!strncmp (line, "DISMISSKEYPADPROMPT", 19)
@ -774,7 +774,7 @@ inq_needpin (void *opaque, const char *line)
assuan_end_confidential (parm->passthru); assuan_end_confidential (parm->passthru);
if (!rc) if (!rc)
{ {
if ((rest = (needrest if ((rest = (needrest
&& !assuan_get_flag (parm->ctx, ASSUAN_CONFIDENTIAL)))) && !assuan_get_flag (parm->ctx, ASSUAN_CONFIDENTIAL))))
assuan_begin_confidential (parm->ctx); assuan_begin_confidential (parm->ctx);
rc = assuan_send_data (parm->ctx, value, valuelen); rc = assuan_send_data (parm->ctx, value, valuelen);
@ -783,7 +783,7 @@ inq_needpin (void *opaque, const char *line)
xfree (value); xfree (value);
} }
else else
log_error ("error forwarding inquiry `%s': %s\n", log_error ("error forwarding inquiry `%s': %s\n",
line, gpg_strerror (rc)); line, gpg_strerror (rc));
} }
else else
@ -837,7 +837,7 @@ agent_card_pksign (ctrl_t ctrl,
inqparm.getpin_cb = getpin_cb; inqparm.getpin_cb = getpin_cb;
inqparm.getpin_cb_arg = getpin_cb_arg; inqparm.getpin_cb_arg = getpin_cb_arg;
inqparm.passthru = 0; inqparm.passthru = 0;
snprintf (line, DIM(line)-1, snprintf (line, DIM(line)-1,
ctrl->use_auth_call? "PKAUTH %s":"PKSIGN %s", keyid); ctrl->use_auth_call? "PKAUTH %s":"PKSIGN %s", keyid);
line[DIM(line)-1] = 0; line[DIM(line)-1] = 0;
rc = assuan_transact (ctrl->scd_local->ctx, line, rc = assuan_transact (ctrl->scd_local->ctx, line,
@ -1042,7 +1042,7 @@ card_getattr_cb (void *opaque, const char *line)
if (!parm->data) if (!parm->data)
parm->error = errno; parm->error = errno;
} }
return 0; return 0;
} }
@ -1070,7 +1070,7 @@ agent_card_getattr (ctrl_t ctrl, const char *name, char **result)
/* We assume that NAME does not need escaping. */ /* We assume that NAME does not need escaping. */
if (8 + strlen (name) > DIM(line)-1) if (8 + strlen (name) > DIM(line)-1)
return gpg_error (GPG_ERR_TOO_LARGE); return gpg_error (GPG_ERR_TOO_LARGE);
stpcpy (stpcpy (line, "GETATTR "), name); stpcpy (stpcpy (line, "GETATTR "), name);
err = start_scd (ctrl); err = start_scd (ctrl);
if (err) if (err)
@ -1081,10 +1081,10 @@ agent_card_getattr (ctrl_t ctrl, const char *name, char **result)
card_getattr_cb, &parm); card_getattr_cb, &parm);
if (!err && parm.error) if (!err && parm.error)
err = gpg_error_from_errno (parm.error); err = gpg_error_from_errno (parm.error);
if (!err && !parm.data) if (!err && !parm.data)
err = gpg_error (GPG_ERR_NO_DATA); err = gpg_error (GPG_ERR_NO_DATA);
if (!err) if (!err)
*result = parm.data; *result = parm.data;
else else
@ -1161,5 +1161,3 @@ agent_card_scd (ctrl_t ctrl, const char *cmdline,
return unlock_scd (ctrl, 0); return unlock_scd (ctrl, 0);
} }

View File

@ -68,7 +68,7 @@ static const char sshcontrolblurb[] =
"# in the SSH protocol. The ssh-add tool may add new entries to this\n" "# in the SSH protocol. The ssh-add tool may add new entries to this\n"
"# file to enable them; you may also add them manually. Comment\n" "# file to enable them; you may also add them manually. Comment\n"
"# lines, like this one, as well as empty lines are ignored. Lines do\n" "# lines, like this one, as well as empty lines are ignored. Lines do\n"
"# have a certain length limit but this is not serious limitation as\n" "# have a certain length limit but this is not serious limitation as\n"
"# the format of the entries is fixed and checked by gpg-agent. A\n" "# the format of the entries is fixed and checked by gpg-agent. A\n"
"# non-comment line starts with optional white spaces, followed by the\n" "# non-comment line starts with optional white spaces, followed by the\n"
"# keygrip of the key given as 40 hex digits, optionally followed by a\n" "# keygrip of the key given as 40 hex digits, optionally followed by a\n"
@ -192,7 +192,7 @@ static gpg_error_t ssh_signature_encoder_dsa (estream_t signature_blob,
/* Global variables. */ /* Global variables. */
/* Associating request types with the corresponding request /* Associating request types with the corresponding request
handlers. */ handlers. */
@ -234,7 +234,7 @@ static ssh_key_type_spec_t ssh_key_types[] =
/* /*
General utility functions. General utility functions.
*/ */
/* A secure realloc, i.e. it makes sure to allocate secure memory if A /* A secure realloc, i.e. it makes sure to allocate secure memory if A
@ -245,7 +245,7 @@ static void *
realloc_secure (void *a, size_t n) realloc_secure (void *a, size_t n)
{ {
void *p; void *p;
if (a) if (a)
p = gcry_realloc (a, n); p = gcry_realloc (a, n);
else else
@ -275,8 +275,8 @@ make_cstring (const char *data, size_t data_n)
/* /*
Primitive I/O functions. Primitive I/O functions.
*/ */
@ -466,7 +466,7 @@ stream_read_cstring (estream_t stream, char **string)
err = stream_read_string (stream, 0, &buffer, NULL); err = stream_read_string (stream, 0, &buffer, NULL);
if (err) if (err)
goto out; goto out;
*string = (char *) buffer; *string = (char *) buffer;
out: out:
@ -503,7 +503,7 @@ stream_write_cstring (estream_t stream, const char *string)
(const unsigned char *) string, strlen (string)); (const unsigned char *) string, strlen (string));
return err; return err;
} }
/* Read an MPI from STREAM, store it in MPINT. Depending on SECURE /* Read an MPI from STREAM, store it in MPINT. Depending on SECURE
use secure memory. */ use secure memory. */
@ -614,7 +614,7 @@ file_to_buffer (const char *filename, unsigned char **buffer, size_t *buffer_n)
buffer_new = NULL; buffer_new = NULL;
err = 0; err = 0;
stream = es_fopen (filename, "r"); stream = es_fopen (filename, "r");
if (! stream) if (! stream)
{ {
@ -678,7 +678,7 @@ open_control_file (FILE **r_fp, int append)
fp = fopen (fname, append? "a+":"r"); fp = fopen (fname, append? "a+":"r");
if (!fp && errno == ENOENT) if (!fp && errno == ENOENT)
{ {
estream_t stream = es_fopen (fname, "wx,mode=-rw-r"); estream_t stream = es_fopen (fname, "wx,mode=-rw-r");
if (!stream) if (!stream)
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
@ -698,8 +698,8 @@ open_control_file (FILE **r_fp, int append)
xfree (fname); xfree (fname);
return err; return err;
} }
*r_fp = fp; *r_fp = fp;
return 0; return 0;
} }
@ -710,7 +710,7 @@ open_control_file (FILE **r_fp, int append)
DISABLED if the found key has been disabled. If R_TTL is not NULL DISABLED if the found key has been disabled. If R_TTL is not NULL
a specified TTL for that key is stored there. */ a specified TTL for that key is stored there. */
static gpg_error_t static gpg_error_t
search_control_file (FILE *fp, const char *hexgrip, search_control_file (FILE *fp, const char *hexgrip,
int *r_disabled, int *r_ttl) int *r_disabled, int *r_ttl)
{ {
int c, i; int c, i;
@ -731,7 +731,7 @@ search_control_file (FILE *fp, const char *hexgrip,
return gpg_error (GPG_ERR_EOF); return gpg_error (GPG_ERR_EOF);
return gpg_error (gpg_err_code_from_errno (errno)); return gpg_error (gpg_err_code_from_errno (errno));
} }
if (!*line || line[strlen(line)-1] != '\n') if (!*line || line[strlen(line)-1] != '\n')
{ {
/* Eat until end of line */ /* Eat until end of line */
@ -740,13 +740,13 @@ search_control_file (FILE *fp, const char *hexgrip,
return gpg_error (*line? GPG_ERR_LINE_TOO_LONG return gpg_error (*line? GPG_ERR_LINE_TOO_LONG
: GPG_ERR_INCOMPLETE_LINE); : GPG_ERR_INCOMPLETE_LINE);
} }
/* Allow for empty lines and spaces */ /* Allow for empty lines and spaces */
for (p=line; spacep (p); p++) for (p=line; spacep (p); p++)
; ;
} }
while (!*p || *p == '\n' || *p == '#'); while (!*p || *p == '\n' || *p == '#');
*r_disabled = 0; *r_disabled = 0;
if (*p == '!') if (*p == '!')
{ {
@ -774,7 +774,7 @@ search_control_file (FILE *fp, const char *hexgrip,
if (r_ttl) if (r_ttl)
*r_ttl = ttl; *r_ttl = ttl;
/* Here is the place to parse flags if we need them. */ /* Here is the place to parse flags if we need them. */
return 0; /* Okay: found it. */ return 0; /* Okay: found it. */
} }
@ -812,7 +812,7 @@ add_control_entry (ctrl_t ctrl, const char *hexgrip, int ttl)
1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday,
tp->tm_hour, tp->tm_min, tp->tm_sec, tp->tm_hour, tp->tm_min, tp->tm_sec,
hexgrip, ttl); hexgrip, ttl);
} }
fclose (fp); fclose (fp);
return 0; return 0;
@ -836,7 +836,7 @@ ttl_from_sshcontrol (const char *hexgrip)
|| disabled) || disabled)
ttl = 0; /* Use the global default if not found or disabled. */ ttl = 0; /* Use the global default if not found or disabled. */
fclose (fp); fclose (fp);
return ttl; return ttl;
} }
@ -847,7 +847,7 @@ ttl_from_sshcontrol (const char *hexgrip)
/* /*
MPI lists. MPI lists.
*/ */
@ -884,7 +884,7 @@ ssh_receive_mpint_list (estream_t stream, int secret,
mpis = NULL; mpis = NULL;
err = 0; err = 0;
if (secret) if (secret)
elems = key_spec.elems_key_secret; elems = key_spec.elems_key_secret;
else else
@ -1006,7 +1006,7 @@ ssh_signature_encoder_dsa (estream_t signature_blob, gcry_mpi_t *mpis)
err = gpg_error (GPG_ERR_INTERNAL); /* FIXME? */ err = gpg_error (GPG_ERR_INTERNAL); /* FIXME? */
break; break;
} }
memset (buffer + (i * SSH_DSA_SIGNATURE_PADDING), 0, memset (buffer + (i * SSH_DSA_SIGNATURE_PADDING), 0,
SSH_DSA_SIGNATURE_PADDING - data_n); SSH_DSA_SIGNATURE_PADDING - data_n);
memcpy (buffer + (i * SSH_DSA_SIGNATURE_PADDING) memcpy (buffer + (i * SSH_DSA_SIGNATURE_PADDING)
@ -1027,8 +1027,8 @@ ssh_signature_encoder_dsa (estream_t signature_blob, gcry_mpi_t *mpis)
return err; return err;
} }
/* /*
S-Expressions. S-Expressions.
*/ */
@ -1250,7 +1250,7 @@ sexp_key_extract (gcry_sexp_t sexp,
gcry_sexp_release (value_list); gcry_sexp_release (value_list);
gcry_sexp_release (value_pair); gcry_sexp_release (value_pair);
gcry_sexp_release (comment_list); gcry_sexp_release (comment_list);
if (err) if (err)
{ {
xfree (comment_new); xfree (comment_new);
@ -1260,7 +1260,7 @@ sexp_key_extract (gcry_sexp_t sexp,
return err; return err;
} }
/* Extract the car from SEXP, and create a newly created C-string /* Extract the car from SEXP, and create a newly created C-string
which is to be stored in IDENTIFIER. */ which is to be stored in IDENTIFIER. */
static gpg_error_t static gpg_error_t
sexp_extract_identifier (gcry_sexp_t sexp, char **identifier) sexp_extract_identifier (gcry_sexp_t sexp, char **identifier)
@ -1273,7 +1273,7 @@ sexp_extract_identifier (gcry_sexp_t sexp, char **identifier)
identifier_new = NULL; identifier_new = NULL;
err = 0; err = 0;
sublist = gcry_sexp_nth (sexp, 1); sublist = gcry_sexp_nth (sexp, 1);
if (! sublist) if (! sublist)
{ {
@ -1327,7 +1327,7 @@ ssh_key_type_lookup (const char *ssh_name, const char *name,
if ((ssh_name && (! strcmp (ssh_name, ssh_key_types[i].ssh_identifier))) if ((ssh_name && (! strcmp (ssh_name, ssh_key_types[i].ssh_identifier)))
|| (name && (! strcmp (name, ssh_key_types[i].identifier)))) || (name && (! strcmp (name, ssh_key_types[i].identifier))))
break; break;
if (i == DIM (ssh_key_types)) if (i == DIM (ssh_key_types))
err = gpg_error (GPG_ERR_NOT_FOUND); err = gpg_error (GPG_ERR_NOT_FOUND);
else else
@ -1360,7 +1360,7 @@ ssh_receive_key (estream_t stream, gcry_sexp_t *key_new, int secret,
key_type = NULL; key_type = NULL;
comment = ""; comment = "";
key = NULL; key = NULL;
err = stream_read_cstring (stream, &key_type); err = stream_read_cstring (stream, &key_type);
if (err) if (err)
goto out; goto out;
@ -1399,7 +1399,7 @@ ssh_receive_key (estream_t stream, gcry_sexp_t *key_new, int secret,
if (key_spec) if (key_spec)
*key_spec = spec; *key_spec = spec;
*key_new = key; *key_new = key;
out: out:
mpint_list_free (mpi_list); mpint_list_free (mpi_list);
@ -1452,7 +1452,7 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
goto out; goto out;
} }
err = es_fseek (stream, 0, SEEK_SET); err = es_fseek (stream, 0, SEEK_SET);
if (err) if (err)
goto out; goto out;
@ -1480,7 +1480,7 @@ ssh_convert_key_to_blob (unsigned char **blob, size_t *blob_size,
return err; return err;
} }
/* Write the public key KEY_PUBLIC to STREAM in SSH key format. If /* Write the public key KEY_PUBLIC to STREAM in SSH key format. If
OVERRIDE_COMMENT is not NULL, it will be used instead of the OVERRIDE_COMMENT is not NULL, it will be used instead of the
@ -1518,14 +1518,14 @@ ssh_send_key_public (estream_t stream, gcry_sexp_t key_public,
spec.ssh_identifier, mpi_list); spec.ssh_identifier, mpi_list);
if (err) if (err)
goto out; goto out;
err = stream_write_string (stream, blob, blob_n); err = stream_write_string (stream, blob, blob_n);
if (err) if (err)
goto out; goto out;
err = stream_write_cstring (stream, err = stream_write_cstring (stream,
override_comment? override_comment : comment); override_comment? override_comment : comment);
out: out:
mpint_list_free (mpi_list); mpint_list_free (mpi_list);
@ -1548,7 +1548,7 @@ ssh_read_key_public_from_blob (unsigned char *blob, size_t blob_size,
gpg_error_t err; gpg_error_t err;
err = 0; err = 0;
blob_stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+"); blob_stream = es_mopen (NULL, 0, 0, 1, NULL, NULL, "r+");
if (! blob_stream) if (! blob_stream)
{ {
@ -1712,7 +1712,7 @@ card_key_available (ctrl_t ctrl, gcry_sexp_t *r_pk, char **cardsn)
/* (Shadow)-key is not available in our key storage. */ /* (Shadow)-key is not available in our key storage. */
unsigned char *shadow_info; unsigned char *shadow_info;
unsigned char *tmp; unsigned char *tmp;
shadow_info = make_shadow_info (serialno, authkeyid); shadow_info = make_shadow_info (serialno, authkeyid);
if (!shadow_info) if (!shadow_info)
{ {
@ -1847,7 +1847,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
goto out; goto out;
} }
key_directory_n = strlen (key_directory); key_directory_n = strlen (key_directory);
key_path = xtrymalloc (key_directory_n + 46); key_path = xtrymalloc (key_directory_n + 46);
if (! key_path) if (! key_path)
{ {
@ -1879,7 +1879,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
xfree (cardsn); xfree (cardsn);
if (err) if (err)
goto out; goto out;
key_counter++; key_counter++;
} }
@ -1919,7 +1919,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
err = file_to_buffer (key_path, &buffer, &buffer_n); err = file_to_buffer (key_path, &buffer, &buffer_n);
if (err) if (err)
goto out; goto out;
err = gcry_sexp_sscan (&key_secret, NULL, (char*)buffer, buffer_n); err = gcry_sexp_sscan (&key_secret, NULL, (char*)buffer, buffer_n);
if (err) if (err)
goto out; goto out;
@ -1944,7 +1944,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
gcry_sexp_release (key_secret); gcry_sexp_release (key_secret);
key_secret = NULL; key_secret = NULL;
err = ssh_send_key_public (key_blobs, key_public, NULL); err = ssh_send_key_public (key_blobs, key_public, NULL);
if (err) if (err)
goto out; goto out;
@ -1955,7 +1955,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
key_counter++; key_counter++;
} }
} }
ret = es_fseek (key_blobs, 0, SEEK_SET); ret = es_fseek (key_blobs, 0, SEEK_SET);
if (ret) if (ret)
{ {
@ -2149,15 +2149,15 @@ data_sign (ctrl_t ctrl, ssh_signature_encoder_t sig_encoder,
{ {
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
goto out; goto out;
} }
err = stream_read_data (stream, sig_blob, sig_blob_n); err = stream_read_data (stream, sig_blob, sig_blob_n);
if (err) if (err)
goto out; goto out;
*sig = sig_blob; *sig = sig_blob;
*sig_n = sig_blob_n; *sig_n = sig_blob_n;
out: out:
if (err) if (err)
@ -2199,7 +2199,7 @@ ssh_handler_sign_request (ctrl_t ctrl, estream_t request, estream_t response)
key = NULL; key = NULL;
/* Receive key. */ /* Receive key. */
err = stream_read_string (request, 0, &key_blob, &key_blob_size); err = stream_read_string (request, 0, &key_blob, &key_blob_size);
if (err) if (err)
goto out; goto out;
@ -2244,7 +2244,7 @@ ssh_handler_sign_request (ctrl_t ctrl, estream_t request, estream_t response)
memcpy (ctrl->keygrip, key_grip, 20); memcpy (ctrl->keygrip, key_grip, 20);
err = data_sign (ctrl, spec.signature_encoder, &sig, &sig_n); err = data_sign (ctrl, spec.signature_encoder, &sig, &sig_n);
out: out:
/* Done. */ /* Done. */
@ -2264,7 +2264,7 @@ ssh_handler_sign_request (ctrl_t ctrl, estream_t request, estream_t response)
if (ret_err) if (ret_err)
goto leave; goto leave;
} }
leave: leave:
gcry_sexp_release (key); gcry_sexp_release (key);
@ -2293,7 +2293,7 @@ ssh_key_extract_comment (gcry_sexp_t key, char **comment)
err = gpg_error (GPG_ERR_INV_SEXP); err = gpg_error (GPG_ERR_INV_SEXP);
goto out; goto out;
} }
data = gcry_sexp_nth_data (comment_list, 1, &data_n); data = gcry_sexp_nth_data (comment_list, 1, &data_n);
if (! data) if (! data)
{ {
@ -2337,7 +2337,7 @@ ssh_key_to_protected_buffer (gcry_sexp_t key, const char *passphrase,
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
goto out; goto out;
} }
gcry_sexp_sprint (key, GCRYSEXP_FMT_CANON, buffer_new, buffer_new_n); gcry_sexp_sprint (key, GCRYSEXP_FMT_CANON, buffer_new, buffer_new_n);
/* FIXME: guarantee? */ /* FIXME: guarantee? */
@ -2393,7 +2393,7 @@ ssh_identity_register (ctrl_t ctrl, gcry_sexp_t key, int ttl)
if ( !agent_key_available (key_grip_raw) ) if ( !agent_key_available (key_grip_raw) )
goto out; /* Yes, key is available. */ goto out; /* Yes, key is available. */
err = ssh_key_extract_comment (key, &comment); err = ssh_key_extract_comment (key, &comment);
if (err) if (err)
goto out; goto out;
@ -2469,7 +2469,7 @@ ssh_identity_register (ctrl_t ctrl, gcry_sexp_t key, int ttl)
xfree (pi); xfree (pi);
xfree (buffer); xfree (buffer);
xfree (comment); xfree (comment);
xfree (description); xfree (description);
return err; return err;
} }
@ -2508,7 +2508,7 @@ ssh_handler_add_identity (ctrl_t ctrl, estream_t request, estream_t response)
unsigned char b; unsigned char b;
int confirm; int confirm;
int ttl; int ttl;
confirm = 0; confirm = 0;
key = NULL; key = NULL;
ttl = 0; ttl = 0;
@ -2586,7 +2586,7 @@ ssh_handler_remove_identity (ctrl_t ctrl,
key_blob = NULL; key_blob = NULL;
key = NULL; key = NULL;
err = stream_read_string (request, 0, &key_blob, &key_blob_size); err = stream_read_string (request, 0, &key_blob, &key_blob_size);
if (err) if (err)
goto out; goto out;
@ -2594,7 +2594,7 @@ ssh_handler_remove_identity (ctrl_t ctrl,
err = ssh_read_key_public_from_blob (key_blob, key_blob_size, &key, NULL); err = ssh_read_key_public_from_blob (key_blob, key_blob_size, &key, NULL);
if (err) if (err)
goto out; goto out;
err = ssh_identity_drop (key); err = ssh_identity_drop (key);
out: out:
@ -2620,7 +2620,7 @@ ssh_identities_remove_all (void)
/* FIXME: shall we remove _all_ cache entries or only those /* FIXME: shall we remove _all_ cache entries or only those
registered through the ssh emulation? */ registered through the ssh emulation? */
return err; return err;
} }
@ -2634,7 +2634,7 @@ ssh_handler_remove_all_identities (ctrl_t ctrl,
(void)ctrl; (void)ctrl;
(void)request; (void)request;
err = ssh_identities_remove_all (); err = ssh_identities_remove_all ();
if (! err) if (! err)
@ -2679,7 +2679,7 @@ ssh_handler_lock (ctrl_t ctrl, estream_t request, estream_t response)
(void)ctrl; (void)ctrl;
(void)request; (void)request;
err = ssh_lock (); err = ssh_lock ();
if (! err) if (! err)
@ -2696,7 +2696,7 @@ ssh_handler_unlock (ctrl_t ctrl, estream_t request, estream_t response)
{ {
gpg_error_t ret_err; gpg_error_t ret_err;
gpg_error_t err; gpg_error_t err;
(void)ctrl; (void)ctrl;
(void)request; (void)request;
@ -2761,7 +2761,7 @@ ssh_request_process (ctrl_t ctrl, estream_t stream_sock)
/* Create memory streams for request/response data. The entire /* Create memory streams for request/response data. The entire
request will be stored in secure memory, since it might contain request will be stored in secure memory, since it might contain
secret key material. The response does not have to be stored in secret key material. The response does not have to be stored in
secure memory, since we never give out secret keys. secure memory, since we never give out secret keys.
Note: we only have little secure memory, but there is NO Note: we only have little secure memory, but there is NO
possibility of DoS here; only trusted clients are allowed to possibility of DoS here; only trusted clients are allowed to
@ -2912,7 +2912,7 @@ start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client)
the current TTY setting, we resort here to use those from startup the current TTY setting, we resort here to use those from startup
or those explictly set. */ or those explictly set. */
{ {
static const char *names[] = static const char *names[] =
{"GPG_TTY", "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL}; {"GPG_TTY", "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL};
int idx; int idx;
const char *value; const char *value;
@ -2921,7 +2921,7 @@ start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client)
if (!session_env_getenv (ctrl->session_env, names[idx]) if (!session_env_getenv (ctrl->session_env, names[idx])
&& (value = session_env_getenv (opt.startup_env, names[idx]))) && (value = session_env_getenv (opt.startup_env, names[idx])))
err = session_env_setenv (ctrl->session_env, names[idx], value); err = session_env_setenv (ctrl->session_env, names[idx], value);
if (!err && !ctrl->lc_ctype && opt.startup_lc_ctype) if (!err && !ctrl->lc_ctype && opt.startup_lc_ctype)
if (!(ctrl->lc_ctype = xtrystrdup (opt.startup_lc_ctype))) if (!(ctrl->lc_ctype = xtrystrdup (opt.startup_lc_ctype)))
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
@ -2932,7 +2932,7 @@ start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client)
if (err) if (err)
{ {
log_error ("error setting default session environment: %s\n", log_error ("error setting default session environment: %s\n",
gpg_strerror (err)); gpg_strerror (err));
goto out; goto out;
} }

View File

@ -83,7 +83,7 @@ struct putval_item_s
struct putval_item_s *next; struct putval_item_s *next;
size_t off; /* Offset to the value into DATA. */ size_t off; /* Offset to the value into DATA. */
size_t len; /* Length of the value. */ size_t len; /* Length of the value. */
char d[1]; /* Key | Nul | value. */ char d[1]; /* Key | Nul | value. */
}; };
@ -97,14 +97,14 @@ static struct putval_item_s *putval_list;
integers and there should be no problem if they are overflowing as integers and there should be no problem if they are overflowing as
callers need to check only whether a counter changed. The actual callers need to check only whether a counter changed. The actual
values are not meaningful. */ values are not meaningful. */
struct struct
{ {
/* Incremented if any of the other counters below changed. */ /* Incremented if any of the other counters below changed. */
unsigned int any; unsigned int any;
/* Incremented if a key is added or removed from the internal privat /* Incremented if a key is added or removed from the internal privat
key database. */ key database. */
unsigned int key; unsigned int key;
/* Incremented if a change of the card readers stati has been /* Incremented if a change of the card readers stati has been
detected. */ detected. */
@ -195,7 +195,7 @@ reset_notify (assuan_context_t ctx, char *line)
} }
/* Skip over options. /* Skip over options.
Blanks after the options are also removed. */ Blanks after the options are also removed. */
static char * static char *
skip_options (const char *line) skip_options (const char *line)
@ -331,7 +331,7 @@ agent_write_status (ctrl_t ctrl, const char *keyword, ...)
va_start (arg_ptr, keyword); va_start (arg_ptr, keyword);
p = buf; p = buf;
n = 0; n = 0;
while ( (text = va_arg (arg_ptr, const char *)) ) while ( (text = va_arg (arg_ptr, const char *)) )
{ {
@ -372,7 +372,7 @@ agent_inq_pinentry_launched (ctrl_t ctrl, unsigned long pid)
{ {
char line[100]; char line[100];
if (!ctrl || !ctrl->server_local if (!ctrl || !ctrl->server_local
|| !ctrl->server_local->allow_pinentry_notify) || !ctrl->server_local->allow_pinentry_notify)
return 0; return 0;
snprintf (line, DIM(line)-1, "PINENTRY_LAUNCHED %lu", pid); snprintf (line, DIM(line)-1, "PINENTRY_LAUNCHED %lu", pid);
@ -417,7 +417,7 @@ leave_cmd (assuan_context_t ctx, gpg_error_t err)
static const char hlp_geteventcounter[] = static const char hlp_geteventcounter[] =
"GETEVENTCOUNTER\n" "GETEVENTCOUNTER\n"
"\n" "\n"
"Return a a status line named EVENTCOUNTER with the current values\n" "Return a a status line named EVENTCOUNTER with the current values\n"
@ -475,7 +475,7 @@ bump_card_eventcounter (void)
static const char hlp_istrusted[] = static const char hlp_istrusted[] =
"ISTRUSTED <hexstring_with_fingerprint>\n" "ISTRUSTED <hexstring_with_fingerprint>\n"
"\n" "\n"
"Return OK when we have an entry with this fingerprint in our\n" "Return OK when we have an entry with this fingerprint in our\n"
@ -512,7 +512,7 @@ cmd_istrusted (assuan_context_t ctx, char *line)
} }
static const char hlp_listtrusted[] = static const char hlp_listtrusted[] =
"LISTTRUSTED\n" "LISTTRUSTED\n"
"\n" "\n"
"List all entries from the trustlist."; "List all entries from the trustlist.";
@ -520,7 +520,7 @@ static gpg_error_t
cmd_listtrusted (assuan_context_t ctx, char *line) cmd_listtrusted (assuan_context_t ctx, char *line)
{ {
int rc; int rc;
(void)line; (void)line;
rc = agent_listtrusted (ctx); rc = agent_listtrusted (ctx);
@ -528,7 +528,7 @@ cmd_listtrusted (assuan_context_t ctx, char *line)
} }
static const char hlp_martrusted[] = static const char hlp_martrusted[] =
"MARKTRUSTED <hexstring_with_fingerprint> <flag> <display_name>\n" "MARKTRUSTED <hexstring_with_fingerprint> <flag> <display_name>\n"
"\n" "\n"
"Store a new key in into the trustlist."; "Store a new key in into the trustlist.";
@ -555,7 +555,7 @@ cmd_marktrusted (assuan_context_t ctx, char *line)
for (p=line; i < 40; p++, i++) for (p=line; i < 40; p++, i++)
fpr[i] = *p >= 'a'? (*p & 0xdf): *p; fpr[i] = *p >= 'a'? (*p & 0xdf): *p;
fpr[i] = 0; fpr[i] = 0;
while (spacep (p)) while (spacep (p))
p++; p++;
flag = *p++; flag = *p++;
@ -582,12 +582,12 @@ cmd_havekey (assuan_context_t ctx, char *line)
gpg_error_t err; gpg_error_t err;
unsigned char buf[20]; unsigned char buf[20];
do do
{ {
err = parse_keygrip (ctx, line, buf); err = parse_keygrip (ctx, line, buf);
if (err) if (err)
return err; return err;
if (!agent_key_available (buf)) if (!agent_key_available (buf))
return 0; /* Found. */ return 0; /* Found. */
@ -597,7 +597,7 @@ cmd_havekey (assuan_context_t ctx, char *line)
line++; line++;
} }
while (*line); while (*line);
/* No leave_cmd() here because errors are expected and would clutter /* No leave_cmd() here because errors are expected and would clutter
the log. */ the log. */
return gpg_error (GPG_ERR_NO_SECKEY); return gpg_error (GPG_ERR_NO_SECKEY);
@ -623,7 +623,7 @@ cmd_sigkey (assuan_context_t ctx, char *line)
} }
static const char hlp_setkeydesc[] = static const char hlp_setkeydesc[] =
"SETKEYDESC plus_percent_escaped_string\n" "SETKEYDESC plus_percent_escaped_string\n"
"\n" "\n"
"Set a description to be used for the next PKSIGN, PKDECRYPT, IMPORT_KEY\n" "Set a description to be used for the next PKSIGN, PKDECRYPT, IMPORT_KEY\n"
@ -710,7 +710,7 @@ cmd_sethash (assuan_context_t ctx, char *line)
algo = 0; algo = 0;
line = skip_options (line); line = skip_options (line);
if (!algo) if (!algo)
{ {
/* No hash option has been given: require an algo number instead */ /* No hash option has been given: require an algo number instead */
@ -731,7 +731,7 @@ cmd_sethash (assuan_context_t ctx, char *line)
n /= 2; n /= 2;
if (algo == MD_USER_TLS_MD5SHA1 && n == 36) if (algo == MD_USER_TLS_MD5SHA1 && n == 36)
; ;
else if (n != 16 && n != 20 && n != 24 else if (n != 16 && n != 20 && n != 24
&& n != 28 && n != 32 && n != 48 && n != 64) && n != 28 && n != 32 && n != 48 && n != 64)
return set_error (GPG_ERR_ASS_PARAMETER, "unsupported length of hash"); return set_error (GPG_ERR_ASS_PARAMETER, "unsupported length of hash");
@ -748,7 +748,7 @@ cmd_sethash (assuan_context_t ctx, char *line)
} }
static const char hlp_pksign[] = static const char hlp_pksign[] =
"PKSIGN [<options>] [<cache_nonce>]\n" "PKSIGN [<options>] [<cache_nonce>]\n"
"\n" "\n"
"Perform the actual sign operation. Neither input nor output are\n" "Perform the actual sign operation. Neither input nor output are\n"
@ -762,9 +762,9 @@ cmd_pksign (assuan_context_t ctx, char *line)
membuf_t outbuf; membuf_t outbuf;
char *cache_nonce = NULL; char *cache_nonce = NULL;
char *p; char *p;
line = skip_options (line); line = skip_options (line);
p = line; p = line;
for (p=line; *p && *p != ' ' && *p != '\t'; p++) for (p=line; *p && *p != ' ' && *p != '\t'; p++)
; ;
@ -793,7 +793,7 @@ cmd_pksign (assuan_context_t ctx, char *line)
} }
static const char hlp_pkdecrypt[] = static const char hlp_pkdecrypt[] =
"PKDECRYPT [<options>]\n" "PKDECRYPT [<options>]\n"
"\n" "\n"
"Perform the actual decrypt operation. Input is not\n" "Perform the actual decrypt operation. Input is not\n"
@ -830,7 +830,7 @@ cmd_pkdecrypt (assuan_context_t ctx, char *line)
} }
static const char hlp_genkey[] = static const char hlp_genkey[] =
"GENKEY [--no-protection] [<cache_nonce>]\n" "GENKEY [--no-protection] [<cache_nonce>]\n"
"\n" "\n"
"Generate a new key, store the secret part and return the public\n" "Generate a new key, store the secret part and return the public\n"
@ -855,7 +855,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
membuf_t outbuf; membuf_t outbuf;
char *cache_nonce = NULL; char *cache_nonce = NULL;
char *p; char *p;
no_protection = has_option (line, "--no-protection"); no_protection = has_option (line, "--no-protection");
line = skip_options (line); line = skip_options (line);
@ -887,7 +887,7 @@ cmd_genkey (assuan_context_t ctx, char *line)
static const char hlp_readkey[] = static const char hlp_readkey[] =
"READKEY <hexstring_with_keygrip>\n" "READKEY <hexstring_with_keygrip>\n"
"\n" "\n"
"Return the public key for the given keygrip."; "Return the public key for the given keygrip.";
@ -929,7 +929,7 @@ cmd_readkey (assuan_context_t ctx, char *line)
static const char hlp_keyinfo[] = static const char hlp_keyinfo[] =
"KEYINFO [--list] <keygrip>\n" "KEYINFO [--list] <keygrip>\n"
"\n" "\n"
"Return information about the key specified by the KEYGRIP. If the\n" "Return information about the key specified by the KEYGRIP. If the\n"
@ -972,22 +972,22 @@ do_one_keyinfo (ctrl_t ctrl, const unsigned char *grip)
/* Reformat the grip so that we use uppercase as good style. */ /* Reformat the grip so that we use uppercase as good style. */
bin2hex (grip, 20, hexgrip); bin2hex (grip, 20, hexgrip);
if (keytype == PRIVATE_KEY_CLEAR if (keytype == PRIVATE_KEY_CLEAR
|| keytype == PRIVATE_KEY_PROTECTED) || keytype == PRIVATE_KEY_PROTECTED)
keytypestr = "D"; keytypestr = "D";
else if (keytype == PRIVATE_KEY_SHADOWED) else if (keytype == PRIVATE_KEY_SHADOWED)
keytypestr = "T"; keytypestr = "T";
else else
keytypestr = "-"; keytypestr = "-";
if (shadow_info) if (shadow_info)
{ {
err = parse_shadow_info (shadow_info, &serialno, &idstr); err = parse_shadow_info (shadow_info, &serialno, &idstr);
if (err) if (err)
goto leave; goto leave;
} }
err = agent_write_status (ctrl, "KEYINFO", err = agent_write_status (ctrl, "KEYINFO",
hexgrip, hexgrip,
keytypestr, keytypestr,
@ -1019,7 +1019,7 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
char *dirname; char *dirname;
struct dirent *dir_entry; struct dirent *dir_entry;
char hexgrip[41]; char hexgrip[41];
dirname = make_filename_try (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, NULL); dirname = make_filename_try (opt.homedir, GNUPG_PRIVATE_KEYS_DIR, NULL);
if (!dirname) if (!dirname)
{ {
@ -1059,7 +1059,7 @@ cmd_keyinfo (assuan_context_t ctx, char *line)
goto leave; goto leave;
err = do_one_keyinfo (ctrl, grip); err = do_one_keyinfo (ctrl, grip);
} }
leave: leave:
if (dir) if (dir)
closedir (dir); closedir (dir);
@ -1096,7 +1096,7 @@ send_back_passphrase (assuan_context_t ctx, int via_data, const char *pw)
} }
static const char hlp_get_passphrase[] = static const char hlp_get_passphrase[] =
"GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]]\n" "GET_PASSPHRASE [--data] [--check] [--no-ask] [--repeat[=N]]\n"
" [--qualitybar] <cache_id>\n" " [--qualitybar] <cache_id>\n"
" [<error_message> <prompt> <description>]\n" " [<error_message> <prompt> <description>]\n"
@ -1215,8 +1215,8 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
plus_to_blank (desc); plus_to_blank (desc);
next_try: next_try:
rc = agent_get_passphrase (ctrl, &response, desc, prompt, rc = agent_get_passphrase (ctrl, &response, desc, prompt,
repeat_errtext? repeat_errtext:errtext, repeat_errtext? repeat_errtext:errtext,
opt_qualbar); opt_qualbar);
xfree (repeat_errtext); xfree (repeat_errtext);
repeat_errtext = NULL; repeat_errtext = NULL;
@ -1241,7 +1241,7 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
{ {
xfree (response2); xfree (response2);
xfree (response); xfree (response);
repeat_errtext = try_percent_escape repeat_errtext = try_percent_escape
(_("does not match - try again"), NULL); (_("does not match - try again"), NULL);
if (!repeat_errtext) if (!repeat_errtext)
{ {
@ -1266,7 +1266,7 @@ cmd_get_passphrase (assuan_context_t ctx, char *line)
} }
static const char hlp_clear_passphrase[] = static const char hlp_clear_passphrase[] =
"CLEAR_PASSPHRASE <cache_id>\n" "CLEAR_PASSPHRASE <cache_id>\n"
"\n" "\n"
"may be used to invalidate the cache entry for a passphrase. The\n" "may be used to invalidate the cache entry for a passphrase. The\n"
@ -1292,7 +1292,7 @@ cmd_clear_passphrase (assuan_context_t ctx, char *line)
} }
static const char hlp_get_confirmation[] = static const char hlp_get_confirmation[] =
"GET_CONFIRMATION <description>\n" "GET_CONFIRMATION <description>\n"
"\n" "\n"
"This command may be used to ask for a simple confirmation.\n" "This command may be used to ask for a simple confirmation.\n"
@ -1355,7 +1355,7 @@ cmd_learn (assuan_context_t ctx, char *line)
static const char hlp_passwd[] = static const char hlp_passwd[] =
"PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] <hexstring_with_keygrip>\n" "PASSWD [--cache-nonce=<c>] [--passwd-nonce=<s>] <hexstring_with_keygrip>\n"
"\n" "\n"
"Change the passphrase/PIN for the key identified by keygrip in LINE."; "Change the passphrase/PIN for the key identified by keygrip in LINE.";
@ -1413,7 +1413,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
ctrl->in_passwd++; ctrl->in_passwd++;
err = agent_key_from_file (ctrl, cache_nonce, ctrl->server_local->keydesc, err = agent_key_from_file (ctrl, cache_nonce, ctrl->server_local->keydesc,
grip, &shadow_info, CACHE_MODE_IGNORE, NULL, grip, &shadow_info, CACHE_MODE_IGNORE, NULL,
&s_skey, &passphrase); &s_skey, &passphrase);
if (err) if (err)
; ;
@ -1441,7 +1441,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
gcry_create_nonce (buf, 12); gcry_create_nonce (buf, 12);
cache_nonce = bin2hex (buf, 12, NULL); cache_nonce = bin2hex (buf, 12, NULL);
} }
if (cache_nonce if (cache_nonce
&& !agent_put_cache (cache_nonce, CACHE_MODE_NONCE, && !agent_put_cache (cache_nonce, CACHE_MODE_NONCE,
passphrase, 120 /*seconds*/)) passphrase, 120 /*seconds*/))
{ {
@ -1461,7 +1461,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
gcry_create_nonce (buf, 12); gcry_create_nonce (buf, 12);
passwd_nonce = bin2hex (buf, 12, NULL); passwd_nonce = bin2hex (buf, 12, NULL);
} }
if (passwd_nonce if (passwd_nonce
&& !agent_put_cache (passwd_nonce, CACHE_MODE_NONCE, && !agent_put_cache (passwd_nonce, CACHE_MODE_NONCE,
newpass, 120 /*seconds*/)) newpass, 120 /*seconds*/))
{ {
@ -1488,7 +1488,7 @@ cmd_passwd (assuan_context_t ctx, char *line)
} }
static const char hlp_preset_passphrase[] = static const char hlp_preset_passphrase[] =
"PRESET_PASSPHRASE <string_or_keygrip> <timeout> <hexstring>\n" "PRESET_PASSPHRASE <string_or_keygrip> <timeout> <hexstring>\n"
"\n" "\n"
"Set the cached passphrase/PIN for the key identified by the keygrip\n" "Set the cached passphrase/PIN for the key identified by the keygrip\n"
@ -1517,7 +1517,7 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line)
line++; line++;
while (*line && (*line == ' ' || *line == '\t')) while (*line && (*line == ' ' || *line == '\t'))
line++; line++;
/* Currently, only infinite timeouts are allowed. */ /* Currently, only infinite timeouts are allowed. */
ttl = -1; ttl = -1;
if (line[0] != '-' || line[1] != '1') if (line[0] != '-' || line[1] != '1')
@ -1554,7 +1554,7 @@ cmd_preset_passphrase (assuan_context_t ctx, char *line)
static const char hlp_scd[] = static const char hlp_scd[] =
"SCD <commands to pass to the scdaemon>\n" "SCD <commands to pass to the scdaemon>\n"
" \n" " \n"
"This is a general quote command to redirect everything to the\n" "This is a general quote command to redirect everything to the\n"
@ -1601,7 +1601,7 @@ cmd_keywrap_key (assuan_context_t ctx, char *line)
xfree (ctrl->server_local->import_key); xfree (ctrl->server_local->import_key);
if (clearopt) if (clearopt)
ctrl->server_local->import_key = NULL; ctrl->server_local->import_key = NULL;
else if (!(ctrl->server_local->import_key = else if (!(ctrl->server_local->import_key =
gcry_random_bytes (KEYWRAP_KEYSIZE, GCRY_STRONG_RANDOM))) gcry_random_bytes (KEYWRAP_KEYSIZE, GCRY_STRONG_RANDOM)))
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
else else
@ -1613,7 +1613,7 @@ cmd_keywrap_key (assuan_context_t ctx, char *line)
xfree (ctrl->server_local->export_key); xfree (ctrl->server_local->export_key);
if (clearopt) if (clearopt)
ctrl->server_local->export_key = NULL; ctrl->server_local->export_key = NULL;
else if (!(ctrl->server_local->export_key = else if (!(ctrl->server_local->export_key =
gcry_random_bytes (KEYWRAP_KEYSIZE, GCRY_STRONG_RANDOM))) gcry_random_bytes (KEYWRAP_KEYSIZE, GCRY_STRONG_RANDOM)))
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
else else
@ -1623,7 +1623,7 @@ cmd_keywrap_key (assuan_context_t ctx, char *line)
else else
err = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for MODE"); err = set_error (GPG_ERR_ASS_PARAMETER, "unknown value for MODE");
assuan_end_confidential (ctx); assuan_end_confidential (ctx);
return leave_cmd (ctx, err); return leave_cmd (ctx, err);
} }
@ -1654,7 +1654,7 @@ cmd_import_key (assuan_context_t ctx, char *line)
gcry_sexp_t openpgp_sexp = NULL; gcry_sexp_t openpgp_sexp = NULL;
char *cache_nonce = NULL; char *cache_nonce = NULL;
char *p; char *p;
if (!ctrl->server_local->import_key) if (!ctrl->server_local->import_key)
{ {
err = gpg_error (GPG_ERR_MISSING_KEY); err = gpg_error (GPG_ERR_MISSING_KEY);
@ -1706,7 +1706,7 @@ cmd_import_key (assuan_context_t ctx, char *line)
realkeylen = gcry_sexp_canon_len (key, keylen, NULL, &err); realkeylen = gcry_sexp_canon_len (key, keylen, NULL, &err);
if (!realkeylen) if (!realkeylen)
goto leave; /* Invalid canonical encoded S-expression. */ goto leave; /* Invalid canonical encoded S-expression. */
err = keygrip_from_canon_sexp (key, realkeylen, grip); err = keygrip_from_canon_sexp (key, realkeylen, grip);
if (err) if (err)
{ {
@ -1717,7 +1717,7 @@ cmd_import_key (assuan_context_t ctx, char *line)
{ {
const char *tag; const char *tag;
size_t taglen; size_t taglen;
tag = gcry_sexp_nth_data (openpgp_sexp, 0, &taglen); tag = gcry_sexp_nth_data (openpgp_sexp, 0, &taglen);
if (tag && taglen == 19 && !memcmp (tag, "openpgp-private-key", 19)) if (tag && taglen == 19 && !memcmp (tag, "openpgp-private-key", 19))
; ;
@ -1739,7 +1739,7 @@ cmd_import_key (assuan_context_t ctx, char *line)
ask for a passphrase. That passphrase will be returned and ask for a passphrase. That passphrase will be returned and
used to protect the key using the same code as for regular used to protect the key using the same code as for regular
key import. */ key import. */
err = convert_from_openpgp (ctrl, openpgp_sexp, grip, err = convert_from_openpgp (ctrl, openpgp_sexp, grip,
ctrl->server_local->keydesc, cache_nonce, ctrl->server_local->keydesc, cache_nonce,
&key, &passphrase); &key, &passphrase);
@ -1756,7 +1756,7 @@ cmd_import_key (assuan_context_t ctx, char *line)
gcry_create_nonce (buf, 12); gcry_create_nonce (buf, 12);
cache_nonce = bin2hex (buf, 12, NULL); cache_nonce = bin2hex (buf, 12, NULL);
} }
if (cache_nonce if (cache_nonce
&& !agent_put_cache (cache_nonce, CACHE_MODE_NONCE, && !agent_put_cache (cache_nonce, CACHE_MODE_NONCE,
passphrase, 120 /*seconds*/)) passphrase, 120 /*seconds*/))
assuan_write_status (ctx, "CACHE_NONCE", cache_nonce); assuan_write_status (ctx, "CACHE_NONCE", cache_nonce);
@ -1767,7 +1767,7 @@ cmd_import_key (assuan_context_t ctx, char *line)
if (!agent_key_available (grip)) if (!agent_key_available (grip))
err = gpg_error (GPG_ERR_EEXIST); err = gpg_error (GPG_ERR_EEXIST);
else else
err = agent_ask_new_passphrase err = agent_ask_new_passphrase
(ctrl, _("Please enter the passphrase to protect the " (ctrl, _("Please enter the passphrase to protect the "
"imported object within the GnuPG system."), "imported object within the GnuPG system."),
&passphrase); &passphrase);
@ -1821,7 +1821,7 @@ cmd_export_key (assuan_context_t ctx, char *line)
int openpgp; int openpgp;
char *cache_nonce; char *cache_nonce;
char *passphrase = NULL; char *passphrase = NULL;
openpgp = has_option (line, "--openpgp"); openpgp = has_option (line, "--openpgp");
cache_nonce = option_value (line, "--cache-nonce"); cache_nonce = option_value (line, "--cache-nonce");
if (cache_nonce) if (cache_nonce)
@ -1870,7 +1870,7 @@ cmd_export_key (assuan_context_t ctx, char *line)
err = gpg_error (GPG_ERR_UNUSABLE_SECKEY); err = gpg_error (GPG_ERR_UNUSABLE_SECKEY);
goto leave; goto leave;
} }
if (openpgp) if (openpgp)
{ {
/* The openpgp option changes the key format into the OpenPGP /* The openpgp option changes the key format into the OpenPGP
@ -1878,7 +1878,7 @@ cmd_export_key (assuan_context_t ctx, char *line)
canonical S-expression. */ canonical S-expression. */
if (!passphrase) if (!passphrase)
{ {
err = agent_ask_new_passphrase err = agent_ask_new_passphrase
(ctrl, _("This key (or subkey) is not protected with a passphrase." (ctrl, _("This key (or subkey) is not protected with a passphrase."
" Please enter a new passphrase to export it."), " Please enter a new passphrase to export it."),
&passphrase); &passphrase);
@ -1925,7 +1925,7 @@ cmd_export_key (assuan_context_t ctx, char *line)
assuan_begin_confidential (ctx); assuan_begin_confidential (ctx);
err = assuan_send_data (ctx, wrappedkey, wrappedkeylen); err = assuan_send_data (ctx, wrappedkey, wrappedkeylen);
assuan_end_confidential (ctx); assuan_end_confidential (ctx);
leave: leave:
xfree (cache_nonce); xfree (cache_nonce);
@ -1943,7 +1943,7 @@ cmd_export_key (assuan_context_t ctx, char *line)
static const char hlp_getval[] = static const char hlp_getval[] =
"GETVAL <key>\n" "GETVAL <key>\n"
"\n" "\n"
"Return the value for KEY from the special environment as created by\n" "Return the value for KEY from the special environment as created by\n"
@ -1962,7 +1962,7 @@ cmd_getval (assuan_context_t ctx, char *line)
p = strchr (key, ' '); p = strchr (key, ' ');
if (p) if (p)
{ {
*p++ = 0; *p++ = 0;
for (; *p == ' '; p++) for (; *p == ' '; p++)
; ;
if (*p) if (*p)
@ -1985,7 +1985,7 @@ cmd_getval (assuan_context_t ctx, char *line)
} }
static const char hlp_putval[] = static const char hlp_putval[] =
"PUTVAL <key> [<percent_escaped_value>]\n" "PUTVAL <key> [<percent_escaped_value>]\n"
"\n" "\n"
"The gpg-agent maintains a kind of environment which may be used to\n" "The gpg-agent maintains a kind of environment which may be used to\n"
@ -2019,7 +2019,7 @@ cmd_putval (assuan_context_t ctx, char *line)
p = strchr (key, ' '); p = strchr (key, ' ');
if (p) if (p)
{ {
*p++ = 0; *p++ = 0;
for (; *p == ' '; p++) for (; *p == ' '; p++)
; ;
if (*p) if (*p)
@ -2048,7 +2048,7 @@ cmd_putval (assuan_context_t ctx, char *line)
xfree (vl); xfree (vl);
} }
if (valuelen) /* Add entry. */ if (valuelen) /* Add entry. */
{ {
vl = xtrymalloc (sizeof *vl + strlen (key) + valuelen); vl = xtrymalloc (sizeof *vl + strlen (key) + valuelen);
if (!vl) if (!vl)
@ -2070,7 +2070,7 @@ cmd_putval (assuan_context_t ctx, char *line)
static const char hlp_updatestartuptty[] = static const char hlp_updatestartuptty[] =
"UPDATESTARTUPTTY\n" "UPDATESTARTUPTTY\n"
"\n" "\n"
"Set startup TTY and X11 DISPLAY variables to the values of this\n" "Set startup TTY and X11 DISPLAY variables to the values of this\n"
@ -2080,7 +2080,7 @@ static const char hlp_updatestartuptty[] =
static gpg_error_t static gpg_error_t
cmd_updatestartuptty (assuan_context_t ctx, char *line) cmd_updatestartuptty (assuan_context_t ctx, char *line)
{ {
static const char *names[] = static const char *names[] =
{ "GPG_TTY", "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL }; { "GPG_TTY", "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL };
ctrl_t ctrl = assuan_get_pointer (ctx); ctrl_t ctrl = assuan_get_pointer (ctx);
gpg_error_t err = 0; gpg_error_t err = 0;
@ -2088,7 +2088,7 @@ cmd_updatestartuptty (assuan_context_t ctx, char *line)
int idx; int idx;
char *lc_ctype = NULL; char *lc_ctype = NULL;
char *lc_messages = NULL; char *lc_messages = NULL;
(void)line; (void)line;
se = session_env_new (); se = session_env_new ();
@ -2102,14 +2102,14 @@ cmd_updatestartuptty (assuan_context_t ctx, char *line)
err = session_env_setenv (se, names[idx], value); err = session_env_setenv (se, names[idx], value);
} }
if (!err && ctrl->lc_ctype) if (!err && ctrl->lc_ctype)
if (!(lc_ctype = xtrystrdup (ctrl->lc_ctype))) if (!(lc_ctype = xtrystrdup (ctrl->lc_ctype)))
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
if (!err && ctrl->lc_messages) if (!err && ctrl->lc_messages)
if (!(lc_messages = xtrystrdup (ctrl->lc_messages))) if (!(lc_messages = xtrystrdup (ctrl->lc_messages)))
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
if (err) if (err)
{ {
session_env_release (se); session_env_release (se);
@ -2142,7 +2142,7 @@ cmd_killagent (assuan_context_t ctx, char *line)
ctrl_t ctrl = assuan_get_pointer (ctx); ctrl_t ctrl = assuan_get_pointer (ctx);
(void)line; (void)line;
if (!opt.use_standard_socket) if (!opt.use_standard_socket)
return set_error (GPG_ERR_NOT_SUPPORTED, "no --use-standard-socket"); return set_error (GPG_ERR_NOT_SUPPORTED, "no --use-standard-socket");
@ -2168,7 +2168,7 @@ cmd_reloadagent (assuan_context_t ctx, char *line)
static const char hlp_getinfo[] = static const char hlp_getinfo[] =
"GETINFO <what>\n" "GETINFO <what>\n"
"\n" "\n"
"Multipurpose function to return a variety of information.\n" "Multipurpose function to return a variety of information.\n"
@ -2237,15 +2237,15 @@ cmd_getinfo (assuan_context_t ctx, char *line)
int iterator; int iterator;
const char *name, *value; const char *name, *value;
char *string; char *string;
iterator = 0; iterator = 0;
while ((name = session_env_list_stdenvnames (&iterator, NULL))) while ((name = session_env_list_stdenvnames (&iterator, NULL)))
{ {
value = session_env_getenv_or_default value = session_env_getenv_or_default
(line[5] == 't'? opt.startup_env:ctrl->session_env, name, NULL); (line[5] == 't'? opt.startup_env:ctrl->session_env, name, NULL);
if (value) if (value)
{ {
string = xtryasprintf ("%s=%s", name, value); string = xtryasprintf ("%s=%s", name, value);
if (!string) if (!string)
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
else else
@ -2308,7 +2308,7 @@ option_handler (assuan_context_t ctx, const char *key, const char *value)
{ {
/* The value is a version string telling us of which agent /* The value is a version string telling us of which agent
version the caller is aware of. */ version the caller is aware of. */
ctrl->server_local->allow_fully_canceled = ctrl->server_local->allow_fully_canceled =
gnupg_compare_version (value, "2.1.0"); gnupg_compare_version (value, "2.1.0");
} }
else if (!strcmp (key, "putenv")) else if (!strcmp (key, "putenv"))
@ -2378,7 +2378,7 @@ static void
post_cmd_notify (assuan_context_t ctx, gpg_error_t err) post_cmd_notify (assuan_context_t ctx, gpg_error_t err)
{ {
ctrl_t ctrl = assuan_get_pointer (ctx); ctrl_t ctrl = assuan_get_pointer (ctx);
(void)err; (void)err;
/* Switch off any I/O monitor controlled logging pausing. */ /* Switch off any I/O monitor controlled logging pausing. */
@ -2395,7 +2395,7 @@ io_monitor (assuan_context_t ctx, void *hook, int direction,
const char *line, size_t linelen) const char *line, size_t linelen)
{ {
ctrl_t ctrl = assuan_get_pointer (ctx); ctrl_t ctrl = assuan_get_pointer (ctx);
(void) hook; (void) hook;
/* Note that we only check for the uppercase name. This allows to /* Note that we only check for the uppercase name. This allows to
@ -2422,7 +2422,7 @@ command_has_option (const char *cmd, const char *cmdopt)
if (!strcmp (cmdopt, "repeat")) if (!strcmp (cmdopt, "repeat"))
return 1; return 1;
} }
return 0; return 0;
} }
@ -2456,8 +2456,8 @@ register_commands (assuan_context_t ctx)
{ "MARKTRUSTED", cmd_marktrusted, hlp_martrusted }, { "MARKTRUSTED", cmd_marktrusted, hlp_martrusted },
{ "LEARN", cmd_learn, hlp_learn }, { "LEARN", cmd_learn, hlp_learn },
{ "PASSWD", cmd_passwd, hlp_passwd }, { "PASSWD", cmd_passwd, hlp_passwd },
{ "INPUT", NULL }, { "INPUT", NULL },
{ "OUTPUT", NULL }, { "OUTPUT", NULL },
{ "SCD", cmd_scd, hlp_scd }, { "SCD", cmd_scd, hlp_scd },
{ "KEYWRAP_KEY", cmd_keywrap_key, hlp_keywrap_key }, { "KEYWRAP_KEY", cmd_keywrap_key, hlp_keywrap_key },
{ "IMPORT_KEY", cmd_import_key, hlp_import_key }, { "IMPORT_KEY", cmd_import_key, hlp_import_key },
@ -2478,7 +2478,7 @@ register_commands (assuan_context_t ctx)
table[i].help); table[i].help);
if (rc) if (rc)
return rc; return rc;
} }
assuan_register_post_cmd_notify (ctx, post_cmd_notify); assuan_register_post_cmd_notify (ctx, post_cmd_notify);
assuan_register_reset_notify (ctx, reset_notify); assuan_register_reset_notify (ctx, reset_notify);
assuan_register_option_handler (ctx, option_handler); assuan_register_option_handler (ctx, option_handler);
@ -2517,7 +2517,7 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
/* FIXME: Need to call assuan_sock_set_nonce for Windows. But /* FIXME: Need to call assuan_sock_set_nonce for Windows. But
this branch is currently not used. */ this branch is currently not used. */
} }
else else
{ {
rc = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED); rc = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED);
} }
@ -2556,7 +2556,7 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
log_info ("Assuan accept problem: %s\n", gpg_strerror (rc)); log_info ("Assuan accept problem: %s\n", gpg_strerror (rc));
break; break;
} }
rc = assuan_process (ctx); rc = assuan_process (ctx);
if (rc) if (rc)
{ {
@ -2584,4 +2584,3 @@ start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)
xfree (ctrl->server_local); xfree (ctrl->server_local);
ctrl->server_local = NULL; ctrl->server_local = NULL;
} }

View File

@ -19,12 +19,12 @@
#ifndef GNUPG_AGENT_CVT_OPENPGP_H #ifndef GNUPG_AGENT_CVT_OPENPGP_H
#define GNUPG_AGENT_CVT_OPENPGP_H #define GNUPG_AGENT_CVT_OPENPGP_H
gpg_error_t convert_from_openpgp (ctrl_t ctrl, gcry_sexp_t s_pgp, gpg_error_t convert_from_openpgp (ctrl_t ctrl, gcry_sexp_t s_pgp,
unsigned char *grip, const char *prompt, unsigned char *grip, const char *prompt,
const char *cache_nonce, const char *cache_nonce,
unsigned char **r_key, char **r_passphrase); unsigned char **r_key, char **r_passphrase);
gpg_error_t convert_to_openpgp (ctrl_t ctrl, gcry_sexp_t s_key, gpg_error_t convert_to_openpgp (ctrl_t ctrl, gcry_sexp_t s_key,
const char *passphrase, const char *passphrase,
unsigned char **r_transferkey, unsigned char **r_transferkey,
size_t *r_transferkeylen); size_t *r_transferkeylen);

View File

@ -1,4 +1,4 @@
/* divert-scd.c - divert operations to the scdaemon /* divert-scd.c - divert operations to the scdaemon
* Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc. * Copyright (C) 2002, 2003, 2009 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
@ -140,7 +140,7 @@ encode_md_for_card (const unsigned char *digest, size_t digestlen, int algo,
memcpy (frame+asnlen, digest, digestlen); memcpy (frame+asnlen, digest, digestlen);
if (DBG_CRYPTO) if (DBG_CRYPTO)
log_printhex ("encoded hash:", frame, asnlen+digestlen); log_printhex ("encoded hash:", frame, asnlen+digestlen);
*r_val = frame; *r_val = frame;
*r_len = asnlen+digestlen; *r_len = asnlen+digestlen;
return 0; return 0;
@ -170,11 +170,11 @@ encode_md_for_card (const unsigned char *digest, size_t digestlen, int algo,
Example: Example:
"|AN|Please enter the new security officer's PIN" "|AN|Please enter the new security officer's PIN"
The text "Please ..." will get displayed and the flags 'A' and 'N' The text "Please ..." will get displayed and the flags 'A' and 'N'
are considered. are considered.
*/ */
static int static int
getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf) getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
{ {
struct pin_entry_info_s *pi; struct pin_entry_info_s *pi;
@ -291,7 +291,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
prompt, NULL, pi2); prompt, NULL, pi2);
if (!rc && strcmp (pi->pin, pi2->pin)) if (!rc && strcmp (pi->pin, pi2->pin))
{ {
again_text = (resetcode? again_text = (resetcode?
N_("Reset Code not correctly repeated; try again"): N_("Reset Code not correctly repeated; try again"):
is_puk? is_puk?
N_("PUK not correctly repeated; try again"): N_("PUK not correctly repeated; try again"):
@ -307,7 +307,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
{ {
char *desc; char *desc;
if ( asprintf (&desc, if ( asprintf (&desc,
_("Please enter the PIN%s%s%s to unlock the card"), _("Please enter the PIN%s%s%s to unlock the card"),
info? " (`":"", info? " (`":"",
info? info:"", info? info:"",
info? "')":"") < 0) info? "')":"") < 0)
@ -329,7 +329,7 @@ getpin_cb (void *opaque, const char *info, char *buf, size_t maxbuf)
int int
divert_pksign (ctrl_t ctrl, divert_pksign (ctrl_t ctrl,
const unsigned char *digest, size_t digestlen, int algo, const unsigned char *digest, size_t digestlen, int algo,
const unsigned char *shadow_info, unsigned char **r_sig) const unsigned char *shadow_info, unsigned char **r_sig)
{ {
@ -376,7 +376,7 @@ divert_pksign (ctrl_t ctrl,
/* Decrypt the the value given asn an S-expression in CIPHER using the /* Decrypt the the value given asn an S-expression in CIPHER using the
key identified by SHADOW_INFO and return the plaintext in an key identified by SHADOW_INFO and return the plaintext in an
allocated buffer in R_BUF. */ allocated buffer in R_BUF. */
int int
divert_pkdecrypt (ctrl_t ctrl, divert_pkdecrypt (ctrl_t ctrl,
const unsigned char *cipher, const unsigned char *cipher,
const unsigned char *shadow_info, const unsigned char *shadow_info,
@ -397,28 +397,28 @@ divert_pkdecrypt (ctrl_t ctrl,
s++; s++;
n = snext (&s); n = snext (&s);
if (!n) if (!n)
return gpg_error (GPG_ERR_INV_SEXP); return gpg_error (GPG_ERR_INV_SEXP);
if (!smatch (&s, n, "enc-val")) if (!smatch (&s, n, "enc-val"))
return gpg_error (GPG_ERR_UNKNOWN_SEXP); return gpg_error (GPG_ERR_UNKNOWN_SEXP);
if (*s != '(') if (*s != '(')
return gpg_error (GPG_ERR_UNKNOWN_SEXP); return gpg_error (GPG_ERR_UNKNOWN_SEXP);
s++; s++;
n = snext (&s); n = snext (&s);
if (!n) if (!n)
return gpg_error (GPG_ERR_INV_SEXP); return gpg_error (GPG_ERR_INV_SEXP);
if (!smatch (&s, n, "rsa")) if (!smatch (&s, n, "rsa"))
return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM); return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
if (*s != '(') if (*s != '(')
return gpg_error (GPG_ERR_UNKNOWN_SEXP); return gpg_error (GPG_ERR_UNKNOWN_SEXP);
s++; s++;
n = snext (&s); n = snext (&s);
if (!n) if (!n)
return gpg_error (GPG_ERR_INV_SEXP); return gpg_error (GPG_ERR_INV_SEXP);
if (!smatch (&s, n, "a")) if (!smatch (&s, n, "a"))
return gpg_error (GPG_ERR_UNKNOWN_SEXP); return gpg_error (GPG_ERR_UNKNOWN_SEXP);
n = snext (&s); n = snext (&s);
if (!n) if (!n)
return gpg_error (GPG_ERR_UNKNOWN_SEXP); return gpg_error (GPG_ERR_UNKNOWN_SEXP);
ciphertext = s; ciphertext = s;
ciphertextlen = n; ciphertextlen = n;
@ -439,13 +439,8 @@ divert_pkdecrypt (ctrl_t ctrl,
} }
int int
divert_generic_cmd (ctrl_t ctrl, const char *cmdline, void *assuan_context) divert_generic_cmd (ctrl_t ctrl, const char *cmdline, void *assuan_context)
{ {
return agent_card_scd (ctrl, cmdline, getpin_cb, ctrl, assuan_context); return agent_card_scd (ctrl, cmdline, getpin_cb, ctrl, assuan_context);
} }

View File

@ -39,7 +39,7 @@
#endif #endif
/* Helper to pass data to the check callback of the unprotect function. */ /* Helper to pass data to the check callback of the unprotect function. */
struct try_unprotect_arg_s struct try_unprotect_arg_s
{ {
ctrl_t ctrl; ctrl_t ctrl;
const unsigned char *protected_key; const unsigned char *protected_key;
@ -59,7 +59,7 @@ agent_write_private_key (const unsigned char *grip,
char *fname; char *fname;
estream_t fp; estream_t fp;
char hexgrip[40+4+1]; char hexgrip[40+4+1];
bin2hex (grip, 20, hexgrip); bin2hex (grip, 20, hexgrip);
strcpy (hexgrip+40, ".key"); strcpy (hexgrip+40, ".key");
@ -73,8 +73,8 @@ agent_write_private_key (const unsigned char *grip,
} }
fp = es_fopen (fname, force? "wb,mode=-rw" : "wbx,mode=-rw"); fp = es_fopen (fname, force? "wb,mode=-rw" : "wbx,mode=-rw");
if (!fp) if (!fp)
{ {
gpg_error_t tmperr = gpg_error_from_syserror (); gpg_error_t tmperr = gpg_error_from_syserror ();
log_error ("can't create `%s': %s\n", fname, gpg_strerror (tmperr)); log_error ("can't create `%s': %s\n", fname, gpg_strerror (tmperr));
xfree (fname); xfree (fname);
@ -143,7 +143,7 @@ try_unprotect_cb (struct pin_entry_info_s *pi)
if (strcmp (now, tmptime) > 0 ) if (strcmp (now, tmptime) > 0 )
{ {
/* Passphrase "expired". */ /* Passphrase "expired". */
desc = xtryasprintf desc = xtryasprintf
(_("This passphrase has not been changed%%0A" (_("This passphrase has not been changed%%0A"
"since %.4s-%.2s-%.2s. Please change it now."), "since %.4s-%.2s-%.2s. Please change it now."),
protected_at, protected_at+4, protected_at+6); protected_at, protected_at+4, protected_at+6);
@ -254,7 +254,7 @@ modify_description (const char *in, const char *comment, char **result)
out_len++; out_len++;
} }
} }
if (!pass) if (!pass)
{ {
*result = out = xtrymalloc (out_len + 1); *result = out = xtrymalloc (out_len + 1);
@ -268,7 +268,7 @@ modify_description (const char *in, const char *comment, char **result)
return 0; return 0;
} }
/* Unprotect the canconical encoded S-expression key in KEYBUF. GRIP /* Unprotect the canconical encoded S-expression key in KEYBUF. GRIP
should be the hex encoded keygrip of that key to be used with the should be the hex encoded keygrip of that key to be used with the
@ -281,7 +281,7 @@ modify_description (const char *in, const char *comment, char **result)
passphrase. */ passphrase. */
static int static int
unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text, unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
unsigned char **keybuf, const unsigned char *grip, unsigned char **keybuf, const unsigned char *grip,
cache_mode_t cache_mode, lookup_ttl_t lookup_ttl, cache_mode_t cache_mode, lookup_ttl_t lookup_ttl,
char **r_passphrase) char **r_passphrase)
{ {
@ -294,14 +294,14 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
if (r_passphrase) if (r_passphrase)
*r_passphrase = NULL; *r_passphrase = NULL;
bin2hex (grip, 20, hexgrip); bin2hex (grip, 20, hexgrip);
/* Initially try to get it using a cache nonce. */ /* Initially try to get it using a cache nonce. */
if (cache_nonce) if (cache_nonce)
{ {
char *pw; char *pw;
pw = agent_get_cache (cache_nonce, CACHE_MODE_NONCE); pw = agent_get_cache (cache_nonce, CACHE_MODE_NONCE);
if (pw) if (pw)
{ {
@ -325,7 +325,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
if (cache_mode != CACHE_MODE_IGNORE) if (cache_mode != CACHE_MODE_IGNORE)
{ {
char *pw; char *pw;
retry: retry:
pw = agent_get_cache (hexgrip, cache_mode); pw = agent_get_cache (hexgrip, cache_mode);
if (pw) if (pw)
@ -362,7 +362,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
{ {
/* We need to give the other thread a chance to actually put /* We need to give the other thread a chance to actually put
it into the cache. */ it into the cache. */
pth_sleep (1); pth_sleep (1);
goto retry; goto retry;
} }
/* Timeout - better call pinentry now the plain way. */ /* Timeout - better call pinentry now the plain way. */
@ -391,7 +391,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
{ {
size_t canlen, erroff; size_t canlen, erroff;
gcry_sexp_t s_skey; gcry_sexp_t s_skey;
assert (arg.unprotected_key); assert (arg.unprotected_key);
canlen = gcry_sexp_canon_len (arg.unprotected_key, 0, NULL, NULL); canlen = gcry_sexp_canon_len (arg.unprotected_key, 0, NULL, NULL);
rc = gcry_sexp_sscan (&s_skey, &erroff, rc = gcry_sexp_sscan (&s_skey, &erroff,
@ -409,7 +409,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
gcry_sexp_release (s_skey); gcry_sexp_release (s_skey);
if (rc) if (rc)
{ {
log_error ("changing the passphrase failed: %s\n", log_error ("changing the passphrase failed: %s\n",
gpg_strerror (rc)); gpg_strerror (rc));
wipememory (arg.unprotected_key, canlen); wipememory (arg.unprotected_key, canlen);
xfree (arg.unprotected_key); xfree (arg.unprotected_key);
@ -419,7 +419,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
} }
else else
{ {
agent_put_cache (hexgrip, cache_mode, pi->pin, agent_put_cache (hexgrip, cache_mode, pi->pin,
lookup_ttl? lookup_ttl (hexgrip) : 0); lookup_ttl? lookup_ttl (hexgrip) : 0);
if (r_passphrase && *pi->pin) if (r_passphrase && *pi->pin)
*r_passphrase = xtrystrdup (pi->pin); *r_passphrase = xtrystrdup (pi->pin);
@ -446,7 +446,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
size_t buflen, erroff; size_t buflen, erroff;
gcry_sexp_t s_skey; gcry_sexp_t s_skey;
char hexgrip[40+4+1]; char hexgrip[40+4+1];
*result = NULL; *result = NULL;
bin2hex (grip, 20, hexgrip); bin2hex (grip, 20, hexgrip);
@ -462,7 +462,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
xfree (fname); xfree (fname);
return rc; return rc;
} }
if (fstat (es_fileno (fp), &st)) if (fstat (es_fileno (fp), &st))
{ {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
@ -489,7 +489,7 @@ read_key_file (const unsigned char *grip, gcry_sexp_t *result)
if (es_fread (buf, buflen, 1, fp) != 1) if (es_fread (buf, buflen, 1, fp) != 1)
{ {
rc = gpg_error_from_syserror (); rc = gpg_error_from_syserror ();
log_error ("error reading %zu bytes from `%s': %s\n", log_error ("error reading %zu bytes from `%s': %s\n",
buflen, fname, strerror (errno)); buflen, fname, strerror (errno));
xfree (fname); xfree (fname);
es_fclose (fp); es_fclose (fp);
@ -540,7 +540,7 @@ agent_key_from_file (ctrl_t ctrl, const char *cache_nonce,
size_t len, buflen, erroff; size_t len, buflen, erroff;
gcry_sexp_t s_skey; gcry_sexp_t s_skey;
int got_shadow_info = 0; int got_shadow_info = 0;
*result = NULL; *result = NULL;
if (shadow_info) if (shadow_info)
*shadow_info = NULL; *shadow_info = NULL;
@ -612,7 +612,7 @@ agent_key_from_file (ctrl_t ctrl, const char *cache_nonce,
log_error ("failed to unprotect the secret key: %s\n", log_error ("failed to unprotect the secret key: %s\n",
gpg_strerror (rc)); gpg_strerror (rc));
} }
gcry_sexp_release (comment_sexp); gcry_sexp_release (comment_sexp);
xfree (desc_text_final); xfree (desc_text_final);
} }
@ -753,7 +753,7 @@ key_parms_from_sexp (gcry_sexp_t s_key, gcry_sexp_t *r_list,
if (strlen (algoname) >= algonamesize) if (strlen (algoname) >= algonamesize)
return gpg_error (GPG_ERR_BUFFER_TOO_SHORT); return gpg_error (GPG_ERR_BUFFER_TOO_SHORT);
strcpy (r_algoname, algoname); strcpy (r_algoname, algoname);
} }
if (r_elems) if (r_elems)
{ {
if (strlen (elems) >= elemssize) if (strlen (elems) >= elemssize)
@ -765,14 +765,14 @@ key_parms_from_sexp (gcry_sexp_t s_key, gcry_sexp_t *r_list,
*r_list = list; *r_list = list;
else else
gcry_sexp_release (list); gcry_sexp_release (list);
return 0; return 0;
} }
/* Return the public key algorithm number if S_KEY is a DSA style key. /* Return the public key algorithm number if S_KEY is a DSA style key.
If it is not a DSA style key, return 0. */ If it is not a DSA style key, return 0. */
int int
agent_is_dsa_key (gcry_sexp_t s_key) agent_is_dsa_key (gcry_sexp_t s_key)
{ {
char algoname[6]; char algoname[6];
@ -798,7 +798,7 @@ agent_is_dsa_key (gcry_sexp_t s_key)
key database. On failure an error code is returned and NULL stored key database. On failure an error code is returned and NULL stored
at RESULT. */ at RESULT. */
gpg_error_t gpg_error_t
agent_public_key_from_file (ctrl_t ctrl, agent_public_key_from_file (ctrl_t ctrl,
const unsigned char *grip, const unsigned char *grip,
gcry_sexp_t *result) gcry_sexp_t *result)
{ {
@ -826,7 +826,7 @@ agent_public_key_from_file (ctrl_t ctrl,
if (err) if (err)
return err; return err;
err = key_parms_from_sexp (s_skey, &list, err = key_parms_from_sexp (s_skey, &list,
algoname, sizeof algoname, algoname, sizeof algoname,
elems, sizeof elems); elems, sizeof elems);
if (err) if (err)
@ -846,7 +846,7 @@ agent_public_key_from_file (ctrl_t ctrl,
return err; return err;
} }
for (idx=0, s=elems; *s; s++, idx++ ) for (idx=0, s=elems; *s; s++, idx++ )
{ {
l2 = gcry_sexp_find_token (list, s, 1); l2 = gcry_sexp_find_token (list, s, 1);
if (!l2) if (!l2)
@ -913,7 +913,7 @@ agent_public_key_from_file (ctrl_t ctrl,
argidx = 0; argidx = 0;
p = stpcpy (stpcpy (format, "(public-key("), algoname); p = stpcpy (stpcpy (format, "(public-key("), algoname);
for (idx=0, s=elems; *s; s++, idx++ ) for (idx=0, s=elems; *s; s++, idx++ )
{ {
*p++ = '('; *p++ = '(';
*p++ = *s; *p++ = *s;
@ -940,7 +940,7 @@ agent_public_key_from_file (ctrl_t ctrl,
*p = 0; *p = 0;
assert (argidx < DIM (args)); assert (argidx < DIM (args));
args[argidx] = NULL; args[argidx] = NULL;
err = gcry_sexp_build_array (&list, NULL, format, args); err = gcry_sexp_build_array (&list, NULL, format, args);
xfree (format); xfree (format);
for (i=0; array[i]; i++) for (i=0; array[i]; i++)
@ -964,7 +964,7 @@ agent_key_available (const unsigned char *grip)
int result; int result;
char *fname; char *fname;
char hexgrip[40+4+1]; char hexgrip[40+4+1];
bin2hex (grip, 20, hexgrip); bin2hex (grip, 20, hexgrip);
strcpy (hexgrip+40, ".key"); strcpy (hexgrip+40, ".key");
@ -990,7 +990,7 @@ agent_key_info_from_file (ctrl_t ctrl, const unsigned char *grip,
int keytype; int keytype;
(void)ctrl; (void)ctrl;
if (r_keytype) if (r_keytype)
*r_keytype = PRIVATE_KEY_UNKNOWN; *r_keytype = PRIVATE_KEY_UNKNOWN;
if (r_shadow_info) if (r_shadow_info)
@ -998,7 +998,7 @@ agent_key_info_from_file (ctrl_t ctrl, const unsigned char *grip,
{ {
gcry_sexp_t sexp; gcry_sexp_t sexp;
err = read_key_file (grip, &sexp); err = read_key_file (grip, &sexp);
if (err) if (err)
{ {
@ -1012,12 +1012,12 @@ agent_key_info_from_file (ctrl_t ctrl, const unsigned char *grip,
if (err) if (err)
return err; return err;
} }
keytype = agent_private_key_type (buf); keytype = agent_private_key_type (buf);
switch (keytype) switch (keytype)
{ {
case PRIVATE_KEY_CLEAR: case PRIVATE_KEY_CLEAR:
break; break;
case PRIVATE_KEY_PROTECTED: case PRIVATE_KEY_PROTECTED:
/* If we ever require it we could retrieve the comment fields /* If we ever require it we could retrieve the comment fields
from such a key. */ from such a key. */

View File

@ -37,7 +37,7 @@ store_key (gcry_sexp_t private, const char *passphrase, int force)
unsigned char *buf; unsigned char *buf;
size_t len; size_t len;
unsigned char grip[20]; unsigned char grip[20];
if ( !gcry_pk_get_keygrip (private, grip) ) if ( !gcry_pk_get_keygrip (private, grip) )
{ {
log_error ("can't calculate keygrip\n"); log_error ("can't calculate keygrip\n");
@ -146,7 +146,7 @@ check_passphrase_pattern (ctrl_t ctrl, const char *pw)
} }
static int static int
take_this_one_anyway2 (ctrl_t ctrl, const char *desc, const char *anyway_btn) take_this_one_anyway2 (ctrl_t ctrl, const char *desc, const char *anyway_btn)
{ {
gpg_error_t err; gpg_error_t err;
@ -164,7 +164,7 @@ take_this_one_anyway2 (ctrl_t ctrl, const char *desc, const char *anyway_btn)
} }
static int static int
take_this_one_anyway (ctrl_t ctrl, const char *desc) take_this_one_anyway (ctrl_t ctrl, const char *desc)
{ {
return take_this_one_anyway2 (ctrl, desc, _("Take this one anyway")); return take_this_one_anyway2 (ctrl, desc, _("Take this one anyway"));
@ -185,18 +185,18 @@ check_passphrase_constraints (ctrl_t ctrl, const char *pw, int silent)
if (!pw) if (!pw)
pw = ""; pw = "";
if (utf8_charcount (pw) < minlen ) if (utf8_charcount (pw) < minlen )
{ {
char *desc; char *desc;
if (silent) if (silent)
return gpg_error (GPG_ERR_INV_PASSPHRASE); return gpg_error (GPG_ERR_INV_PASSPHRASE);
desc = xtryasprintf desc = xtryasprintf
( ngettext ("Warning: You have entered an insecure passphrase.%%0A" ( ngettext ("Warning: You have entered an insecure passphrase.%%0A"
"A passphrase should be at least %u character long.", "A passphrase should be at least %u character long.",
"Warning: You have entered an insecure passphrase.%%0A" "Warning: You have entered an insecure passphrase.%%0A"
"A passphrase should be at least %u characters long.", "A passphrase should be at least %u characters long.",
minlen), minlen ); minlen), minlen );
if (!desc) if (!desc)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
@ -206,17 +206,17 @@ check_passphrase_constraints (ctrl_t ctrl, const char *pw, int silent)
return err; return err;
} }
if (nonalpha_count (pw) < minnonalpha ) if (nonalpha_count (pw) < minnonalpha )
{ {
char *desc; char *desc;
if (silent) if (silent)
return gpg_error (GPG_ERR_INV_PASSPHRASE); return gpg_error (GPG_ERR_INV_PASSPHRASE);
desc = xtryasprintf desc = xtryasprintf
( ngettext ("Warning: You have entered an insecure passphrase.%%0A" ( ngettext ("Warning: You have entered an insecure passphrase.%%0A"
"A passphrase should contain at least %u digit or%%0A" "A passphrase should contain at least %u digit or%%0A"
"special character.", "special character.",
"Warning: You have entered an insecure passphrase.%%0A" "Warning: You have entered an insecure passphrase.%%0A"
"A passphrase should contain at least %u digits or%%0A" "A passphrase should contain at least %u digits or%%0A"
"special characters.", "special characters.",
@ -259,7 +259,7 @@ check_passphrase_constraints (ctrl_t ctrl, const char *pw, int silent)
"this is in general a bad idea!%0A" "this is in general a bad idea!%0A"
"Please confirm that you do not want to " "Please confirm that you do not want to "
"have any protection on your key.")); "have any protection on your key."));
if (silent) if (silent)
return gpg_error (GPG_ERR_INV_PASSPHRASE); return gpg_error (GPG_ERR_INV_PASSPHRASE);
@ -300,7 +300,7 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
const char *text2 = _("Please re-enter this passphrase"); const char *text2 = _("Please re-enter this passphrase");
const char *initial_errtext = NULL; const char *initial_errtext = NULL;
struct pin_entry_info_s *pi, *pi2; struct pin_entry_info_s *pi, *pi2;
*r_passphrase = NULL; *r_passphrase = NULL;
pi = gcry_calloc_secure (2, sizeof (*pi) + 100); pi = gcry_calloc_secure (2, sizeof (*pi) + 100);
@ -336,7 +336,7 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
} }
} }
} }
if (!err && *pi->pin) if (!err && *pi->pin)
{ {
/* User wants a passphrase. */ /* User wants a passphrase. */
@ -357,7 +357,7 @@ agent_ask_new_passphrase (ctrl_t ctrl, const char *prompt,
int int
agent_genkey (ctrl_t ctrl, const char *cache_nonce, agent_genkey (ctrl_t ctrl, const char *cache_nonce,
const char *keyparam, size_t keyparamlen, int no_protection, const char *keyparam, size_t keyparamlen, int no_protection,
membuf_t *outbuf) membuf_t *outbuf)
{ {
gcry_sexp_t s_keyparam, s_key, s_private, s_public; gcry_sexp_t s_keyparam, s_key, s_private, s_public;
char *passphrase; char *passphrase;
@ -375,13 +375,13 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
/* Get the passphrase now, cause key generation may take a while. */ /* Get the passphrase now, cause key generation may take a while. */
if (no_protection || !cache_nonce) if (no_protection || !cache_nonce)
passphrase = NULL; passphrase = NULL;
else else
passphrase = agent_get_cache (cache_nonce, CACHE_MODE_NONCE); passphrase = agent_get_cache (cache_nonce, CACHE_MODE_NONCE);
if (passphrase || no_protection) if (passphrase || no_protection)
rc = 0; rc = 0;
else else
rc = agent_ask_new_passphrase (ctrl, rc = agent_ask_new_passphrase (ctrl,
_("Please enter the passphrase to%0A" _("Please enter the passphrase to%0A"
"to protect your new key"), "to protect your new key"),
&passphrase); &passphrase);
@ -416,7 +416,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
return gpg_error (GPG_ERR_INV_DATA); return gpg_error (GPG_ERR_INV_DATA);
} }
gcry_sexp_release (s_key); s_key = NULL; gcry_sexp_release (s_key); s_key = NULL;
/* store the secret key */ /* store the secret key */
if (DBG_CRYPTO) if (DBG_CRYPTO)
log_debug ("storing private key\n"); log_debug ("storing private key\n");
@ -474,7 +474,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
passphrase at that address. */ passphrase at that address. */
gpg_error_t gpg_error_t
agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey, agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey,
char **passphrase_addr) char **passphrase_addr)
{ {
gpg_error_t err; gpg_error_t err;
@ -492,7 +492,7 @@ agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey,
xfree (*passphrase_addr); xfree (*passphrase_addr);
*passphrase_addr = NULL; *passphrase_addr = NULL;
} }
err = agent_ask_new_passphrase (ctrl, err = agent_ask_new_passphrase (ctrl,
_("Please enter the new passphrase"), _("Please enter the new passphrase"),
&pass); &pass);
if (!err) if (!err)
@ -502,6 +502,6 @@ agent_protect_and_store (ctrl_t ctrl, gcry_sexp_t s_skey,
else else
xfree (pass); xfree (pass);
} }
return err; return err;
} }

View File

@ -53,7 +53,7 @@
#include "asshelp.h" #include "asshelp.h"
#include "../include/cipher.h" /* for PUBKEY_ALGO_ECDSA, PUBKEY_ALGO_ECDH */ #include "../include/cipher.h" /* for PUBKEY_ALGO_ECDSA, PUBKEY_ALGO_ECDH */
enum cmd_and_opt_values enum cmd_and_opt_values
{ aNull = 0, { aNull = 0,
oCsh = 'c', oCsh = 'c',
oQuiet = 'q', oQuiet = 'q',
@ -118,8 +118,8 @@ static ARGPARSE_OPTS opts[] = {
{ aGPGConfList, "gpgconf-list", 256, "@" }, { aGPGConfList, "gpgconf-list", 256, "@" },
{ aGPGConfTest, "gpgconf-test", 256, "@" }, { aGPGConfTest, "gpgconf-test", 256, "@" },
{ aUseStandardSocketP, "use-standard-socket-p", 256, "@" }, { aUseStandardSocketP, "use-standard-socket-p", 256, "@" },
{ 301, NULL, 0, N_("@Options:\n ") }, { 301, NULL, 0, N_("@Options:\n ") },
{ oServer, "server", 0, N_("run in server mode (foreground)") }, { oServer, "server", 0, N_("run in server mode (foreground)") },
@ -148,7 +148,7 @@ static ARGPARSE_OPTS opts[] = {
{ oFakedSystemTime, "faked-system-time", 2, "@" }, /* (epoch time) */ { oFakedSystemTime, "faked-system-time", 2, "@" }, /* (epoch time) */
{ oBatch, "batch", 0, "@" }, { oBatch, "batch", 0, "@" },
{ oHomedir, "homedir", 2, "@"}, { oHomedir, "homedir", 2, "@"},
{ oDisplay, "display", 2, "@" }, { oDisplay, "display", 2, "@" },
{ oTTYname, "ttyname", 2, "@" }, { oTTYname, "ttyname", 2, "@" },
@ -190,8 +190,8 @@ static ARGPARSE_OPTS opts[] = {
#define DEFAULT_CACHE_TTL_SSH (30*60) /* 30 minutes */ #define DEFAULT_CACHE_TTL_SSH (30*60) /* 30 minutes */
#define MAX_CACHE_TTL (120*60) /* 2 hours */ #define MAX_CACHE_TTL (120*60) /* 2 hours */
#define MAX_CACHE_TTL_SSH (120*60) /* 2 hours */ #define MAX_CACHE_TTL_SSH (120*60) /* 2 hours */
#define MIN_PASSPHRASE_LEN (8) #define MIN_PASSPHRASE_LEN (8)
#define MIN_PASSPHRASE_NONALPHA (1) #define MIN_PASSPHRASE_NONALPHA (1)
#define MAX_PASSPHRASE_DAYS (0) #define MAX_PASSPHRASE_DAYS (0)
/* The timer tick used for housekeeping stuff. For Windows we use a /* The timer tick used for housekeeping stuff. For Windows we use a
@ -204,7 +204,7 @@ static ARGPARSE_OPTS opts[] = {
# define CHECK_OWN_SOCKET_INTERVAL (0) /* Never */ # define CHECK_OWN_SOCKET_INTERVAL (0) /* Never */
#elif defined(HAVE_W32_SYSTEM) #elif defined(HAVE_W32_SYSTEM)
# define TIMERTICK_INTERVAL (4) # define TIMERTICK_INTERVAL (4)
# define CHECK_OWN_SOCKET_INTERVAL (60) # define CHECK_OWN_SOCKET_INTERVAL (60)
#else #else
# define TIMERTICK_INTERVAL (2) # define TIMERTICK_INTERVAL (2)
# define CHECK_OWN_SOCKET_INTERVAL (60) # define CHECK_OWN_SOCKET_INTERVAL (60)
@ -267,11 +267,11 @@ static pid_t parent_pid = (pid_t)(-1);
/* /*
Local prototypes. Local prototypes.
*/ */
static char *create_socket_name (char *standard_name, char *template); static char *create_socket_name (char *standard_name, char *template);
static gnupg_fd_t create_server_socket (char *name, int is_ssh, static gnupg_fd_t create_server_socket (char *name, int is_ssh,
assuan_sock_nonce_t *nonce); assuan_sock_nonce_t *nonce);
static void create_directories (void); static void create_directories (void);
@ -303,7 +303,7 @@ static unsigned long pth_thread_id (void)
/* /*
Functions. Functions.
*/ */
static char * static char *
@ -311,7 +311,7 @@ make_libversion (const char *libname, const char *(*getfnc)(const char*))
{ {
const char *s; const char *s;
char *result; char *result;
if (maybe_setuid) if (maybe_setuid)
{ {
gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */ gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
@ -353,7 +353,7 @@ my_strusage (int level)
case 41: p = _("Syntax: gpg-agent [options] [command [args]]\n" case 41: p = _("Syntax: gpg-agent [options] [command [args]]\n"
"Secret key management for GnuPG\n"); "Secret key management for GnuPG\n");
break; break;
default: p = NULL; default: p = NULL;
} }
return p; return p;
@ -390,7 +390,7 @@ set_debug (void)
/* Unless the "guru" string has been used we don't want to allow /* Unless the "guru" string has been used we don't want to allow
hashing debugging. The rationale is that people tend to hashing debugging. The rationale is that people tend to
select the highest debug value and would then clutter their select the highest debug value and would then clutter their
disk with debug files which may reveal confidential data. */ disk with debug files which may reveal confidential data. */
if (numok) if (numok)
opt.debug &= ~(DBG_HASHING_VALUE); opt.debug &= ~(DBG_HASHING_VALUE);
} }
@ -414,16 +414,16 @@ set_debug (void)
if (opt.debug) if (opt.debug)
log_info ("enabled debug flags:%s%s%s%s%s%s%s%s\n", log_info ("enabled debug flags:%s%s%s%s%s%s%s%s\n",
(opt.debug & DBG_COMMAND_VALUE)? " command":"", (opt.debug & DBG_COMMAND_VALUE)? " command":"",
(opt.debug & DBG_MPI_VALUE )? " mpi":"", (opt.debug & DBG_MPI_VALUE )? " mpi":"",
(opt.debug & DBG_CRYPTO_VALUE )? " crypto":"", (opt.debug & DBG_CRYPTO_VALUE )? " crypto":"",
(opt.debug & DBG_MEMORY_VALUE )? " memory":"", (opt.debug & DBG_MEMORY_VALUE )? " memory":"",
(opt.debug & DBG_CACHE_VALUE )? " cache":"", (opt.debug & DBG_CACHE_VALUE )? " cache":"",
(opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"", (opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"",
(opt.debug & DBG_HASHING_VALUE)? " hashing":"", (opt.debug & DBG_HASHING_VALUE)? " hashing":"",
(opt.debug & DBG_ASSUAN_VALUE )? " assuan":""); (opt.debug & DBG_ASSUAN_VALUE )? " assuan":"");
} }
/* Helper for cleanup to remove one socket with NAME. */ /* Helper for cleanup to remove one socket with NAME. */
static void static void
@ -443,7 +443,7 @@ remove_socket (char *name)
} }
*name = 0; *name = 0;
} }
} }
static void static void
cleanup (void) cleanup (void)
@ -452,7 +452,7 @@ cleanup (void)
if (done) if (done)
return; return;
done = 1; done = 1;
deinitialize_module_cache (); deinitialize_module_cache ();
remove_socket (socket_name); remove_socket (socket_name);
remove_socket (socket_name_ssh); remove_socket (socket_name_ssh);
@ -515,7 +515,7 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
break; break;
case oNoGrab: opt.no_grab = 1; break; case oNoGrab: opt.no_grab = 1; break;
case oPinentryProgram: opt.pinentry_program = pargs->r.ret_str; break; case oPinentryProgram: opt.pinentry_program = pargs->r.ret_str; break;
case oPinentryTouchFile: opt.pinentry_touch_file = pargs->r.ret_str; break; case oPinentryTouchFile: opt.pinentry_touch_file = pargs->r.ret_str; break;
case oScdaemonProgram: opt.scdaemon_program = pargs->r.ret_str; break; case oScdaemonProgram: opt.scdaemon_program = pargs->r.ret_str; break;
@ -525,19 +525,19 @@ parse_rereadable_options (ARGPARSE_ARGS *pargs, int reread)
case oDefCacheTTLSSH: opt.def_cache_ttl_ssh = pargs->r.ret_ulong; break; case oDefCacheTTLSSH: opt.def_cache_ttl_ssh = pargs->r.ret_ulong; break;
case oMaxCacheTTL: opt.max_cache_ttl = pargs->r.ret_ulong; break; case oMaxCacheTTL: opt.max_cache_ttl = pargs->r.ret_ulong; break;
case oMaxCacheTTLSSH: opt.max_cache_ttl_ssh = pargs->r.ret_ulong; break; case oMaxCacheTTLSSH: opt.max_cache_ttl_ssh = pargs->r.ret_ulong; break;
case oEnforcePassphraseConstraints: case oEnforcePassphraseConstraints:
opt.enforce_passphrase_constraints=1; opt.enforce_passphrase_constraints=1;
break; break;
case oMinPassphraseLen: opt.min_passphrase_len = pargs->r.ret_ulong; break; case oMinPassphraseLen: opt.min_passphrase_len = pargs->r.ret_ulong; break;
case oMinPassphraseNonalpha: case oMinPassphraseNonalpha:
opt.min_passphrase_nonalpha = pargs->r.ret_ulong; opt.min_passphrase_nonalpha = pargs->r.ret_ulong;
break; break;
case oCheckPassphrasePattern: case oCheckPassphrasePattern:
opt.check_passphrase_pattern = pargs->r.ret_str; opt.check_passphrase_pattern = pargs->r.ret_str;
break; break;
case oMaxPassphraseDays: case oMaxPassphraseDays:
opt.max_passphrase_days = pargs->r.ret_ulong; opt.max_passphrase_days = pargs->r.ret_ulong;
break; break;
case oEnablePassphraseHistory: case oEnablePassphraseHistory:
opt.enable_passhrase_history = 1; opt.enable_passhrase_history = 1;
@ -599,7 +599,7 @@ main (int argc, char **argv )
/* Please note that we may running SUID(ROOT), so be very CAREFUL /* Please note that we may running SUID(ROOT), so be very CAREFUL
when adding any stuff between here and the call to INIT_SECMEM() when adding any stuff between here and the call to INIT_SECMEM()
somewhere after the option parsing */ somewhere after the option parsing */
log_set_prefix ("gpg-agent", JNLIB_LOG_WITH_PREFIX|JNLIB_LOG_WITH_PID); log_set_prefix ("gpg-agent", JNLIB_LOG_WITH_PREFIX|JNLIB_LOG_WITH_PID);
/* Make sure that our subsystems are ready. */ /* Make sure that our subsystems are ready. */
i18n_init (); i18n_init ();
@ -644,7 +644,7 @@ main (int argc, char **argv )
#ifdef USE_STANDARD_SOCKET #ifdef USE_STANDARD_SOCKET
opt.use_standard_socket = 1; opt.use_standard_socket = 1;
#endif #endif
shell = getenv ("SHELL"); shell = getenv ("SHELL");
if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") ) if (shell && strlen (shell) >= 3 && !strcmp (shell+strlen (shell)-3, "csh") )
csh_style = 1; csh_style = 1;
@ -655,7 +655,7 @@ main (int argc, char **argv )
{ {
const char *s; const char *s;
int idx; int idx;
static const char *names[] = static const char *names[] =
{ "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL }; { "DISPLAY", "TERM", "XAUTHORITY", "PINENTRY_USER_DATA", NULL };
err = 0; err = 0;
@ -677,10 +677,10 @@ main (int argc, char **argv )
if (err) if (err)
log_fatal ("error recording startup environment: %s\n", log_fatal ("error recording startup environment: %s\n",
gpg_strerror (err)); gpg_strerror (err));
/* Fixme: Better use the locale function here. */ /* Fixme: Better use the locale function here. */
opt.startup_lc_ctype = getenv ("LC_CTYPE"); opt.startup_lc_ctype = getenv ("LC_CTYPE");
if (opt.startup_lc_ctype) if (opt.startup_lc_ctype)
opt.startup_lc_ctype = xstrdup (opt.startup_lc_ctype); opt.startup_lc_ctype = xstrdup (opt.startup_lc_ctype);
opt.startup_lc_messages = getenv ("LC_MESSAGES"); opt.startup_lc_messages = getenv ("LC_MESSAGES");
if (opt.startup_lc_messages) if (opt.startup_lc_messages)
@ -713,13 +713,13 @@ main (int argc, char **argv )
gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0); gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
maybe_setuid = 0; maybe_setuid = 0;
/* /*
Now we are now working under our real uid Now we are now working under our real uid
*/ */
if (default_config) if (default_config)
configname = make_filename (opt.homedir, "gpg-agent.conf", NULL ); configname = make_filename (opt.homedir, "gpg-agent.conf", NULL );
argc = orig_argc; argc = orig_argc;
argv = orig_argv; argv = orig_argv;
pargs.argc = &argc; pargs.argc = &argc;
@ -750,7 +750,7 @@ main (int argc, char **argv )
configname, strerror(errno) ); configname, strerror(errno) );
exit(2); exit(2);
} }
xfree (configname); xfree (configname);
configname = NULL; configname = NULL;
} }
if (parse_debug && configname ) if (parse_debug && configname )
@ -804,7 +804,7 @@ main (int argc, char **argv )
case oFakedSystemTime: case oFakedSystemTime:
{ {
time_t faked_time = isotime2epoch (pargs.r.ret_str); time_t faked_time = isotime2epoch (pargs.r.ret_str);
if (faked_time == (time_t)(-1)) if (faked_time == (time_t)(-1))
faked_time = (time_t)strtoul (pargs.r.ret_str, NULL, 10); faked_time = (time_t)strtoul (pargs.r.ret_str, NULL, 10);
gnupg_set_time (faked_time, 0); gnupg_set_time (faked_time, 0);
@ -838,7 +838,7 @@ main (int argc, char **argv )
configname = NULL; configname = NULL;
goto next_pass; goto next_pass;
} }
xfree (configname); xfree (configname);
configname = NULL; configname = NULL;
if (log_get_errorcount(0)) if (log_get_errorcount(0))
@ -894,7 +894,7 @@ main (int argc, char **argv )
initialize_module_call_pinentry (); initialize_module_call_pinentry ();
initialize_module_call_scd (); initialize_module_call_scd ();
initialize_module_trustlist (); initialize_module_trustlist ();
/* Try to create missing directories. */ /* Try to create missing directories. */
create_directories (); create_directories ();
@ -905,7 +905,7 @@ main (int argc, char **argv )
gnupg_sleep (debug_wait); gnupg_sleep (debug_wait);
log_debug ("... okay\n"); log_debug ("... okay\n");
} }
if (gpgconf_list == 3) if (gpgconf_list == 3)
{ {
if (opt.use_standard_socket && !opt.quiet) if (opt.use_standard_socket && !opt.quiet)
@ -944,21 +944,21 @@ main (int argc, char **argv )
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL ); GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL );
es_printf ("max-cache-ttl-ssh:%lu:%d:\n", es_printf ("max-cache-ttl-ssh:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL_SSH ); GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MAX_CACHE_TTL_SSH );
es_printf ("enforce-passphrase-constraints:%lu:\n", es_printf ("enforce-passphrase-constraints:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME); GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
es_printf ("min-passphrase-len:%lu:%d:\n", es_printf ("min-passphrase-len:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MIN_PASSPHRASE_LEN ); GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, MIN_PASSPHRASE_LEN );
es_printf ("min-passphrase-nonalpha:%lu:%d:\n", es_printf ("min-passphrase-nonalpha:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
MIN_PASSPHRASE_NONALPHA); MIN_PASSPHRASE_NONALPHA);
es_printf ("check-passphrase-pattern:%lu:\n", es_printf ("check-passphrase-pattern:%lu:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME); GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME);
es_printf ("max-passphrase-days:%lu:%d:\n", es_printf ("max-passphrase-days:%lu:%d:\n",
GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME, GC_OPT_FLAG_DEFAULT|GC_OPT_FLAG_RUNTIME,
MAX_PASSPHRASE_DAYS); MAX_PASSPHRASE_DAYS);
es_printf ("enable-passphrase-history:%lu:\n", es_printf ("enable-passphrase-history:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME); GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
es_printf ("no-grab:%lu:\n", es_printf ("no-grab:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME); GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
es_printf ("ignore-cache-for-signing:%lu:\n", es_printf ("ignore-cache-for-signing:%lu:\n",
GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME); GC_OPT_FLAG_NONE|GC_OPT_FLAG_RUNTIME);
@ -988,7 +988,7 @@ main (int argc, char **argv )
if (pipe_server) if (pipe_server)
{ {
/* This is the simple pipe based server */ /* This is the simple pipe based server */
ctrl_t ctrl; ctrl_t ctrl;
@ -1033,10 +1033,10 @@ main (int argc, char **argv )
/* Create the sockets. */ /* Create the sockets. */
socket_name = create_socket_name socket_name = create_socket_name
("S.gpg-agent", "gpg-XXXXXX/S.gpg-agent"); ("S.gpg-agent", "gpg-XXXXXX/S.gpg-agent");
if (opt.ssh_support) if (opt.ssh_support)
socket_name_ssh = create_socket_name socket_name_ssh = create_socket_name
("S.gpg-agent.ssh", "gpg-XXXXXX/S.gpg-agent.ssh"); ("S.gpg-agent.ssh", "gpg-XXXXXX/S.gpg-agent.ssh");
fd = create_server_socket (socket_name, 0, &socket_nonce); fd = create_server_socket (socket_name, 0, &socket_nonce);
@ -1057,12 +1057,12 @@ main (int argc, char **argv )
es_printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid); es_printf ("set GPG_AGENT_INFO=%s;%lu;1\n", socket_name, (ulong)pid);
#else /*!HAVE_W32_SYSTEM*/ #else /*!HAVE_W32_SYSTEM*/
pid = fork (); pid = fork ();
if (pid == (pid_t)-1) if (pid == (pid_t)-1)
{ {
log_fatal ("fork failed: %s\n", strerror (errno) ); log_fatal ("fork failed: %s\n", strerror (errno) );
exit (1); exit (1);
} }
else if (pid) else if (pid)
{ /* We are the parent */ { /* We are the parent */
char *infostr, *infostr_ssh_sock; char *infostr, *infostr_ssh_sock;
@ -1081,7 +1081,7 @@ main (int argc, char **argv )
signal mask. */ signal mask. */
if ( !pth_kill () ) if ( !pth_kill () )
log_error ("pth_kill failed in forked process\n"); log_error ("pth_kill failed in forked process\n");
#ifdef HAVE_SIGPROCMASK #ifdef HAVE_SIGPROCMASK
if (startup_signal_mask_valid) if (startup_signal_mask_valid)
{ {
@ -1091,7 +1091,7 @@ main (int argc, char **argv )
} }
else else
log_info ("no saved signal mask\n"); log_info ("no saved signal mask\n");
#endif /*HAVE_SIGPROCMASK*/ #endif /*HAVE_SIGPROCMASK*/
/* Create the info string: <name>:<pid>:<protocol_version> */ /* Create the info string: <name>:<pid>:<protocol_version> */
if (asprintf (&infostr, "GPG_AGENT_INFO=%s:%lu:1", if (asprintf (&infostr, "GPG_AGENT_INFO=%s:%lu:1",
@ -1120,7 +1120,7 @@ main (int argc, char **argv )
if (env_file_name) if (env_file_name)
{ {
estream_t fp; estream_t fp;
fp = es_fopen (env_file_name, "w,mode=-rw"); fp = es_fopen (env_file_name, "w,mode=-rw");
if (!fp) if (!fp)
log_error (_("error creating `%s': %s\n"), log_error (_("error creating `%s': %s\n"),
@ -1139,7 +1139,7 @@ main (int argc, char **argv )
} }
if (argc) if (argc)
{ /* Run the program given on the commandline. */ { /* Run the program given on the commandline. */
if (putenv (infostr)) if (putenv (infostr))
{ {
@ -1191,28 +1191,28 @@ main (int argc, char **argv )
infostr_ssh_sock); infostr_ssh_sock);
} }
} }
xfree (infostr); xfree (infostr);
if (opt.ssh_support) if (opt.ssh_support)
{ {
xfree (infostr_ssh_sock); xfree (infostr_ssh_sock);
} }
exit (0); exit (0);
} }
/*NOTREACHED*/ /*NOTREACHED*/
} /* End parent */ } /* End parent */
/* /*
This is the child This is the child
*/ */
/* Detach from tty and put process into a new session */ /* Detach from tty and put process into a new session */
if (!nodetach ) if (!nodetach )
{ {
int i; int i;
unsigned int oldflags; unsigned int oldflags;
/* Close stdin, stdout and stderr unless it is the log stream */ /* Close stdin, stdout and stderr unless it is the log stream */
for (i=0; i <= 2; i++) for (i=0; i <= 2; i++)
{ {
if (!log_test_fd (i) && i != fd ) if (!log_test_fd (i) && i != fd )
{ {
@ -1246,7 +1246,7 @@ main (int argc, char **argv )
{ {
struct sigaction sa; struct sigaction sa;
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sigemptyset (&sa.sa_mask); sigemptyset (&sa.sa_mask);
sa.sa_flags = 0; sa.sa_flags = 0;
@ -1258,7 +1258,7 @@ main (int argc, char **argv )
handle_connections (fd, opt.ssh_support ? fd_ssh : GNUPG_INVALID_FD); handle_connections (fd, opt.ssh_support ? fd_ssh : GNUPG_INVALID_FD);
assuan_sock_close (fd); assuan_sock_close (fd);
} }
return 0; return 0;
} }
@ -1300,11 +1300,11 @@ agent_init_default_ctrl (ctrl_t ctrl)
session_env_setenv (ctrl->session_env, "TERM", default_ttytype); session_env_setenv (ctrl->session_env, "TERM", default_ttytype);
session_env_setenv (ctrl->session_env, "XAUTHORITY", default_xauthority); session_env_setenv (ctrl->session_env, "XAUTHORITY", default_xauthority);
session_env_setenv (ctrl->session_env, "PINENTRY_USER_DATA", NULL); session_env_setenv (ctrl->session_env, "PINENTRY_USER_DATA", NULL);
if (ctrl->lc_ctype) if (ctrl->lc_ctype)
xfree (ctrl->lc_ctype); xfree (ctrl->lc_ctype);
ctrl->lc_ctype = default_lc_ctype? xtrystrdup (default_lc_ctype) : NULL; ctrl->lc_ctype = default_lc_ctype? xtrystrdup (default_lc_ctype) : NULL;
if (ctrl->lc_messages) if (ctrl->lc_messages)
xfree (ctrl->lc_messages); xfree (ctrl->lc_messages);
ctrl->lc_messages = default_lc_messages? xtrystrdup (default_lc_messages) ctrl->lc_messages = default_lc_messages? xtrystrdup (default_lc_messages)
@ -1327,7 +1327,7 @@ agent_deinit_default_ctrl (ctrl_t ctrl)
/* Reread parts of the configuration. Note, that this function is /* Reread parts of the configuration. Note, that this function is
obviously not thread-safe and should only be called from the PTH obviously not thread-safe and should only be called from the PTH
signal handler. signal handler.
Fixme: Due to the way the argument parsing works, we create a Fixme: Due to the way the argument parsing works, we create a
memory leak here for all string type arguments. There is currently memory leak here for all string type arguments. There is currently
@ -1417,7 +1417,7 @@ get_agent_scd_notify_event (void)
log_error ("can't create scd notify event: %s\n", w32_strerror (-1) ); log_error ("can't create scd notify event: %s\n", w32_strerror (-1) );
else if (!DuplicateHandle (GetCurrentProcess(), h, else if (!DuplicateHandle (GetCurrentProcess(), h,
GetCurrentProcess(), &h2, GetCurrentProcess(), &h2,
EVENT_MODIFY_STATE|SYNCHRONIZE, TRUE, 0)) EVENT_MODIFY_STATE|SYNCHRONIZE, TRUE, 0))
{ {
log_error ("setting syncronize for scd notify event failed: %s\n", log_error ("setting syncronize for scd notify event failed: %s\n",
w32_strerror (-1) ); w32_strerror (-1) );
@ -1509,7 +1509,7 @@ create_server_socket (char *name, int is_ssh, assuan_sock_nonce_t *nonce)
agent_exit (2); agent_exit (2);
} }
serv_addr = xmalloc (sizeof (*serv_addr)); serv_addr = xmalloc (sizeof (*serv_addr));
memset (serv_addr, 0, sizeof *serv_addr); memset (serv_addr, 0, sizeof *serv_addr);
serv_addr->sun_family = AF_UNIX; serv_addr->sun_family = AF_UNIX;
if (strlen (name) + 1 >= sizeof (serv_addr->sun_path)) if (strlen (name) + 1 >= sizeof (serv_addr->sun_path))
@ -1523,7 +1523,7 @@ create_server_socket (char *name, int is_ssh, assuan_sock_nonce_t *nonce)
/* Our error code mapping on W32CE returns EEXIST thus we also test /* Our error code mapping on W32CE returns EEXIST thus we also test
for this. */ for this. */
if (opt.use_standard_socket && rc == -1 if (opt.use_standard_socket && rc == -1
&& (errno == EADDRINUSE && (errno == EADDRINUSE
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
|| errno == EEXIST || errno == EEXIST
@ -1540,7 +1540,7 @@ create_server_socket (char *name, int is_ssh, assuan_sock_nonce_t *nonce)
a hang. */ a hang. */
if (!is_ssh && !check_for_running_agent (1, 1)) if (!is_ssh && !check_for_running_agent (1, 1))
{ {
log_set_prefix (NULL, JNLIB_LOG_WITH_PREFIX); log_set_prefix (NULL, JNLIB_LOG_WITH_PREFIX);
log_set_file (NULL); log_set_file (NULL);
log_error (_("a gpg-agent is already running - " log_error (_("a gpg-agent is already running - "
"not starting a new one\n")); "not starting a new one\n"));
@ -1551,7 +1551,7 @@ create_server_socket (char *name, int is_ssh, assuan_sock_nonce_t *nonce)
gnupg_remove (name); gnupg_remove (name);
rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len); rc = assuan_sock_bind (fd, (struct sockaddr*) serv_addr, len);
} }
if (rc != -1 if (rc != -1
&& (rc=assuan_sock_get_nonce ((struct sockaddr*)serv_addr, len, nonce))) && (rc=assuan_sock_get_nonce ((struct sockaddr*)serv_addr, len, nonce)))
log_error (_("error getting nonce for the socket\n")); log_error (_("error getting nonce for the socket\n"));
if (rc == -1) if (rc == -1)
@ -1559,9 +1559,9 @@ create_server_socket (char *name, int is_ssh, assuan_sock_nonce_t *nonce)
/* We use gpg_strerror here because it allows us to get strings /* We use gpg_strerror here because it allows us to get strings
for some W32 socket error codes. */ for some W32 socket error codes. */
log_error (_("error binding socket to `%s': %s\n"), log_error (_("error binding socket to `%s': %s\n"),
serv_addr->sun_path, serv_addr->sun_path,
gpg_strerror (gpg_error_from_errno (errno))); gpg_strerror (gpg_error_from_errno (errno)));
assuan_sock_close (fd); assuan_sock_close (fd);
if (opt.use_standard_socket) if (opt.use_standard_socket)
*name = 0; /* Inhibit removal of the socket by cleanup(). */ *name = 0; /* Inhibit removal of the socket by cleanup(). */
@ -1574,7 +1574,7 @@ create_server_socket (char *name, int is_ssh, assuan_sock_nonce_t *nonce)
assuan_sock_close (fd); assuan_sock_close (fd);
agent_exit (2); agent_exit (2);
} }
if (opt.verbose) if (opt.verbose)
log_info (_("listening on socket `%s'\n"), serv_addr->sun_path); log_info (_("listening on socket `%s'\n"), serv_addr->sun_path);
@ -1636,7 +1636,7 @@ create_directories (void)
if (gnupg_mkdir (home, "-rwx")) if (gnupg_mkdir (home, "-rwx"))
log_error (_("can't create directory `%s': %s\n"), log_error (_("can't create directory `%s': %s\n"),
home, strerror (errno) ); home, strerror (errno) );
else else
{ {
if (!opt.quiet) if (!opt.quiet)
log_info (_("directory `%s' created\n"), home); log_info (_("directory `%s' created\n"), home);
@ -1688,7 +1688,7 @@ handle_tick (void)
} }
} }
#endif /*HAVE_W32_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/
/* Code to be run from time to time. */ /* Code to be run from time to time. */
#if CHECK_OWN_SOCKET_INTERVAL > 0 #if CHECK_OWN_SOCKET_INTERVAL > 0
if (last_minute + CHECK_OWN_SOCKET_INTERVAL <= time (NULL)) if (last_minute + CHECK_OWN_SOCKET_INTERVAL <= time (NULL))
@ -1733,7 +1733,7 @@ handle_signal (int signo)
case SIGHUP: case SIGHUP:
agent_sighup_action (); agent_sighup_action ();
break; break;
case SIGUSR1: case SIGUSR1:
log_info ("SIGUSR1 received - printing internal information:\n"); log_info ("SIGUSR1 received - printing internal information:\n");
/* Fixme: We need to see how to integrate pth dumping into our /* Fixme: We need to see how to integrate pth dumping into our
@ -1742,7 +1742,7 @@ handle_signal (int signo)
agent_query_dump_state (); agent_query_dump_state ();
agent_scd_dump_state (); agent_scd_dump_state ();
break; break;
case SIGUSR2: case SIGUSR2:
agent_sigusr2_action (); agent_sigusr2_action ();
break; break;
@ -1762,7 +1762,7 @@ handle_signal (int signo)
agent_exit (0); agent_exit (0);
} }
break; break;
case SIGINT: case SIGINT:
log_info ("SIGINT received - immediate shutdown\n"); log_info ("SIGINT received - immediate shutdown\n");
log_info( "%s %s stopped\n", strusage(11), strusage(13)); log_info( "%s %s stopped\n", strusage(11), strusage(13));
@ -1778,12 +1778,12 @@ handle_signal (int signo)
/* Check the nonce on a new connection. This is a NOP unless we we /* Check the nonce on a new connection. This is a NOP unless we we
are using our Unix domain socket emulation under Windows. */ are using our Unix domain socket emulation under Windows. */
static int static int
check_nonce (ctrl_t ctrl, assuan_sock_nonce_t *nonce) check_nonce (ctrl_t ctrl, assuan_sock_nonce_t *nonce)
{ {
if (assuan_sock_check_nonce (ctrl->thread_startup.fd, nonce)) if (assuan_sock_check_nonce (ctrl->thread_startup.fd, nonce))
{ {
log_info (_("error reading nonce on fd %d: %s\n"), log_info (_("error reading nonce on fd %d: %s\n"),
FD2INT(ctrl->thread_startup.fd), strerror (errno)); FD2INT(ctrl->thread_startup.fd), strerror (errno));
assuan_sock_close (ctrl->thread_startup.fd); assuan_sock_close (ctrl->thread_startup.fd);
xfree (ctrl); xfree (ctrl);
@ -1808,14 +1808,14 @@ start_connection_thread (void *arg)
agent_init_default_ctrl (ctrl); agent_init_default_ctrl (ctrl);
if (opt.verbose) if (opt.verbose)
log_info (_("handler 0x%lx for fd %d started\n"), log_info (_("handler 0x%lx for fd %d started\n"),
pth_thread_id (), FD2INT(ctrl->thread_startup.fd)); pth_thread_id (), FD2INT(ctrl->thread_startup.fd));
start_command_handler (ctrl, GNUPG_INVALID_FD, ctrl->thread_startup.fd); start_command_handler (ctrl, GNUPG_INVALID_FD, ctrl->thread_startup.fd);
if (opt.verbose) if (opt.verbose)
log_info (_("handler 0x%lx for fd %d terminated\n"), log_info (_("handler 0x%lx for fd %d terminated\n"),
pth_thread_id (), FD2INT(ctrl->thread_startup.fd)); pth_thread_id (), FD2INT(ctrl->thread_startup.fd));
agent_deinit_default_ctrl (ctrl); agent_deinit_default_ctrl (ctrl);
xfree (ctrl); xfree (ctrl);
return NULL; return NULL;
@ -1840,7 +1840,7 @@ start_connection_thread_ssh (void *arg)
if (opt.verbose) if (opt.verbose)
log_info (_("ssh handler 0x%lx for fd %d terminated\n"), log_info (_("ssh handler 0x%lx for fd %d terminated\n"),
pth_thread_id (), FD2INT(ctrl->thread_startup.fd)); pth_thread_id (), FD2INT(ctrl->thread_startup.fd));
agent_deinit_default_ctrl (ctrl); agent_deinit_default_ctrl (ctrl);
xfree (ctrl); xfree (ctrl);
return NULL; return NULL;
@ -1886,7 +1886,7 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
sa.sa_handler = SIG_IGN; sa.sa_handler = SIG_IGN;
sa.sa_flags = 0; sa.sa_flags = 0;
sigaction (mysigs[i], &sa, NULL); sigaction (mysigs[i], &sa, NULL);
sigaddset (&sigs, mysigs[i]); sigaddset (&sigs, mysigs[i]);
} }
} }
@ -2035,7 +2035,7 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
xfree (ctrl); xfree (ctrl);
assuan_sock_close (fd); assuan_sock_close (fd);
} }
else else
{ {
char threadname[50]; char threadname[50];
@ -2055,7 +2055,7 @@ handle_connections (gnupg_fd_t listen_fd, gnupg_fd_t listen_fd_ssh)
fd = GNUPG_INVALID_FD; fd = GNUPG_INVALID_FD;
} }
if (!shutdown_pending && listen_fd_ssh != GNUPG_INVALID_FD if (!shutdown_pending && listen_fd_ssh != GNUPG_INVALID_FD
&& FD_ISSET ( FD2INT (listen_fd_ssh), &read_fdset)) && FD_ISSET ( FD2INT (listen_fd_ssh), &read_fdset))
{ {
ctrl_t ctrl; ctrl_t ctrl;
@ -2148,7 +2148,7 @@ check_own_socket_thread (void *arg)
log_error ("can't connect my own socket: %s\n", gpg_strerror (rc)); log_error ("can't connect my own socket: %s\n", gpg_strerror (rc));
goto leave; goto leave;
} }
init_membuf (&mb, 100); init_membuf (&mb, 100);
rc = assuan_transact (ctx, "GETINFO pid", check_own_socket_pid_cb, &mb, rc = assuan_transact (ctx, "GETINFO pid", check_own_socket_pid_cb, &mb,
NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL);
@ -2156,7 +2156,7 @@ check_own_socket_thread (void *arg)
buffer = get_membuf (&mb, NULL); buffer = get_membuf (&mb, NULL);
if (rc || !buffer) if (rc || !buffer)
{ {
log_error ("sending command \"%s\" to my own socket failed: %s\n", log_error ("sending command \"%s\" to my own socket failed: %s\n",
"GETINFO pid", gpg_strerror (rc)); "GETINFO pid", gpg_strerror (rc));
rc = 1; rc = 1;
} }
@ -2167,7 +2167,7 @@ check_own_socket_thread (void *arg)
} }
else if (opt.verbose > 1) else if (opt.verbose > 1)
log_error ("socket is still served by this server\n"); log_error ("socket is still served by this server\n");
xfree (buffer); xfree (buffer);
leave: leave:

View File

@ -58,7 +58,7 @@ keys is in canonical representation[3]:
(u #304559a..[some bytes not shown]..9b#) (u #304559a..[some bytes not shown]..9b#)
) )
(uri http://foo.bar x-foo:whatever_you_want) (uri http://foo.bar x-foo:whatever_you_want)
) )
Protected Private Key Format Protected Private Key Format
@ -74,7 +74,7 @@ A protected key is like this:
) )
(uri http://foo.bar x-foo:whatever_you_want) (uri http://foo.bar x-foo:whatever_you_want)
(comment whatever) (comment whatever)
) )
In this scheme the encrypted_octet_string is encrypted according to In this scheme the encrypted_octet_string is encrypted according to
@ -107,13 +107,13 @@ representation) after decryption:
(d #046129F..[some bytes not shown]..81#) (d #046129F..[some bytes not shown]..81#)
(p #00e861b..[some bytes not shown]..f1#) (p #00e861b..[some bytes not shown]..f1#)
(q #00f7a7c..[some bytes not shown]..61#) (q #00f7a7c..[some bytes not shown]..61#)
(u #304559a..[some bytes not shown]..9b#) (u #304559a..[some bytes not shown]..9b#)
) )
(hash sha1 #...[hashvalue]...#) (hash sha1 #...[hashvalue]...#)
) )
For padding reasons, random bytes are appended to this list - they can For padding reasons, random bytes are appended to this list - they can
easily be stripped by looking for the end of the list. easily be stripped by looking for the end of the list.
The hash is calculated on the concatenation of the public key and The hash is calculated on the concatenation of the public key and
secret key parameter lists: i.e it is required to hash the secret key parameter lists: i.e it is required to hash the
@ -150,7 +150,7 @@ to keys stored on a token:
) )
(uri http://foo.bar x-foo:whatever_you_want) (uri http://foo.bar x-foo:whatever_you_want)
(comment whatever) (comment whatever)
) )
The currently used protocol is "ti-v1" (token info version 1). The The currently used protocol is "ti-v1" (token info version 1). The
second list with the information has this layout: second list with the information has this layout:
@ -174,7 +174,7 @@ This format is used to transfer keys between gpg and gpg-agent.
* V is the packet version number (3 or 4). * V is the packet version number (3 or 4).
* PUBKEYALGO is a Libgcrypt algo name * PUBKEYALGO is a Libgcrypt algo name
* P1 .. PN are the parameters; the public parameters are never encrypted * P1 .. PN are the parameters; the public parameters are never encrypted
the secrect key parameters are encrypted if the "protection" list is the secrect key parameters are encrypted if the "protection" list is
given. To make this more explicit each parameter is preceded by a given. To make this more explicit each parameter is preceded by a
@ -215,7 +215,7 @@ for the passphrase storage the name "pw-default.dat" is suggested.
(protected mode (parms) encrypted_octet_string) (protected mode (parms) encrypted_octet_string)
(protected-at <isotimestamp>) (protected-at <isotimestamp>)
) )
) )
After decryption the encrypted_octet_string yields this S-expression: After decryption the encrypted_octet_string yields this S-expression:
@ -224,7 +224,7 @@ After decryption the encrypted_octet_string yields this S-expression:
(value key_1 value_1) (value key_1 value_1)
(value key_2 value_2) (value key_2 value_2)
(value key_n value_n) (value key_n value_n)
) )
(hash sha1 #...[hashvalue]...#) (hash sha1 #...[hashvalue]...#)
) )
@ -260,7 +260,7 @@ Example:
(protected mode (parms) encrypted_octet_string) (protected mode (parms) encrypted_octet_string)
(protected-at "20100915T111722") (protected-at "20100915T111722")
) )
) )
with "encrypted_octet_string" decoding to: with "encrypted_octet_string" decoding to:
@ -269,7 +269,7 @@ with "encrypted_octet_string" decoding to:
(value 4:1002 "signal flags at the lock") (value 4:1002 "signal flags at the lock")
(value 4:1001 "taocp") (value 4:1001 "taocp")
(value 1:0 "premature optimization is the root of all evil") (value 1:0 "premature optimization is the root of all evil")
) )
(hash sha1 #0102030405060708091011121314151617181920#) (hash sha1 #0102030405060708091011121314151617181920#)
) )

View File

@ -32,7 +32,7 @@
/* Structures used by the callback mechanism to convey information /* Structures used by the callback mechanism to convey information
pertaining to key pairs. */ pertaining to key pairs. */
struct keypair_info_s struct keypair_info_s
{ {
struct keypair_info_s *next; struct keypair_info_s *next;
int no_cert; int no_cert;
@ -44,7 +44,7 @@ struct keypair_info_s
}; };
typedef struct keypair_info_s *KEYPAIR_INFO; typedef struct keypair_info_s *KEYPAIR_INFO;
struct kpinfo_cb_parm_s struct kpinfo_cb_parm_s
{ {
ctrl_t ctrl; ctrl_t ctrl;
int error; int error;
@ -56,13 +56,13 @@ struct kpinfo_cb_parm_s
pertaining to certificates. */ pertaining to certificates. */
struct certinfo_s { struct certinfo_s {
struct certinfo_s *next; struct certinfo_s *next;
int type; int type;
int done; int done;
char id[1]; char id[1];
}; };
typedef struct certinfo_s *CERTINFO; typedef struct certinfo_s *CERTINFO;
struct certinfo_cb_parm_s struct certinfo_cb_parm_s
{ {
ctrl_t ctrl; ctrl_t ctrl;
int error; int error;
@ -75,9 +75,9 @@ struct certinfo_cb_parm_s
struct sinfo_s { struct sinfo_s {
struct sinfo_s *next; struct sinfo_s *next;
char *data; /* Points into keyword. */ char *data; /* Points into keyword. */
char keyword[1]; char keyword[1];
}; };
typedef struct sinfo_s *SINFO; typedef struct sinfo_s *SINFO;
struct sinfo_cb_parm_s { struct sinfo_cb_parm_s {
int error; int error;
@ -172,7 +172,7 @@ kpinfo_cb (void *opaque, const char *line)
return; return;
} }
*p = 0; /* ignore trailing stuff */ *p = 0; /* ignore trailing stuff */
/* store it */ /* store it */
item->next = parm->info; item->next = parm->info;
parm->info = item; parm->info = item;
@ -202,7 +202,7 @@ certinfo_cb (void *opaque, const char *line)
for (pend = p; *pend && !spacep (pend); pend++) for (pend = p; *pend && !spacep (pend); pend++)
; ;
if (p == pend || !*p) if (p == pend || !*p)
{ {
parm->error = gpg_error (GPG_ERR_INV_RESPONSE); parm->error = gpg_error (GPG_ERR_INV_RESPONSE);
return; return;
} }
@ -258,7 +258,7 @@ send_cert_back (ctrl_t ctrl, const char *id, void *assuan_context)
int rc; int rc;
char *derbuf; char *derbuf;
size_t derbuflen; size_t derbuflen;
rc = agent_card_readcert (ctrl, id, &derbuf, &derbuflen); rc = agent_card_readcert (ctrl, id, &derbuf, &derbuflen);
if (rc) if (rc)
{ {
@ -312,7 +312,7 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
unsigned char grip[20]; unsigned char grip[20];
char *p; char *p;
int i; int i;
static int certtype_list[] = { static int certtype_list[] = {
111, /* Root CA */ 111, /* Root CA */
101, /* trusted */ 101, /* trusted */
102, /* useful */ 102, /* useful */
@ -344,7 +344,7 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
log_debug ("agent_card_learn failed: %s\n", gpg_strerror (rc)); log_debug ("agent_card_learn failed: %s\n", gpg_strerror (rc));
goto leave; goto leave;
} }
log_info ("card has S/N: %s\n", serialno); log_info ("card has S/N: %s\n", serialno);
/* Pass on all the collected status information. */ /* Pass on all the collected status information. */
@ -368,7 +368,7 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
if (opt.verbose) if (opt.verbose)
log_info (" id: %s (type=%d)\n", log_info (" id: %s (type=%d)\n",
citem->id, citem->type); citem->id, citem->type);
if (assuan_context) if (assuan_context)
{ {
rc = send_cert_back (ctrl, citem->id, assuan_context); rc = send_cert_back (ctrl, citem->id, assuan_context);
@ -378,7 +378,7 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
} }
} }
} }
for (item = parm.info; item; item = item->next) for (item = parm.info; item; item = item->next)
{ {
unsigned char *pubkey, *shdkey; unsigned char *pubkey, *shdkey;
@ -398,10 +398,10 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
for (p=item->hexgrip, i=0; i < 20; p += 2, i++) for (p=item->hexgrip, i=0; i < 20; p += 2, i++)
grip[i] = xtoi_2 (p); grip[i] = xtoi_2 (p);
if (!agent_key_available (grip)) if (!agent_key_available (grip))
continue; /* The key is already available. */ continue; /* The key is already available. */
/* Unknown key - store it. */ /* Unknown key - store it. */
rc = agent_card_readkey (ctrl, item->id, &pubkey); rc = agent_card_readkey (ctrl, item->id, &pubkey);
if (rc) if (rc)
@ -440,11 +440,11 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
if (opt.verbose) if (opt.verbose)
log_info ("stored\n"); log_info ("stored\n");
if (assuan_context) if (assuan_context)
{ {
CERTINFO citem; CERTINFO citem;
/* only send the certificate if we have not done so before */ /* only send the certificate if we have not done so before */
for (citem = cparm.info; citem; citem = citem->next) for (citem = cparm.info; citem; citem = citem->next)
{ {
@ -460,7 +460,7 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
} }
} }
leave: leave:
xfree (serialno); xfree (serialno);
release_keypair_info (parm.info); release_keypair_info (parm.info);
@ -468,5 +468,3 @@ agent_handle_learn (ctrl_t ctrl, void *assuan_context)
release_sinfo (sparm.info); release_sinfo (sparm.info);
return rc; return rc;
} }

View File

@ -36,7 +36,7 @@
int int
agent_pkdecrypt (ctrl_t ctrl, const char *desc_text, agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
const unsigned char *ciphertext, size_t ciphertextlen, const unsigned char *ciphertext, size_t ciphertextlen,
membuf_t *outbuf) membuf_t *outbuf)
{ {
gcry_sexp_t s_skey = NULL, s_cipher = NULL, s_plain = NULL; gcry_sexp_t s_skey = NULL, s_cipher = NULL, s_plain = NULL;
unsigned char *shadow_info = NULL; unsigned char *shadow_info = NULL;
@ -136,7 +136,7 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
put_membuf (outbuf, buf, len); put_membuf (outbuf, buf, len);
put_membuf (outbuf, ")", 2); put_membuf (outbuf, ")", 2);
} }
} }
leave: leave:
@ -147,5 +147,3 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
xfree (shadow_info); xfree (shadow_info);
return rc; return rc;
} }

View File

@ -43,13 +43,13 @@ do_encode_md (const byte * md, size_t mdlen, int algo, gcry_sexp_t * r_hash,
const char *s; const char *s;
char tmp[16+1]; char tmp[16+1];
int i; int i;
s = gcry_md_algo_name (algo); s = gcry_md_algo_name (algo);
if (s && strlen (s) < 16) if (s && strlen (s) < 16)
{ {
for (i=0; i < strlen (s); i++) for (i=0; i < strlen (s); i++)
tmp[i] = tolower (s[i]); tmp[i] = tolower (s[i]);
tmp[i] = '\0'; tmp[i] = '\0';
} }
rc = gcry_sexp_build (&hash, NULL, rc = gcry_sexp_build (&hash, NULL,
@ -59,7 +59,7 @@ do_encode_md (const byte * md, size_t mdlen, int algo, gcry_sexp_t * r_hash,
else else
{ {
gcry_mpi_t mpi; gcry_mpi_t mpi;
rc = gcry_mpi_scan (&mpi, GCRYMPI_FMT_USG, md, mdlen, NULL); rc = gcry_mpi_scan (&mpi, GCRYMPI_FMT_USG, md, mdlen, NULL);
if (! rc) if (! rc)
{ {
@ -68,11 +68,11 @@ do_encode_md (const byte * md, size_t mdlen, int algo, gcry_sexp_t * r_hash,
mpi); mpi);
gcry_mpi_release (mpi); gcry_mpi_release (mpi);
} }
} }
*r_hash = hash; *r_hash = hash;
return rc; return rc;
} }
@ -131,7 +131,7 @@ do_encode_dsa (const byte *md, size_t mdlen, int dsaalgo, gcry_sexp_t pkey,
qbits = get_dsa_qbits (pkey); qbits = get_dsa_qbits (pkey);
else else
return gpg_error (GPG_ERR_WRONG_PUBKEY_ALGO); return gpg_error (GPG_ERR_WRONG_PUBKEY_ALGO);
if ((qbits%8)) if ((qbits%8))
{ {
log_error (_("DSA requires the hash length to be a" log_error (_("DSA requires the hash length to be a"
@ -164,7 +164,7 @@ do_encode_dsa (const byte *md, size_t mdlen, int dsaalgo, gcry_sexp_t pkey,
{ {
log_error (_("a %zu bit hash is not valid for a %u bit %s key\n"), log_error (_("a %zu bit hash is not valid for a %u bit %s key\n"),
mdlen*8, mdlen*8,
gcry_pk_get_nbits (pkey), gcry_pk_get_nbits (pkey),
gcry_pk_algo_name (pkalgo)); gcry_pk_algo_name (pkalgo));
/* FIXME: we need to check the requirements for ECDSA. */ /* FIXME: we need to check the requirements for ECDSA. */
if (mdlen < 20 || pkalgo == GCRY_PK_DSA) if (mdlen < 20 || pkalgo == GCRY_PK_DSA)
@ -174,7 +174,7 @@ do_encode_dsa (const byte *md, size_t mdlen, int dsaalgo, gcry_sexp_t pkey,
/* Truncate. */ /* Truncate. */
if (mdlen > qbits/8) if (mdlen > qbits/8)
mdlen = qbits/8; mdlen = qbits/8;
/* Create the S-expression. We need to convert to an MPI first /* Create the S-expression. We need to convert to an MPI first
because we want an unsigned integer. Using %b directly is not because we want an unsigned integer. Using %b directly is not
possible because libgcrypt assumes an mpi and uses possible because libgcrypt assumes an mpi and uses
@ -182,7 +182,7 @@ do_encode_dsa (const byte *md, size_t mdlen, int dsaalgo, gcry_sexp_t pkey,
value. */ value. */
{ {
gcry_mpi_t mpi; gcry_mpi_t mpi;
err = gcry_mpi_scan (&mpi, GCRYMPI_FMT_USG, md, mdlen, NULL); err = gcry_mpi_scan (&mpi, GCRYMPI_FMT_USG, md, mdlen, NULL);
if (!err) if (!err)
{ {
@ -193,7 +193,7 @@ do_encode_dsa (const byte *md, size_t mdlen, int dsaalgo, gcry_sexp_t pkey,
} }
if (!err) if (!err)
*r_hash = hash; *r_hash = hash;
return err; return err;
} }
@ -209,7 +209,7 @@ do_encode_raw_pkcs1 (const byte *md, size_t mdlen, unsigned int nbits,
gcry_sexp_t hash; gcry_sexp_t hash;
unsigned char *frame; unsigned char *frame;
size_t i, n, nframe; size_t i, n, nframe;
nframe = (nbits+7) / 8; nframe = (nbits+7) / 8;
if ( !mdlen || mdlen + 8 + 4 > nframe ) if ( !mdlen || mdlen + 8 + 4 > nframe )
{ {
@ -220,7 +220,7 @@ do_encode_raw_pkcs1 (const byte *md, size_t mdlen, unsigned int nbits,
frame = xtrymalloc (nframe); frame = xtrymalloc (nframe);
if (!frame) if (!frame)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
/* Assemble the pkcs#1 block type 1. */ /* Assemble the pkcs#1 block type 1. */
n = 0; n = 0;
frame[n++] = 0; frame[n++] = 0;
@ -233,7 +233,7 @@ do_encode_raw_pkcs1 (const byte *md, size_t mdlen, unsigned int nbits,
memcpy (frame+n, md, mdlen ); memcpy (frame+n, md, mdlen );
n += mdlen; n += mdlen;
assert (n == nframe); assert (n == nframe);
/* Create the S-expression. */ /* Create the S-expression. */
rc = gcry_sexp_build (&hash, NULL, rc = gcry_sexp_build (&hash, NULL,
"(data (flags raw) (value %b))", "(data (flags raw) (value %b))",
@ -241,7 +241,7 @@ do_encode_raw_pkcs1 (const byte *md, size_t mdlen, unsigned int nbits,
xfree (frame); xfree (frame);
*r_hash = hash; *r_hash = hash;
return rc; return rc;
} }
@ -280,8 +280,8 @@ agent_pksign_do (ctrl_t ctrl, const char *cache_nonce,
unsigned char *buf = NULL; unsigned char *buf = NULL;
size_t len = 0; size_t len = 0;
rc = divert_pksign (ctrl, rc = divert_pksign (ctrl,
ctrl->digest.value, ctrl->digest.value,
ctrl->digest.valuelen, ctrl->digest.valuelen,
ctrl->digest.algo, ctrl->digest.algo,
shadow_info, &buf); shadow_info, &buf);
@ -367,7 +367,7 @@ agent_pksign_do (ctrl_t ctrl, const char *cache_nonce,
tried to get a passphrase. */ tried to get a passphrase. */
int int
agent_pksign (ctrl_t ctrl, const char *cache_nonce, const char *desc_text, agent_pksign (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
membuf_t *outbuf, cache_mode_t cache_mode) membuf_t *outbuf, cache_mode_t cache_mode)
{ {
gcry_sexp_t s_sig = NULL; gcry_sexp_t s_sig = NULL;
char *buf = NULL; char *buf = NULL;

View File

@ -48,14 +48,14 @@
#include "sysutils.h" #include "sysutils.h"
enum cmd_and_opt_values enum cmd_and_opt_values
{ aNull = 0, { aNull = 0,
oVerbose = 'v', oVerbose = 'v',
oPassphrase = 'P', oPassphrase = 'P',
oPreset = 'c', oPreset = 'c',
oForget = 'f', oForget = 'f',
oNoVerbose = 500, oNoVerbose = 500,
oHomedir, oHomedir,
@ -67,7 +67,7 @@ static const char *opt_homedir;
static const char *opt_passphrase; static const char *opt_passphrase;
static ARGPARSE_OPTS opts[] = { static ARGPARSE_OPTS opts[] = {
{ 301, NULL, 0, N_("@Options:\n ") }, { 301, NULL, 0, N_("@Options:\n ") },
{ oVerbose, "verbose", 0, "verbose" }, { oVerbose, "verbose", 0, "verbose" },
@ -75,7 +75,7 @@ static ARGPARSE_OPTS opts[] = {
{ oPreset, "preset", 256, "preset passphrase"}, { oPreset, "preset", 256, "preset passphrase"},
{ oForget, "forget", 256, "forget passphrase"}, { oForget, "forget", 256, "forget passphrase"},
{ oHomedir, "homedir", 2, "@" }, { oHomedir, "homedir", 2, "@" },
{0} {0}
}; };
@ -93,14 +93,14 @@ my_strusage (int level)
case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break; case 19: p = _("Please report bugs to <@EMAIL@>.\n"); break;
case 1: case 1:
case 40: case 40:
p = _("Usage: gpg-preset-passphrase [options] KEYGRIP (-h for help)\n"); p = _("Usage: gpg-preset-passphrase [options] KEYGRIP (-h for help)\n");
break; break;
case 41: case 41:
p = _("Syntax: gpg-preset-passphrase [options] KEYGRIP\n" p = _("Syntax: gpg-preset-passphrase [options] KEYGRIP\n"
"Password cache maintenance\n"); "Password cache maintenance\n");
break; break;
default: p = NULL; default: p = NULL;
} }
return p; return p;
@ -111,7 +111,7 @@ my_strusage (int level)
/* Include the implementation of map_spwq_error. */ /* Include the implementation of map_spwq_error. */
MAP_SPWQ_ERROR_IMPL MAP_SPWQ_ERROR_IMPL
static void static void
preset_passphrase (const char *keygrip) preset_passphrase (const char *keygrip)
@ -209,7 +209,7 @@ main (int argc, char **argv)
const char *keygrip = NULL; const char *keygrip = NULL;
set_strusage (my_strusage); set_strusage (my_strusage);
log_set_prefix ("gpg-preset-passphrase", 1); log_set_prefix ("gpg-preset-passphrase", 1);
/* Make sure that our subsystems are ready. */ /* Make sure that our subsystems are ready. */
i18n_init (); i18n_init ();
@ -230,7 +230,7 @@ main (int argc, char **argv)
case oPreset: cmd = oPreset; break; case oPreset: cmd = oPreset; break;
case oForget: cmd = oForget; break; case oForget: cmd = oForget; break;
case oPassphrase: opt_passphrase = pargs.r.ret_str; break; case oPassphrase: opt_passphrase = pargs.r.ret_str; break;
default : pargs.err = 2; break; default : pargs.err = 2; break;
} }
} }

View File

@ -45,8 +45,8 @@
#include "sysutils.h" #include "sysutils.h"
enum cmd_and_opt_values enum cmd_and_opt_values
{ {
aNull = 0, aNull = 0,
oVerbose = 'v', oVerbose = 'v',
oArmor = 'a', oArmor = 'a',
@ -54,7 +54,7 @@ enum cmd_and_opt_values
oProtect = 'p', oProtect = 'p',
oUnprotect = 'u', oUnprotect = 'u',
oNoVerbose = 500, oNoVerbose = 500,
oShadow, oShadow,
oShowShadowInfo, oShowShadowInfo,
@ -68,13 +68,13 @@ enum cmd_and_opt_values
oNoFailOnExist, oNoFailOnExist,
oHomedir, oHomedir,
oPrompt, oPrompt,
oStatusMsg, oStatusMsg,
oAgentProgram oAgentProgram
}; };
struct rsa_secret_key_s struct rsa_secret_key_s
{ {
gcry_mpi_t n; /* public modulus */ gcry_mpi_t n; /* public modulus */
gcry_mpi_t e; /* public exponent */ gcry_mpi_t e; /* public exponent */
@ -95,7 +95,7 @@ static int opt_have_cert;
static const char *opt_passphrase; static const char *opt_passphrase;
static char *opt_prompt; static char *opt_prompt;
static int opt_status_msg; static int opt_status_msg;
static const char *opt_agent_program; static const char *opt_agent_program;
static char *get_passphrase (int promptno); static char *get_passphrase (int promptno);
static void release_passphrase (char *pw); static void release_passphrase (char *pw);
@ -110,7 +110,7 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_c (oShowShadowInfo, "show-shadow-info", "return the shadow info"), ARGPARSE_c (oShowShadowInfo, "show-shadow-info", "return the shadow info"),
ARGPARSE_c (oShowKeygrip, "show-keygrip", "show the \"keygrip\""), ARGPARSE_c (oShowKeygrip, "show-keygrip", "show the \"keygrip\""),
ARGPARSE_c (oS2Kcalibration, "s2k-calibration", "@"), ARGPARSE_c (oS2Kcalibration, "s2k-calibration", "@"),
ARGPARSE_group (301, N_("@\nOptions:\n ")), ARGPARSE_group (301, N_("@\nOptions:\n ")),
ARGPARSE_s_n (oVerbose, "verbose", "verbose"), ARGPARSE_s_n (oVerbose, "verbose", "verbose"),
@ -120,14 +120,14 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_s (oPassphrase, "passphrase", "|STRING|use passphrase STRING"), ARGPARSE_s_s (oPassphrase, "passphrase", "|STRING|use passphrase STRING"),
ARGPARSE_s_n (oHaveCert, "have-cert", ARGPARSE_s_n (oHaveCert, "have-cert",
"certificate to export provided on STDIN"), "certificate to export provided on STDIN"),
ARGPARSE_s_n (oStore, "store", ARGPARSE_s_n (oStore, "store",
"store the created key in the appropriate place"), "store the created key in the appropriate place"),
ARGPARSE_s_n (oForce, "force", ARGPARSE_s_n (oForce, "force",
"force overwriting"), "force overwriting"),
ARGPARSE_s_n (oNoFailOnExist, "no-fail-on-exist", "@"), ARGPARSE_s_n (oNoFailOnExist, "no-fail-on-exist", "@"),
ARGPARSE_s_s (oHomedir, "homedir", "@"), ARGPARSE_s_s (oHomedir, "homedir", "@"),
ARGPARSE_s_s (oPrompt, "prompt", ARGPARSE_s_s (oPrompt, "prompt",
"|ESCSTRING|use ESCSTRING as prompt in pinentry"), "|ESCSTRING|use ESCSTRING as prompt in pinentry"),
ARGPARSE_s_n (oStatusMsg, "enable-status-msg", "@"), ARGPARSE_s_n (oStatusMsg, "enable-status-msg", "@"),
ARGPARSE_s_s (oAgentProgram, "agent-program", "@"), ARGPARSE_s_s (oAgentProgram, "agent-program", "@"),
@ -153,7 +153,7 @@ my_strusage (int level)
case 41: p = _("Syntax: gpg-protect-tool [options] [args]\n" case 41: p = _("Syntax: gpg-protect-tool [options] [args]\n"
"Secret key maintenance tool\n"); "Secret key maintenance tool\n");
break; break;
default: p = NULL; default: p = NULL;
} }
return p; return p;
@ -234,7 +234,7 @@ read_file (const char *fname, size_t *r_length)
FILE *fp; FILE *fp;
char *buf; char *buf;
size_t buflen; size_t buflen;
if (!strcmp (fname, "-")) if (!strcmp (fname, "-"))
{ {
size_t nread, bufsize = 0; size_t nread, bufsize = 0;
@ -246,7 +246,7 @@ read_file (const char *fname, size_t *r_length)
buf = NULL; buf = NULL;
buflen = 0; buflen = 0;
#define NCHUNK 8192 #define NCHUNK 8192
do do
{ {
bufsize += NCHUNK; bufsize += NCHUNK;
if (!buf) if (!buf)
@ -277,14 +277,14 @@ read_file (const char *fname, size_t *r_length)
log_error ("can't open `%s': %s\n", fname, strerror (errno)); log_error ("can't open `%s': %s\n", fname, strerror (errno));
return NULL; return NULL;
} }
if (fstat (fileno(fp), &st)) if (fstat (fileno(fp), &st))
{ {
log_error ("can't stat `%s': %s\n", fname, strerror (errno)); log_error ("can't stat `%s': %s\n", fname, strerror (errno));
fclose (fp); fclose (fp);
return NULL; return NULL;
} }
buflen = st.st_size; buflen = st.st_size;
buf = xmalloc (buflen+1); buf = xmalloc (buflen+1);
if (fread (buf, buflen, 1, fp) != 1) if (fread (buf, buflen, 1, fp) != 1)
@ -308,7 +308,7 @@ read_key (const char *fname)
char *buf; char *buf;
size_t buflen; size_t buflen;
unsigned char *key; unsigned char *key;
buf = read_file (fname, &buflen); buf = read_file (fname, &buflen);
if (!buf) if (!buf)
return NULL; return NULL;
@ -327,7 +327,7 @@ read_and_protect (const char *fname)
unsigned char *result; unsigned char *result;
size_t resultlen; size_t resultlen;
char *pw; char *pw;
key = read_key (fname); key = read_key (fname);
if (!key) if (!key)
return; return;
@ -341,7 +341,7 @@ read_and_protect (const char *fname)
log_error ("protecting the key failed: %s\n", gpg_strerror (rc)); log_error ("protecting the key failed: %s\n", gpg_strerror (rc));
return; return;
} }
if (opt_armor) if (opt_armor)
{ {
char *p = make_advanced (result, resultlen); char *p = make_advanced (result, resultlen);
@ -371,7 +371,7 @@ read_and_unprotect (const char *fname)
if (!key) if (!key)
return; return;
rc = agent_unprotect (key, (pw=get_passphrase (1)), rc = agent_unprotect (key, (pw=get_passphrase (1)),
protected_at, &result, &resultlen); protected_at, &result, &resultlen);
release_passphrase (pw); release_passphrase (pw);
xfree (key); xfree (key);
@ -412,7 +412,7 @@ read_and_shadow (const char *fname)
unsigned char *result; unsigned char *result;
size_t resultlen; size_t resultlen;
unsigned char dummy_info[] = "(8:313233342:43)"; unsigned char dummy_info[] = "(8:313233342:43)";
key = read_key (fname); key = read_key (fname);
if (!key) if (!key)
return; return;
@ -426,7 +426,7 @@ read_and_shadow (const char *fname)
} }
resultlen = gcry_sexp_canon_len (result, 0, NULL,NULL); resultlen = gcry_sexp_canon_len (result, 0, NULL,NULL);
assert (resultlen); assert (resultlen);
if (opt_armor) if (opt_armor)
{ {
char *p = make_advanced (result, resultlen); char *p = make_advanced (result, resultlen);
@ -448,7 +448,7 @@ show_shadow_info (const char *fname)
unsigned char *key; unsigned char *key;
const unsigned char *info; const unsigned char *info;
size_t infolen; size_t infolen;
key = read_key (fname); key = read_key (fname);
if (!key) if (!key)
return; return;
@ -462,7 +462,7 @@ show_shadow_info (const char *fname)
} }
infolen = gcry_sexp_canon_len (info, 0, NULL,NULL); infolen = gcry_sexp_canon_len (info, 0, NULL,NULL);
assert (infolen); assert (infolen);
if (opt_armor) if (opt_armor)
{ {
char *p = make_advanced (info, infolen); char *p = make_advanced (info, infolen);
@ -482,14 +482,14 @@ show_file (const char *fname)
unsigned char *key; unsigned char *key;
size_t keylen; size_t keylen;
char *p; char *p;
key = read_key (fname); key = read_key (fname);
if (!key) if (!key)
return; return;
keylen = gcry_sexp_canon_len (key, 0, NULL,NULL); keylen = gcry_sexp_canon_len (key, 0, NULL,NULL);
assert (keylen); assert (keylen);
if (opt_canonical) if (opt_canonical)
{ {
fwrite (key, keylen, 1, stdout); fwrite (key, keylen, 1, stdout);
@ -513,7 +513,7 @@ show_keygrip (const char *fname)
gcry_sexp_t private; gcry_sexp_t private;
unsigned char grip[20]; unsigned char grip[20];
int i; int i;
key = read_key (fname); key = read_key (fname);
if (!key) if (!key)
return; return;
@ -522,7 +522,7 @@ show_keygrip (const char *fname)
{ {
log_error ("gcry_sexp_new failed\n"); log_error ("gcry_sexp_new failed\n");
return; return;
} }
xfree (key); xfree (key);
if (!gcry_pk_get_keygrip (private, grip)) if (!gcry_pk_get_keygrip (private, grip))
@ -550,7 +550,7 @@ main (int argc, char **argv )
set_strusage (my_strusage); set_strusage (my_strusage);
gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
log_set_prefix ("gpg-protect-tool", 1); log_set_prefix ("gpg-protect-tool", 1);
/* Make sure that our subsystems are ready. */ /* Make sure that our subsystems are ready. */
i18n_init (); i18n_init ();
@ -597,7 +597,7 @@ main (int argc, char **argv )
case oHaveCert: opt_have_cert = 1; break; case oHaveCert: opt_have_cert = 1; break;
case oPrompt: opt_prompt = pargs.r.ret_str; break; case oPrompt: opt_prompt = pargs.r.ret_str; break;
case oStatusMsg: opt_status_msg = 1; break; case oStatusMsg: opt_status_msg = 1; break;
default: pargs.err = ARGPARSE_PRINT_ERROR; break; default: pargs.err = ARGPARSE_PRINT_ERROR; break;
} }
} }
@ -667,7 +667,7 @@ get_passphrase (int promptno)
const char *desc; const char *desc;
char *orig_codeset; char *orig_codeset;
int repeat = 0; int repeat = 0;
if (opt_passphrase) if (opt_passphrase)
return xstrdup (opt_passphrase); return xstrdup (opt_passphrase);
@ -727,4 +727,3 @@ release_passphrase (char *pw)
xfree (pw); xfree (pw);
} }
} }

View File

@ -137,7 +137,7 @@ test_agent_protect (void)
"\x9B\x7B\xE8\xDD\x1F\x87\x4E\x79\x7B\x50\x12\xA7\xB4\x8B\x52\x38\xEC\x7C\xBB\xB9" "\x9B\x7B\xE8\xDD\x1F\x87\x4E\x79\x7B\x50\x12\xA7\xB4\x8B\x52\x38\xEC\x7C\xBB\xB9"
"\x55\x87\x11\x1C\x74\xE7\x7F\xA0\xBA\xE3\x34\x5D\x61\xBF\x29\x29\x29\x00" "\x55\x87\x11\x1C\x74\xE7\x7F\xA0\xBA\xE3\x34\x5D\x61\xBF\x29\x29\x29\x00"
}; };
struct struct
{ {
const char *key; const char *key;
@ -182,7 +182,7 @@ test_agent_protect (void)
specs[i].ret_expected, gpg_strerror (specs[i].ret_expected)); specs[i].ret_expected, gpg_strerror (specs[i].ret_expected));
abort (); abort ();
} }
if (specs[i].no_result_expected) if (specs[i].no_result_expected)
{ {
assert (! specs[i].result); assert (! specs[i].result);
@ -234,14 +234,14 @@ static void
test_make_shadow_info (void) test_make_shadow_info (void)
{ {
#if 0 #if 0
static struct static struct
{ {
const char *snstr; const char *snstr;
const char *idstr; const char *idstr;
const char *expected; const char *expected;
} data[] = { } data[] = {
{ "", "", NULL }, { "", "", NULL },
}; };
int i; int i;
unsigned char *result; unsigned char *result;
@ -305,7 +305,7 @@ main (int argc, char **argv)
(void)argv; (void)argv;
gcry_control (GCRYCTL_DISABLE_SECMEM); gcry_control (GCRYCTL_DISABLE_SECMEM);
test_agent_protect (); test_agent_protect ();
test_agent_unprotect (); test_agent_unprotect ();
test_agent_private_key_type (); test_agent_private_key_type ();

View File

@ -50,8 +50,8 @@ struct trustitem_s
typedef struct trustitem_s trustitem_t; typedef struct trustitem_s trustitem_t;
/* Malloced table and its allocated size with all trust items. */ /* Malloced table and its allocated size with all trust items. */
static trustitem_t *trusttable; static trustitem_t *trusttable;
static size_t trusttablesize; static size_t trusttablesize;
/* A mutex used to protect the table. */ /* A mutex used to protect the table. */
static pth_mutex_t trusttable_lock; static pth_mutex_t trusttable_lock;
@ -111,7 +111,7 @@ unlock_trusttable (void)
static gpg_error_t static gpg_error_t
read_one_trustfile (const char *fname, int allow_include, read_one_trustfile (const char *fname, int allow_include,
trustitem_t **addr_of_table, trustitem_t **addr_of_table,
size_t *addr_of_tablesize, size_t *addr_of_tablesize,
int *addr_of_tableidx) int *addr_of_tableidx)
{ {
@ -123,7 +123,7 @@ read_one_trustfile (const char *fname, int allow_include,
int tableidx; int tableidx;
size_t tablesize; size_t tablesize;
int lnr = 0; int lnr = 0;
table = *addr_of_table; table = *addr_of_table;
tablesize = *addr_of_tablesize; tablesize = *addr_of_tablesize;
tableidx = *addr_of_tableidx; tableidx = *addr_of_tableidx;
@ -155,13 +155,13 @@ read_one_trustfile (const char *fname, int allow_include,
line[--n] = 0; /* Chop the LF. */ line[--n] = 0; /* Chop the LF. */
if (n && line[n-1] == '\r') if (n && line[n-1] == '\r')
line[--n] = 0; /* Chop an optional CR. */ line[--n] = 0; /* Chop an optional CR. */
/* Allow for empty lines and spaces */ /* Allow for empty lines and spaces */
for (p=line; spacep (p); p++) for (p=line; spacep (p); p++)
; ;
if (!*p || *p == '#') if (!*p || *p == '#')
continue; continue;
if (!strncmp (p, "include-default", 15) if (!strncmp (p, "include-default", 15)
&& (!p[15] || spacep (p+15))) && (!p[15] || spacep (p+15)))
{ {
@ -194,7 +194,7 @@ read_one_trustfile (const char *fname, int allow_include,
err = err2; err = err2;
} }
xfree (etcname); xfree (etcname);
continue; continue;
} }
@ -202,7 +202,7 @@ read_one_trustfile (const char *fname, int allow_include,
{ {
trustitem_t *tmp; trustitem_t *tmp;
size_t tmplen; size_t tmplen;
tmplen = tablesize + 20; tmplen = tablesize + 20;
tmp = xtryrealloc (table, tmplen * sizeof *table); tmp = xtryrealloc (table, tmplen * sizeof *table);
if (!tmp) if (!tmp)
@ -229,13 +229,13 @@ read_one_trustfile (const char *fname, int allow_include,
if (n < 0) if (n < 0)
{ {
log_error (_("bad fingerprint in `%s', line %d\n"), fname, lnr); log_error (_("bad fingerprint in `%s', line %d\n"), fname, lnr);
err = gpg_error (GPG_ERR_BAD_DATA); err = gpg_error (GPG_ERR_BAD_DATA);
continue; continue;
} }
p += n; p += n;
for (; spacep (p); p++) for (; spacep (p); p++)
; ;
/* Process the first flag which needs to be the first for /* Process the first flag which needs to be the first for
backward compatibility. */ backward compatibility. */
if (!*p || *p == '*' ) if (!*p || *p == '*' )
@ -379,7 +379,7 @@ read_trustfiles (void)
/* Check whether the given fpr is in our trustdb. We expect FPR to be /* Check whether the given fpr is in our trustdb. We expect FPR to be
an all uppercase hexstring of 40 characters. */ an all uppercase hexstring of 40 characters. */
gpg_error_t gpg_error_t
agent_istrusted (ctrl_t ctrl, const char *fpr, int *r_disabled) agent_istrusted (ctrl_t ctrl, const char *fpr, int *r_disabled)
{ {
gpg_error_t err; gpg_error_t err;
@ -414,7 +414,7 @@ agent_istrusted (ctrl_t ctrl, const char *fpr, int *r_disabled)
if (ti->flags.relax) if (ti->flags.relax)
{ {
err = agent_write_status (ctrl, err = agent_write_status (ctrl,
"TRUSTLISTFLAG", "relax", "TRUSTLISTFLAG", "relax",
NULL); NULL);
if (err) if (err)
return err; return err;
@ -422,7 +422,7 @@ agent_istrusted (ctrl_t ctrl, const char *fpr, int *r_disabled)
else if (ti->flags.cm) else if (ti->flags.cm)
{ {
err = agent_write_status (ctrl, err = agent_write_status (ctrl,
"TRUSTLISTFLAG", "cm", "TRUSTLISTFLAG", "cm",
NULL); NULL);
if (err) if (err)
return err; return err;
@ -435,7 +435,7 @@ agent_istrusted (ctrl_t ctrl, const char *fpr, int *r_disabled)
/* Write all trust entries to FP. */ /* Write all trust entries to FP. */
gpg_error_t gpg_error_t
agent_listtrusted (void *assuan_context) agent_listtrusted (void *assuan_context)
{ {
trustitem_t *ti; trustitem_t *ti;
@ -532,7 +532,7 @@ reformat_name (const char *name, const char *replstring)
count++; count++;
newname = xtrymalloc (strlen (name) + count*replstringlen + 1); newname = xtrymalloc (strlen (name) + count*replstringlen + 1);
if (!newname) if (!newname)
return NULL; return NULL;
for (s=name+1, d=newname; *s; s++) for (s=name+1, d=newname; *s; s++)
if (*s == '/') if (*s == '/')
d = stpcpy (d, replstring); d = stpcpy (d, replstring);
@ -571,7 +571,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
{ {
xfree (fname); xfree (fname);
return gpg_error (GPG_ERR_EPERM); return gpg_error (GPG_ERR_EPERM);
} }
xfree (fname); xfree (fname);
if (!agent_istrusted (ctrl, fpr, &is_disabled)) if (!agent_istrusted (ctrl, fpr, &is_disabled))
@ -579,7 +579,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
return 0; /* We already got this fingerprint. Silently return return 0; /* We already got this fingerprint. Silently return
success. */ success. */
} }
/* This feature must explicitly been enabled. */ /* This feature must explicitly been enabled. */
if (!opt.allow_mark_trusted) if (!opt.allow_mark_trusted)
return gpg_error (GPG_ERR_NOT_SUPPORTED); return gpg_error (GPG_ERR_NOT_SUPPORTED);
@ -629,7 +629,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
xfree (nameformatted); xfree (nameformatted);
return err; return err;
} }
fprformatted = insert_colons (fpr); fprformatted = insert_colons (fpr);
if (!fprformatted) if (!fprformatted)
@ -642,7 +642,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
fingerprint of course. */ fingerprint of course. */
if (yes_i_trust) if (yes_i_trust)
{ {
desc = xtryasprintf desc = xtryasprintf
( (
/* TRANSLATORS: This prompt is shown by the Pinentry and has /* TRANSLATORS: This prompt is shown by the Pinentry and has
one special property: A "%%0A" is used by Pinentry to one special property: A "%%0A" is used by Pinentry to
@ -662,7 +662,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
xfree (nameformatted); xfree (nameformatted);
return out_of_core (); return out_of_core ();
} }
/* TRANSLATORS: "Correct" is the label of a button and intended /* TRANSLATORS: "Correct" is the label of a button and intended
to be hit if the fingerprint matches the one of the CA. The to be hit if the fingerprint matches the one of the CA. The
other button is "the default "Cancel" of the Pinentry. */ other button is "the default "Cancel" of the Pinentry. */
@ -688,7 +688,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
unlock_trusttable (); unlock_trusttable ();
xfree (fprformatted); xfree (fprformatted);
xfree (nameformatted); xfree (nameformatted);
return is_disabled? gpg_error (GPG_ERR_NOT_TRUSTED) : 0; return is_disabled? gpg_error (GPG_ERR_NOT_TRUSTED) : 0;
} }
fname = make_filename (opt.homedir, "trustlist.txt", NULL); fname = make_filename (opt.homedir, "trustlist.txt", NULL);
@ -735,7 +735,7 @@ agent_marktrusted (ctrl_t ctrl, const char *name, const char *fpr, int flag)
es_fprintf (fp, "\n%s%s %c\n", yes_i_trust?"":"!", fprformatted, flag); es_fprintf (fp, "\n%s%s %c\n", yes_i_trust?"":"!", fprformatted, flag);
if (es_ferror (fp)) if (es_ferror (fp))
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
if (es_fclose (fp)) if (es_fclose (fp))
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();

View File

@ -67,12 +67,12 @@ build_argv (char *cmdline_arg, int reserved)
{ {
argc++; argc++;
/* Skip the remaining spaces. */ /* Skip the remaining spaces. */
while (*s==' ' || *s=='\t') while (*s==' ' || *s=='\t')
s++; s++;
if (!*s) if (!*s)
break; break;
bs_count = 0; bs_count = 0;
} }
else if (*s=='\\') else if (*s=='\\')
{ {
bs_count++; bs_count++;
@ -84,7 +84,7 @@ build_argv (char *cmdline_arg, int reserved)
in_quotes = !in_quotes; in_quotes = !in_quotes;
bs_count=0; bs_count=0;
s++; s++;
} }
else /* A regular character. */ else /* A regular character. */
{ {
bs_count = 0; bs_count = 0;
@ -113,20 +113,20 @@ build_argv (char *cmdline_arg, int reserved)
argv[argc++] = arg; argv[argc++] = arg;
/* Skip the remaining spaces. */ /* Skip the remaining spaces. */
do do
s++; s++;
while (*s==' ' || *s=='\t'); while (*s==' ' || *s=='\t');
/* Start with a new argument */ /* Start with a new argument */
arg = d = s; arg = d = s;
bs_count = 0; bs_count = 0;
} }
else if (*s=='\\') else if (*s=='\\')
{ {
*d++ = *s++; *d++ = *s++;
bs_count++; bs_count++;
} }
else if (*s=='\"') else if (*s=='\"')
{ {
if ( !(bs_count & 1) ) if ( !(bs_count & 1) )
{ {
@ -137,7 +137,7 @@ build_argv (char *cmdline_arg, int reserved)
s++; s++;
in_quotes = !in_quotes; in_quotes = !in_quotes;
} }
else else
{ {
/* Preceded by an odd number of backslashes, this is /* Preceded by an odd number of backslashes, this is
half that number of backslashes followed by a '\"'. */ half that number of backslashes followed by a '\"'. */
@ -146,7 +146,7 @@ build_argv (char *cmdline_arg, int reserved)
s++; s++;
} }
bs_count=0; bs_count=0;
} }
else /* A regular character. */ else /* A regular character. */
{ {
*d++ = *s++; *d++ = *s++;
@ -167,9 +167,9 @@ build_argv (char *cmdline_arg, int reserved)
/* Our window message processing function. */ /* Our window message processing function. */
static LRESULT CALLBACK static LRESULT CALLBACK
wndw_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) wndw_proc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{ {
switch (msg) switch (msg)
{ {
@ -239,8 +239,8 @@ handle_taskbar (void *ctx)
DestroyIcon (nid.hIcon); DestroyIcon (nid.hIcon);
fprintf (stderr, "%s: enter\n", __func__); fprintf (stderr, "%s: enter\n", __func__);
while ( (rc=GetMessage (&msg, hwnd, 0, 0)) ) while ( (rc=GetMessage (&msg, hwnd, 0, 0)) )
{ {
if (rc == -1) if (rc == -1)
{ {
log_error ("getMessage failed: %s\n", w32_strerror (-1)); log_error ("getMessage failed: %s\n", w32_strerror (-1));

View File

@ -7,18 +7,18 @@
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or # the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# GnuPG is distributed in the hope that it will be useful, # GnuPG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
localedir = $(datadir)/locale localedir = $(datadir)/locale
AM_CPPFLAGS += -DLOCALEDIR=\"$(localedir)\" AM_CPPFLAGS += -DLOCALEDIR=\"$(localedir)\"
if ! HAVE_DOSISH_SYSTEM if ! HAVE_DOSISH_SYSTEM
AM_CPPFLAGS += -DGNUPG_BINDIR="\"$(bindir)\"" \ AM_CPPFLAGS += -DGNUPG_BINDIR="\"$(bindir)\"" \
@ -59,14 +59,13 @@ endif
# we use with pth. # we use with pth.
if HAVE_W32CE_SYSTEM if HAVE_W32CE_SYSTEM
extra_sys_libs = -lcoredll6 extra_sys_libs = -lcoredll6
extra_bin_ldflags = -Wl,--stack=0x40000 extra_bin_ldflags = -Wl,--stack=0x40000
else else
extra_sys_libs = extra_sys_libs =
extra_bin_ldflags = extra_bin_ldflags =
endif endif
# Convenience macros # Convenience macros
libcommon = ../common/libcommon.a libcommon = ../common/libcommon.a
libcommonpth = ../common/libcommonpth.a libcommonpth = ../common/libcommonpth.a

View File

@ -7,12 +7,12 @@
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or # the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# GnuPG is distributed in the hope that it will be useful, # GnuPG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
@ -97,12 +97,12 @@ common_sources = \
# separate source files. # separate source files.
if HAVE_W32_SYSTEM if HAVE_W32_SYSTEM
if HAVE_W32CE_SYSTEM if HAVE_W32CE_SYSTEM
common_sources += exechelp-w32ce.c common_sources += exechelp-w32ce.c
else else
common_sources += exechelp-w32.c common_sources += exechelp-w32.c
endif endif
else else
common_sources += exechelp-posix.c common_sources += exechelp-posix.c
endif endif
# Sources only useful without PTH. # Sources only useful without PTH.
@ -155,7 +155,7 @@ endif
# #
# Module tests # Module tests
# #
t_jnlib_src = t-support.c t-support.h t_jnlib_src = t-support.c t-support.h
jnlib_tests = t-stringhelp t-timestuff jnlib_tests = t-stringhelp t-timestuff
if HAVE_W32_SYSTEM if HAVE_W32_SYSTEM
jnlib_tests += t-w32-reg jnlib_tests += t-w32-reg
@ -194,7 +194,3 @@ t_b64_LDADD = $(t_common_ldadd)
t_exechelp_LDADD = $(t_common_ldadd) t_exechelp_LDADD = $(t_common_ldadd)
t_session_env_LDADD = $(t_common_ldadd) t_session_env_LDADD = $(t_common_ldadd)
t_openpgp_oid_LDADD = $(t_common_ldadd) t_openpgp_oid_LDADD = $(t_common_ldadd)

View File

@ -60,7 +60,7 @@ libjnlib_a_SOURCES = \
logging.c logging.h \ logging.c logging.h \
dotlock.c dotlock.h \ dotlock.c dotlock.h \
types.h mischelp.c mischelp.h dynload.h w32help.h \ types.h mischelp.c mischelp.h dynload.h w32help.h \
xmalloc.c xmalloc.h xmalloc.c xmalloc.h
if HAVE_W32_SYSTEM if HAVE_W32_SYSTEM
libjnlib_a_SOURCES += w32-reg.c w32-afunix.c w32-afunix.h libjnlib_a_SOURCES += w32-reg.c w32-afunix.c w32-afunix.h
@ -79,7 +79,7 @@ if HAVE_W32_SYSTEM
module_tests += t-w32-reg module_tests += t-w32-reg
endif endif
t_jnlib_src = t-support.c t-support.h t_jnlib_src = t-support.c t-support.h
t_jnlib_ldadd = libjnlib.a $(LIBINTL) $(LIBICONV) t_jnlib_ldadd = libjnlib.a $(LIBINTL) $(LIBICONV)
# For W32 we need libgpg-error because it provides gettext. # For W32 we need libgpg-error because it provides gettext.
if HAVE_W32_SYSTEM if HAVE_W32_SYSTEM
@ -97,5 +97,3 @@ t_w32_reg_SOURCES = t-w32-reg.c $(t_jnlib_src)
t_w32_reg_LDADD = $(t_jnlib_ldadd) t_w32_reg_LDADD = $(t_jnlib_ldadd)
endif endif
==>8=================================================== ==>8===================================================

View File

@ -24,12 +24,12 @@
#include "types.h" #include "types.h"
typedef struct typedef struct
{ {
int *argc; /* Pointer to ARGC (value subject to change). */ int *argc; /* Pointer to ARGC (value subject to change). */
char ***argv; /* Pointer to ARGV (value subject to change). */ char ***argv; /* Pointer to ARGV (value subject to change). */
unsigned int flags; /* Global flags. May be set prior to calling the unsigned int flags; /* Global flags. May be set prior to calling the
parser. The parser may change the value. */ parser. The parser may change the value. */
int err; /* Print error description for last option. int err; /* Print error description for last option.
Either 0, ARGPARSE_PRINT_WARNING or Either 0, ARGPARSE_PRINT_WARNING or
ARGPARSE_PRINT_ERROR. */ ARGPARSE_PRINT_ERROR. */
@ -78,7 +78,7 @@ typedef struct
#define ARGPARSE_TYPE_STRING 2 /* Takes a string argument. */ #define ARGPARSE_TYPE_STRING 2 /* Takes a string argument. */
#define ARGPARSE_TYPE_LONG 3 /* Takes a long argument. */ #define ARGPARSE_TYPE_LONG 3 /* Takes a long argument. */
#define ARGPARSE_TYPE_ULONG 4 /* Takes an unsigned long argument. */ #define ARGPARSE_TYPE_ULONG 4 /* Takes an unsigned long argument. */
#define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional. */ #define ARGPARSE_OPT_OPTIONAL (1<<3) /* Argument is optional. */
#define ARGPARSE_OPT_PREFIX (1<<4) /* Allow 0x etc. prefixed values. */ #define ARGPARSE_OPT_PREFIX (1<<4) /* Allow 0x etc. prefixed values. */
#define ARGPARSE_OPT_COMMAND (1<<8) /* The argument is a command. */ #define ARGPARSE_OPT_COMMAND (1<<8) /* The argument is a command. */
@ -149,7 +149,7 @@ typedef struct
#define ARGPARSE_group(s,d) \ #define ARGPARSE_group(s,d) \
{ (s), NULL, 0, (d) } { (s), NULL, 0, (d) }
#define ARGPARSE_end() { 0, NULL, 0, NULL } #define ARGPARSE_end() { 0, NULL, 0, NULL }

View File

@ -32,7 +32,7 @@
#include "util.h" #include "util.h"
#include "exechelp.h" #include "exechelp.h"
#include "sysutils.h" #include "sysutils.h"
#include "status.h" #include "status.h"
#include "asshelp.h" #include "asshelp.h"
/* The type we use for lock_agent_spawning. */ /* The type we use for lock_agent_spawning. */
@ -43,7 +43,7 @@
#endif #endif
/* The time we wait until the agent or the dirmngr are ready for /* The time we wait until the agent or the dirmngr are ready for
operation after we started them before giving up. */ operation after we started them before giving up. */
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
# define SECS_TO_WAIT_FOR_AGENT 30 # define SECS_TO_WAIT_FOR_AGENT 30
# define SECS_TO_WAIT_FOR_DIRMNGR 30 # define SECS_TO_WAIT_FOR_DIRMNGR 30
@ -110,7 +110,7 @@ send_one_option (assuan_context_t ctx, gpg_err_source_t errsource,
if (!value || !*value) if (!value || !*value)
err = 0; /* Avoid sending empty strings. */ err = 0; /* Avoid sending empty strings. */
else if (asprintf (&optstr, "OPTION %s%s=%s", else if (asprintf (&optstr, "OPTION %s%s=%s",
use_putenv? "putenv=":"", name, value) < 0) use_putenv? "putenv=":"", name, value) < 0)
err = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
else else
@ -136,7 +136,7 @@ send_pinentry_environment (assuan_context_t ctx,
{ {
gpg_error_t err = 0; gpg_error_t err = 0;
#if defined(HAVE_SETLOCALE) #if defined(HAVE_SETLOCALE)
char *old_lc = NULL; char *old_lc = NULL;
#endif #endif
char *dft_lc = NULL; char *dft_lc = NULL;
const char *dft_ttyname; const char *dft_ttyname;
@ -144,7 +144,7 @@ send_pinentry_environment (assuan_context_t ctx,
const char *name, *assname, *value; const char *name, *assname, *value;
int is_default; int is_default;
iterator = 0; iterator = 0;
while ((name = session_env_list_stdenvnames (&iterator, &assname))) while ((name = session_env_list_stdenvnames (&iterator, &assname)))
{ {
value = session_env_getenv_or_default (session_env, name, NULL); value = session_env_getenv_or_default (session_env, name, NULL);
@ -164,7 +164,7 @@ send_pinentry_environment (assuan_context_t ctx,
} }
dft_ttyname = session_env_getenv_or_default (session_env, "GPG_TTY", dft_ttyname = session_env_getenv_or_default (session_env, "GPG_TTY",
&is_default); &is_default);
if (dft_ttyname && !is_default) if (dft_ttyname && !is_default)
dft_ttyname = NULL; /* We need the default value. */ dft_ttyname = NULL; /* We need the default value. */
@ -182,7 +182,7 @@ send_pinentry_environment (assuan_context_t ctx,
#endif #endif
if (opt_lc_ctype || (dft_ttyname && dft_lc)) if (opt_lc_ctype || (dft_ttyname && dft_lc))
{ {
err = send_one_option (ctx, errsource, "lc-ctype", err = send_one_option (ctx, errsource, "lc-ctype",
opt_lc_ctype ? opt_lc_ctype : dft_lc, 0); opt_lc_ctype ? opt_lc_ctype : dft_lc, 0);
} }
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE) #if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
@ -208,7 +208,7 @@ send_pinentry_environment (assuan_context_t ctx,
#endif #endif
if (opt_lc_messages || (dft_ttyname && dft_lc)) if (opt_lc_messages || (dft_ttyname && dft_lc))
{ {
err = send_one_option (ctx, errsource, "lc-messages", err = send_one_option (ctx, errsource, "lc-messages",
opt_lc_messages ? opt_lc_messages : dft_lc, 0); opt_lc_messages ? opt_lc_messages : dft_lc, 0);
} }
#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES) #if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
@ -240,7 +240,7 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name,
(void)homedir; /* Not required. */ (void)homedir; /* Not required. */
*lock = CreateMutexW *lock = CreateMutexW
(NULL, FALSE, (NULL, FALSE,
!strcmp (name, "agent")? L"GnuPG_spawn_agent_sentinel": !strcmp (name, "agent")? L"GnuPG_spawn_agent_sentinel":
!strcmp (name, "dirmngr")? L"GnuPG_spawn_dirmngr_sentinel": !strcmp (name, "dirmngr")? L"GnuPG_spawn_dirmngr_sentinel":
@ -256,7 +256,7 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name,
waitrc = WaitForSingleObject (*lock, 1000); waitrc = WaitForSingleObject (*lock, 1000);
if (waitrc == WAIT_OBJECT_0) if (waitrc == WAIT_OBJECT_0)
return 0; return 0;
if (waitrc == WAIT_TIMEOUT && timeout) if (waitrc == WAIT_TIMEOUT && timeout)
{ {
timeout--; timeout--;
@ -268,7 +268,7 @@ lock_spawning (lock_spawn_t *lock, const char *homedir, const char *name,
if (waitrc == WAIT_TIMEOUT) if (waitrc == WAIT_TIMEOUT)
log_info ("error waiting for the spawn_%s mutex: timeout\n", name); log_info ("error waiting for the spawn_%s mutex: timeout\n", name);
else else
log_info ("error waiting for the spawn_%s mutex: (code=%d) %s\n", log_info ("error waiting for the spawn_%s mutex: (code=%d) %s\n",
name, waitrc, w32_strerror (-1)); name, waitrc, w32_strerror (-1));
return gpg_error (GPG_ERR_GENERAL); return gpg_error (GPG_ERR_GENERAL);
#else /*!HAVE_W32_SYSTEM*/ #else /*!HAVE_W32_SYSTEM*/
@ -377,11 +377,11 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
if (verbose) if (verbose)
log_info (_("no running gpg-agent - starting `%s'\n"), log_info (_("no running gpg-agent - starting `%s'\n"),
agent_program); agent_program);
if (status_cb) if (status_cb)
status_cb (status_cb_arg, STATUS_PROGRESS, status_cb (status_cb_arg, STATUS_PROGRESS,
"starting_agent ? 0 0", NULL); "starting_agent ? 0 0", NULL);
if (fflush (NULL)) if (fflush (NULL))
{ {
gpg_error_t tmperr = gpg_err_make (errsource, gpg_error_t tmperr = gpg_err_make (errsource,
@ -392,9 +392,9 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
assuan_release (ctx); assuan_release (ctx);
return tmperr; return tmperr;
} }
argv[0] = "--use-standard-socket-p"; argv[0] = "--use-standard-socket-p";
argv[1] = NULL; argv[1] = NULL;
err = gnupg_spawn_process_fd (agent_program, argv, -1, -1, -1, &pid); err = gnupg_spawn_process_fd (agent_program, argv, -1, -1, -1, &pid);
if (err) if (err)
log_debug ("starting `%s' for testing failed: %s\n", log_debug ("starting `%s' for testing failed: %s\n",
@ -404,7 +404,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
if (excode == -1) if (excode == -1)
log_debug ("running `%s' for testing failed (wait): %s\n", log_debug ("running `%s' for testing failed (wait): %s\n",
agent_program, gpg_strerror (err)); agent_program, gpg_strerror (err));
} }
gnupg_release_process (pid); gnupg_release_process (pid);
if (!err && !excode) if (!err && !excode)
@ -416,8 +416,8 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
lock_spawn_t lock; lock_spawn_t lock;
argv[0] = "--daemon"; argv[0] = "--daemon";
argv[1] = "--use-standard-socket"; argv[1] = "--use-standard-socket";
argv[2] = NULL; argv[2] = NULL;
if (!(err = lock_spawning (&lock, homedir, "agent", verbose)) if (!(err = lock_spawning (&lock, homedir, "agent", verbose))
&& assuan_socket_connect (ctx, sockname, 0, 0)) && assuan_socket_connect (ctx, sockname, 0, 0))
@ -463,22 +463,22 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
const char *pgmname; const char *pgmname;
int no_close_list[3]; int no_close_list[3];
int i; int i;
if ( !(pgmname = strrchr (agent_program, '/'))) if ( !(pgmname = strrchr (agent_program, '/')))
pgmname = agent_program; pgmname = agent_program;
else else
pgmname++; pgmname++;
argv[0] = pgmname; argv[0] = pgmname;
argv[1] = "--server"; argv[1] = "--server";
argv[2] = NULL; argv[2] = NULL;
i=0; i=0;
if (log_get_fd () != -1) if (log_get_fd () != -1)
no_close_list[i++] = assuan_fd_from_posix_fd (log_get_fd ()); no_close_list[i++] = assuan_fd_from_posix_fd (log_get_fd ());
no_close_list[i++] = assuan_fd_from_posix_fd (fileno (stderr)); no_close_list[i++] = assuan_fd_from_posix_fd (fileno (stderr));
no_close_list[i] = -1; no_close_list[i] = -1;
/* Connect to the agent and perform initial handshaking. */ /* Connect to the agent and perform initial handshaking. */
err = assuan_pipe_connect (ctx, agent_program, argv, err = assuan_pipe_connect (ctx, agent_program, argv,
no_close_list, NULL, NULL, 0); no_close_list, NULL, NULL, 0);
@ -566,7 +566,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
assuan_context_t ctx; assuan_context_t ctx;
const char *sockname; const char *sockname;
int did_success_msg = 0; int did_success_msg = 0;
*r_ctx = NULL; *r_ctx = NULL;
err = assuan_new (&ctx); err = assuan_new (&ctx);
@ -595,11 +595,11 @@ start_new_dirmngr (assuan_context_t *r_ctx,
if (verbose) if (verbose)
log_info (_("no running Dirmngr - starting `%s'\n"), log_info (_("no running Dirmngr - starting `%s'\n"),
dirmngr_program); dirmngr_program);
if (status_cb) if (status_cb)
status_cb (status_cb_arg, STATUS_PROGRESS, status_cb (status_cb_arg, STATUS_PROGRESS,
"starting_dirmngr ? 0 0", NULL); "starting_dirmngr ? 0 0", NULL);
if (fflush (NULL)) if (fflush (NULL))
{ {
gpg_error_t tmperr = gpg_err_make (errsource, gpg_error_t tmperr = gpg_err_make (errsource,
@ -609,10 +609,10 @@ start_new_dirmngr (assuan_context_t *r_ctx,
assuan_release (ctx); assuan_release (ctx);
return tmperr; return tmperr;
} }
argv[0] = "--daemon"; argv[0] = "--daemon";
argv[1] = NULL; argv[1] = NULL;
if (!(err = lock_spawning (&lock, homedir, "dirmngr", verbose)) if (!(err = lock_spawning (&lock, homedir, "dirmngr", verbose))
&& assuan_socket_connect (ctx, sockname, 0, 0)) && assuan_socket_connect (ctx, sockname, 0, 0))
{ {
@ -623,7 +623,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
else else
{ {
int i; int i;
for (i=0; i < SECS_TO_WAIT_FOR_DIRMNGR; i++) for (i=0; i < SECS_TO_WAIT_FOR_DIRMNGR; i++)
{ {
if (verbose) if (verbose)
@ -645,7 +645,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
} }
} }
} }
unlock_spawning (&lock, "dirmngr"); unlock_spawning (&lock, "dirmngr");
} }
#else #else
@ -655,7 +655,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
(void)status_cb; (void)status_cb;
(void)status_cb_arg; (void)status_cb_arg;
#endif /*USE_DIRMNGR_AUTO_START*/ #endif /*USE_DIRMNGR_AUTO_START*/
if (err) if (err)
{ {
log_error ("connecting dirmngr at `%s' failed: %s\n", log_error ("connecting dirmngr at `%s' failed: %s\n",
@ -670,4 +670,3 @@ start_new_dirmngr (assuan_context_t *r_ctx,
*r_ctx = ctx; *r_ctx = ctx;
return 0; return 0;
} }

View File

@ -57,7 +57,7 @@ struct audit_ctx_s
{ {
const char *failure; /* If set a description of the internal failure. */ const char *failure; /* If set a description of the internal failure. */
audit_type_t type; audit_type_t type;
log_item_t log; /* The table with the log entries. */ log_item_t log; /* The table with the log entries. */
size_t logsize; /* The allocated size for LOG. */ size_t logsize; /* The allocated size for LOG. */
size_t logused; /* The used size of LOG. */ size_t logused; /* The used size of LOG. */
@ -71,17 +71,17 @@ struct audit_ctx_s
static void writeout_para (audit_ctx_t ctx, static void writeout_para (audit_ctx_t ctx,
const char *format, ...) JNLIB_GCC_A_PRINTF(2,3); const char *format, ...) JNLIB_GCC_A_PRINTF(2,3);
static void writeout_li (audit_ctx_t ctx, const char *oktext, static void writeout_li (audit_ctx_t ctx, const char *oktext,
const char *format, ...) JNLIB_GCC_A_PRINTF(3,4); const char *format, ...) JNLIB_GCC_A_PRINTF(3,4);
static void writeout_rem (audit_ctx_t ctx, static void writeout_rem (audit_ctx_t ctx,
const char *format, ...) JNLIB_GCC_A_PRINTF(2,3); const char *format, ...) JNLIB_GCC_A_PRINTF(2,3);
/* Add NAME to the list of help tags. NAME needs to be a const string /* Add NAME to the list of help tags. NAME needs to be a const string
an this function merly stores this pointer. */ an this function merly stores this pointer. */
static void static void
add_helptag (audit_ctx_t ctx, const char *name) add_helptag (audit_ctx_t ctx, const char *name)
{ {
helptag_t item; helptag_t item;
@ -127,7 +127,7 @@ event2str (audit_event_t event)
/* Create a new audit context. In case of an error NULL is returned /* Create a new audit context. In case of an error NULL is returned
and errno set appropriately. */ and errno set appropriately. */
audit_ctx_t audit_ctx_t
audit_new (void) audit_new (void)
{ {
@ -228,7 +228,7 @@ create_log_item (audit_ctx_t ctx)
item->cert = NULL; item->cert = NULL;
return item; return item;
} }
/* Add a new event to the audit log. If CTX is NULL, this function /* Add a new event to the audit log. If CTX is NULL, this function
@ -329,7 +329,7 @@ audit_log_s (audit_ctx_t ctx, audit_event_t event, const char *value)
does nothing. This version also adds the certificate CERT and the does nothing. This version also adds the certificate CERT and the
result of an operation to the log. */ result of an operation to the log. */
void void
audit_log_cert (audit_ctx_t ctx, audit_event_t event, audit_log_cert (audit_ctx_t ctx, audit_event_t event,
ksba_cert_t cert, gpg_error_t err) ksba_cert_t cert, gpg_error_t err)
{ {
log_item_t item; log_item_t item;
@ -348,14 +348,14 @@ audit_log_cert (audit_ctx_t ctx, audit_event_t event,
item->have_err = 1; item->have_err = 1;
if (cert) if (cert)
{ {
ksba_cert_ref (cert); ksba_cert_ref (cert);
item->cert = cert; item->cert = cert;
} }
} }
/* Write TEXT to the outstream. */ /* Write TEXT to the outstream. */
static void static void
writeout (audit_ctx_t ctx, const char *text) writeout (audit_ctx_t ctx, const char *text)
{ {
if (ctx->use_html) if (ctx->use_html)
@ -376,7 +376,7 @@ writeout (audit_ctx_t ctx, const char *text)
/* Write TEXT to the outstream using a variable argument list. */ /* Write TEXT to the outstream using a variable argument list. */
static void static void
writeout_v (audit_ctx_t ctx, const char *format, va_list arg_ptr) writeout_v (audit_ctx_t ctx, const char *format, va_list arg_ptr)
{ {
char *buf; char *buf;
@ -440,7 +440,7 @@ leave_li (audit_ctx_t ctx)
} }
} }
/* Write TEXT as a list element. If OKTEXT is not NULL, append it to /* Write TEXT as a list element. If OKTEXT is not NULL, append it to
the last line. */ the last line. */
static void static void
@ -451,7 +451,7 @@ writeout_li (audit_ctx_t ctx, const char *oktext, const char *format, ...)
if (ctx->use_html && format && oktext) if (ctx->use_html && format && oktext)
{ {
if (!strcmp (oktext, "Yes") if (!strcmp (oktext, "Yes")
|| !strcmp (oktext, "good") ) || !strcmp (oktext, "good") )
color = "green"; color = "green";
else if (!strcmp (oktext, "No") else if (!strcmp (oktext, "No")
@ -530,13 +530,13 @@ writeout_li (audit_ctx_t ctx, const char *oktext, const char *format, ...)
if (color) if (color)
es_fprintf (ctx->outstream, "<font color=\"%s\">", color); es_fprintf (ctx->outstream, "<font color=\"%s\">", color);
} }
else else
writeout (ctx, ": "); writeout (ctx, ": ");
writeout (ctx, oktext); writeout (ctx, oktext);
if (color) if (color)
es_fputs ("</font>", ctx->outstream); es_fputs ("</font>", ctx->outstream);
} }
if (ctx->use_html) if (ctx->use_html)
es_fputs ("</td></tr>\n", ctx->outstream); es_fputs ("</td></tr>\n", ctx->outstream);
else else
@ -579,7 +579,7 @@ writeout_rem (audit_ctx_t ctx, const char *format, ...)
look behind that event in the log. If STARTITEM is not NULL start look behind that event in the log. If STARTITEM is not NULL start
search _after_that item. */ search _after_that item. */
static log_item_t static log_item_t
find_next_log_item (audit_ctx_t ctx, log_item_t startitem, find_next_log_item (audit_ctx_t ctx, log_item_t startitem,
audit_event_t event, audit_event_t stopevent) audit_event_t event, audit_event_t stopevent)
{ {
int idx; int idx;
@ -725,9 +725,9 @@ list_certchain (audit_ctx_t ctx, log_item_t startitem, audit_event_t stopevent)
startitem = find_next_log_item (ctx, startitem, AUDIT_CHAIN_BEGIN,stopevent); startitem = find_next_log_item (ctx, startitem, AUDIT_CHAIN_BEGIN,stopevent);
writeout_li (ctx, startitem? "Yes":"No", _("Certificate chain available")); writeout_li (ctx, startitem? "Yes":"No", _("Certificate chain available"));
if (!startitem) if (!startitem)
return; return;
item = find_next_log_item (ctx, startitem, item = find_next_log_item (ctx, startitem,
AUDIT_CHAIN_ROOTCERT, AUDIT_CHAIN_END); AUDIT_CHAIN_ROOTCERT, AUDIT_CHAIN_END);
if (!item) if (!item)
writeout_rem (ctx, "%s", _("root certificate missing")); writeout_rem (ctx, "%s", _("root certificate missing"));
@ -736,7 +736,7 @@ list_certchain (audit_ctx_t ctx, log_item_t startitem, audit_event_t stopevent)
list_cert (ctx, item->cert, 0); list_cert (ctx, item->cert, 0);
} }
item = startitem; item = startitem;
while ( ((item = find_next_log_item (ctx, item, while ( ((item = find_next_log_item (ctx, item,
AUDIT_CHAIN_CERT, AUDIT_CHAIN_END)))) AUDIT_CHAIN_CERT, AUDIT_CHAIN_END))))
{ {
list_cert (ctx, item->cert, 1); list_cert (ctx, item->cert, 1);
@ -779,7 +779,7 @@ proc_type_encrypt (audit_ctx_t ctx)
} }
item = find_log_item (ctx, AUDIT_GOT_RECIPIENTS, 0); item = find_log_item (ctx, AUDIT_GOT_RECIPIENTS, 0);
snprintf (numbuf, sizeof numbuf, "%d", snprintf (numbuf, sizeof numbuf, "%d",
item && item->have_intvalue? item->intvalue : 0); item && item->have_intvalue? item->intvalue : 0);
writeout_li (ctx, numbuf, "%s", _("Number of recipients")); writeout_li (ctx, numbuf, "%s", _("Number of recipients"));
@ -830,7 +830,7 @@ proc_type_sign (audit_ctx_t ctx)
writeout_li (ctx, item? "Yes":"No", "%s", _("Data available")); writeout_li (ctx, item? "Yes":"No", "%s", _("Data available"));
/* Write remarks with the data hash algorithms. We use a very /* Write remarks with the data hash algorithms. We use a very
simple scheme to avoid some duplicates. */ simple scheme to avoid some duplicates. */
loopitem = NULL; loopitem = NULL;
lastalgo = 0; lastalgo = 0;
while ((loopitem = find_next_log_item while ((loopitem = find_next_log_item
(ctx, loopitem, AUDIT_DATA_HASH_ALGO, AUDIT_NEW_SIG))) (ctx, loopitem, AUDIT_DATA_HASH_ALGO, AUDIT_NEW_SIG)))
@ -1033,7 +1033,7 @@ proc_type_verify (audit_ctx_t ctx)
writeout_rem (ctx, _("data hash algorithm: %s"), writeout_rem (ctx, _("data hash algorithm: %s"),
gcry_md_algo_name (item->intvalue)); gcry_md_algo_name (item->intvalue));
else if (item->event == AUDIT_BAD_DATA_HASH_ALGO) else if (item->event == AUDIT_BAD_DATA_HASH_ALGO)
writeout_rem (ctx, _("bad data hash algorithm: %s"), writeout_rem (ctx, _("bad data hash algorithm: %s"),
item->string? item->string:"?"); item->string? item->string:"?");
} }
} }
@ -1066,7 +1066,7 @@ proc_type_verify (audit_ctx_t ctx)
gcry_md_algo_name (item->intvalue)); gcry_md_algo_name (item->intvalue));
enter_li (ctx); enter_li (ctx);
/* List the certificate chain. */ /* List the certificate chain. */
list_certchain (ctx, loopitem, AUDIT_NEW_SIG); list_certchain (ctx, loopitem, AUDIT_NEW_SIG);
@ -1075,12 +1075,12 @@ proc_type_verify (audit_ctx_t ctx)
AUDIT_CHAIN_STATUS, AUDIT_NEW_SIG); AUDIT_CHAIN_STATUS, AUDIT_NEW_SIG);
if (item && item->have_err) if (item && item->have_err)
{ {
writeout_li (ctx, item->err? "No":"Yes", writeout_li (ctx, item->err? "No":"Yes",
_("Certificate chain valid")); _("Certificate chain valid"));
if (item->err) if (item->err)
writeout_rem (ctx, "%s", gpg_strerror (item->err)); writeout_rem (ctx, "%s", gpg_strerror (item->err));
} }
/* Show whether the root certificate is fine. */ /* Show whether the root certificate is fine. */
item = find_next_log_item (ctx, loopitem, item = find_next_log_item (ctx, loopitem,
AUDIT_ROOT_TRUSTED, AUDIT_CHAIN_STATUS); AUDIT_ROOT_TRUSTED, AUDIT_CHAIN_STATUS);
@ -1115,9 +1115,9 @@ proc_type_verify (audit_ctx_t ctx)
break; break;
default: ok = gpg_strerror (item->err); break; default: ok = gpg_strerror (item->err); break;
} }
writeout_li (ctx, ok, "%s", _("CRL/OCSP check of certificates")); writeout_li (ctx, ok, "%s", _("CRL/OCSP check of certificates"));
if (item->err if (item->err
&& gpg_err_code (item->err) != GPG_ERR_CERT_REVOKED && gpg_err_code (item->err) != GPG_ERR_CERT_REVOKED
&& gpg_err_code (item->err) != GPG_ERR_NOT_ENABLED) && gpg_err_code (item->err) != GPG_ERR_NOT_ENABLED)
add_helptag (ctx, "gpgsm.crl-problem"); add_helptag (ctx, "gpgsm.crl-problem");
@ -1132,13 +1132,13 @@ proc_type_verify (audit_ctx_t ctx)
/* Always list the certificates stored in the signature. */ /* Always list the certificates stored in the signature. */
item = NULL; item = NULL;
count = 0; count = 0;
while ( ((item = find_next_log_item (ctx, item, while ( ((item = find_next_log_item (ctx, item,
AUDIT_SAVE_CERT, AUDIT_NEW_SIG)))) AUDIT_SAVE_CERT, AUDIT_NEW_SIG))))
count++; count++;
snprintf (numbuf, sizeof numbuf, "%d", count); snprintf (numbuf, sizeof numbuf, "%d", count);
writeout_li (ctx, numbuf, _("Included certificates")); writeout_li (ctx, numbuf, _("Included certificates"));
item = NULL; item = NULL;
while ( ((item = find_next_log_item (ctx, item, while ( ((item = find_next_log_item (ctx, item,
AUDIT_SAVE_CERT, AUDIT_NEW_SIG)))) AUDIT_SAVE_CERT, AUDIT_NEW_SIG))))
{ {
char *name = get_cert_name (item->cert); char *name = get_cert_name (item->cert);
@ -1169,7 +1169,7 @@ audit_print_result (audit_ctx_t ctx, estream_t out, int use_html)
const char *s; const char *s;
int show_raw = 0; int show_raw = 0;
char *orig_codeset; char *orig_codeset;
if (!ctx) if (!ctx)
return; return;
@ -1201,31 +1201,31 @@ audit_print_result (audit_ctx_t ctx, estream_t out, int use_html)
for (idx=0,maxlen=0; idx < DIM (eventstr_msgidx); idx++) for (idx=0,maxlen=0; idx < DIM (eventstr_msgidx); idx++)
{ {
n = strlen (eventstr_msgstr + eventstr_msgidx[idx]); n = strlen (eventstr_msgstr + eventstr_msgidx[idx]);
if (n > maxlen) if (n > maxlen)
maxlen = n; maxlen = n;
} }
if (use_html) if (use_html)
es_fputs ("<pre>\n", out); es_fputs ("<pre>\n", out);
for (idx=0; idx < ctx->logused; idx++) for (idx=0; idx < ctx->logused; idx++)
{ {
es_fprintf (out, "log: %-*s", es_fprintf (out, "log: %-*s",
maxlen, event2str (ctx->log[idx].event)); maxlen, event2str (ctx->log[idx].event));
if (ctx->log[idx].have_intvalue) if (ctx->log[idx].have_intvalue)
es_fprintf (out, " i=%d", ctx->log[idx].intvalue); es_fprintf (out, " i=%d", ctx->log[idx].intvalue);
if (ctx->log[idx].string) if (ctx->log[idx].string)
{ {
es_fputs (" s=`", out); es_fputs (" s=`", out);
writeout (ctx, ctx->log[idx].string); writeout (ctx, ctx->log[idx].string);
es_fputs ("'", out); es_fputs ("'", out);
} }
if (ctx->log[idx].cert) if (ctx->log[idx].cert)
es_fprintf (out, " has_cert"); es_fprintf (out, " has_cert");
if (ctx->log[idx].have_err) if (ctx->log[idx].have_err)
{ {
es_fputs (" err=`", out); es_fputs (" err=`", out);
writeout (ctx, gpg_strerror (ctx->log[idx].err)); writeout (ctx, gpg_strerror (ctx->log[idx].err));
es_fputs ("'", out); es_fputs ("'", out);
} }
es_fputs ("\n", out); es_fputs ("\n", out);
@ -1321,4 +1321,3 @@ audit_print_result (audit_ctx_t ctx, estream_t out, int use_html)
clear_helptags (ctx); clear_helptags (ctx);
i18n_switchback (orig_codeset); i18n_switchback (orig_codeset);
} }

View File

@ -56,7 +56,7 @@ typedef enum
/* Indicates whether the gpg-agent is available. For some /* Indicates whether the gpg-agent is available. For some
operations the agent is not required and thus no such event operations the agent is not required and thus no such event
will be logged. */ will be logged. */
AUDIT_DIRMNGR_READY, /* err */ AUDIT_DIRMNGR_READY, /* err */
/* Indicates whether the Dirmngr is available. For some /* Indicates whether the Dirmngr is available. For some
operations the Dirmngr is not required and thus no such event operations the Dirmngr is not required and thus no such event
@ -115,7 +115,7 @@ typedef enum
/* The program was used in an inappropriate way; For example by /* The program was used in an inappropriate way; For example by
passing a data object while the signature does not expect one passing a data object while the signature does not expect one
or vice versa. */ or vice versa. */
AUDIT_SAVE_CERT, /* cert, ok_err */ AUDIT_SAVE_CERT, /* cert, ok_err */
/* Save the certificate received in a message. */ /* Save the certificate received in a message. */
@ -123,7 +123,7 @@ typedef enum
/* Start the verification of a new signature for the last data /* Start the verification of a new signature for the last data
object. The argument is the signature number as used object. The argument is the signature number as used
internally by the program. */ internally by the program. */
AUDIT_SIG_NAME, /* string */ AUDIT_SIG_NAME, /* string */
/* The name of a signer. This is the name or other identification /* The name of a signer. This is the name or other identification
data as known from the signature and not the name from the data as known from the signature and not the name from the
@ -135,7 +135,7 @@ typedef enum
audit information for one signature. STRING gives the status: audit information for one signature. STRING gives the status:
"error" - there was a problem checking this or any signature. "error" - there was a problem checking this or any signature.
"unsupported" - the signature type is not supported. "unsupported" - the signature type is not supported.
"no-cert" - The certificate of the signer was not found (the "no-cert" - The certificate of the signer was not found (the
S/N+issuer of the signer is already in the log). S/N+issuer of the signer is already in the log).
"bad" - bad signature "bad" - bad signature
@ -145,7 +145,7 @@ typedef enum
AUDIT_NEW_RECP, /* int */ AUDIT_NEW_RECP, /* int */
/* A new recipient has been seen during decryption. The argument /* A new recipient has been seen during decryption. The argument
is the recipient number as used internally by the program. */ is the recipient number as used internally by the program. */
AUDIT_RECP_NAME, /* string */ AUDIT_RECP_NAME, /* string */
/* The name of a recipient. This is the name or other identification /* The name of a recipient. This is the name or other identification
data as known from the decryption and not the name from the data as known from the decryption and not the name from the
@ -169,7 +169,7 @@ typedef enum
AUDIT_CHAIN_END, AUDIT_CHAIN_END,
/* These 4 events are used to log the certificates making up a /* These 4 events are used to log the certificates making up a
certificate chain. ROOTCERT is used for the trustanchor and certificate chain. ROOTCERT is used for the trustanchor and
CERT for all other certificates. */ CERT for all other certificates. */
AUDIT_CHAIN_STATUS, /* err */ AUDIT_CHAIN_STATUS, /* err */
/* Tells the final status of the chain validation. */ /* Tells the final status of the chain validation. */
@ -217,7 +217,7 @@ void audit_log (audit_ctx_t ctx, audit_event_t event);
void audit_log_ok (audit_ctx_t ctx, audit_event_t event, gpg_error_t err); void audit_log_ok (audit_ctx_t ctx, audit_event_t event, gpg_error_t err);
void audit_log_i (audit_ctx_t ctx, audit_event_t event, int value); void audit_log_i (audit_ctx_t ctx, audit_event_t event, int value);
void audit_log_s (audit_ctx_t ctx, audit_event_t event, const char *value); void audit_log_s (audit_ctx_t ctx, audit_event_t event, const char *value);
void audit_log_cert (audit_ctx_t ctx, audit_event_t event, void audit_log_cert (audit_ctx_t ctx, audit_event_t event,
ksba_cert_t cert, gpg_error_t err); ksba_cert_t cert, gpg_error_t err);
void audit_print_result (audit_ctx_t ctx, estream_t stream, int use_html); void audit_print_result (audit_ctx_t ctx, estream_t stream, int use_html);

View File

@ -29,7 +29,7 @@
/* The reverse base-64 list used for base-64 decoding. */ /* The reverse base-64 list used for base-64 decoding. */
static unsigned char const asctobin[128] = static unsigned char const asctobin[128] =
{ {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
@ -49,7 +49,7 @@ static unsigned char const asctobin[128] =
0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff
}; };
enum decoder_states enum decoder_states
{ {
s_init, s_idle, s_lfseen, s_begin, s_init, s_idle, s_lfseen, s_begin,
s_b64_0, s_b64_1, s_b64_2, s_b64_3, s_b64_0, s_b64_1, s_b64_2, s_b64_3,
@ -62,7 +62,7 @@ enum decoder_states
plain base64 decoding is done. If it is the empty string the plain base64 decoding is done. If it is the empty string the
decoder will skip everything until a "-----BEGIN " line has been decoder will skip everything until a "-----BEGIN " line has been
seen, decoding ends at a "----END " line. seen, decoding ends at a "----END " line.
Not yet implemented: If TITLE is either "PGP" or begins with "PGP " Not yet implemented: If TITLE is either "PGP" or begins with "PGP "
the PGP armor lines are skipped as well. */ the PGP armor lines are skipped as well. */
gpg_error_t gpg_error_t
@ -96,7 +96,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length,
{ {
enum decoder_states ds = state->idx; enum decoder_states ds = state->idx;
unsigned char val = state->radbuf[0]; unsigned char val = state->radbuf[0];
int pos = state->quad_count; int pos = state->quad_count;
char *d, *s; char *d, *s;
if (state->lasterr) if (state->lasterr)
@ -110,7 +110,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length,
state->title = NULL; state->title = NULL;
return state->lasterr; return state->lasterr;
} }
for (s=d=buffer; length && !state->stop_seen; length--, s++) for (s=d=buffer; length && !state->stop_seen; length--, s++)
{ {
switch (ds) switch (ds)
@ -143,7 +143,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length,
{ {
int c; int c;
if (*s == '-' && state->title) if (*s == '-' && state->title)
{ {
/* Not a valid Base64 character: assume end /* Not a valid Base64 character: assume end
header. */ header. */
@ -158,7 +158,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length,
} }
else if (*s == '\n' || *s == ' ' || *s == '\r' || *s == '\t') else if (*s == '\n' || *s == ' ' || *s == '\r' || *s == '\t')
; /* Skip white spaces. */ ; /* Skip white spaces. */
else if ( (*s & 0x80) else if ( (*s & 0x80)
|| (c = asctobin[*(unsigned char *)s]) == 255) || (c = asctobin[*(unsigned char *)s]) == 255)
{ {
/* Skip invalid encodings. */ /* Skip invalid encodings. */
@ -198,8 +198,8 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length,
case s_waitend: case s_waitend:
if ( *s == '\n') if ( *s == '\n')
state->stop_seen = 1; state->stop_seen = 1;
break; break;
default: default:
BUG(); BUG();
} }
} }
@ -207,7 +207,7 @@ b64dec_proc (struct b64state *state, void *buffer, size_t length,
state->idx = ds; state->idx = ds;
state->radbuf[0] = val; state->radbuf[0] = val;
state->quad_count = pos; state->quad_count = pos;
*r_nbytes = (d -(char*) buffer); *r_nbytes = (d -(char*) buffer);
return 0; return 0;
} }
@ -226,4 +226,3 @@ b64dec_finish (struct b64state *state)
state->title = NULL; state->title = NULL;
return state->invalid_encoding? gpg_error(GPG_ERR_BAD_DATA): 0; return state->invalid_encoding? gpg_error(GPG_ERR_BAD_DATA): 0;
} }

View File

@ -34,25 +34,25 @@
#define B64ENC_USE_PGPCRC 32 #define B64ENC_USE_PGPCRC 32
/* The base-64 character list */ /* The base-64 character list */
static unsigned char bintoasc[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" static unsigned char bintoasc[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
"0123456789+/"; "0123456789+/";
/* Stuff required to create the OpenPGP CRC. This crc_table has been /* Stuff required to create the OpenPGP CRC. This crc_table has been
created using this code: created using this code:
#include <stdio.h> #include <stdio.h>
#include <stdint.h> #include <stdint.h>
#define CRCPOLY 0x864CFB #define CRCPOLY 0x864CFB
int int
main (void) main (void)
{ {
int i, j; int i, j;
uint32_t t; uint32_t t;
uint32_t crc_table[256]; uint32_t crc_table[256];
crc_table[0] = 0; crc_table[0] = 0;
for (i=j=0; j < 128; j++ ) for (i=j=0; j < 128; j++ )
{ {
@ -70,7 +70,7 @@ static unsigned char bintoasc[64] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
crc_table[i++] = t ^ CRCPOLY; crc_table[i++] = t ^ CRCPOLY;
} }
} }
puts ("static const u32 crc_table[256] = {"); puts ("static const u32 crc_table[256] = {");
for (i=j=0; i < 256; i++) for (i=j=0; i < 256; i++)
{ {
@ -224,11 +224,11 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes)
|| my_fputs (state->title, state) == EOF || my_fputs (state->title, state) == EOF
|| my_fputs ("-----\n", state) == EOF) || my_fputs ("-----\n", state) == EOF)
goto write_error; goto write_error;
if ( (state->flags & B64ENC_USE_PGPCRC) if ( (state->flags & B64ENC_USE_PGPCRC)
&& my_fputs ("\n", state) == EOF) && my_fputs ("\n", state) == EOF)
goto write_error; goto write_error;
} }
state->flags |= B64ENC_DID_HEADER; state->flags |= B64ENC_DID_HEADER;
} }
@ -274,7 +274,7 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes)
if (ferror (state->fp)) if (ferror (state->fp))
goto write_error; goto write_error;
} }
if (++quad_count >= (64/4)) if (++quad_count >= (64/4))
{ {
quad_count = 0; quad_count = 0;
if (!(state->flags & B64ENC_NO_LINEFEEDS) if (!(state->flags & B64ENC_NO_LINEFEEDS)
@ -328,8 +328,8 @@ b64enc_finish (struct b64state *state)
tmp[2] = '='; tmp[2] = '=';
tmp[3] = '='; tmp[3] = '=';
} }
else else
{ {
tmp[1] = bintoasc[(((*radbuf<<4)&060)|((radbuf[1]>>4)&017))&077]; tmp[1] = bintoasc[(((*radbuf<<4)&060)|((radbuf[1]>>4)&017))&077];
tmp[2] = bintoasc[((radbuf[1] << 2) & 074) & 077]; tmp[2] = bintoasc[((radbuf[1] << 2) & 074) & 077];
tmp[3] = '='; tmp[3] = '=';
@ -351,7 +351,7 @@ b64enc_finish (struct b64state *state)
goto write_error; goto write_error;
} }
if (++quad_count >= (64/4)) if (++quad_count >= (64/4))
{ {
quad_count = 0; quad_count = 0;
if (!(state->flags & B64ENC_NO_LINEFEEDS) if (!(state->flags & B64ENC_NO_LINEFEEDS)
@ -365,7 +365,7 @@ b64enc_finish (struct b64state *state)
&& !(state->flags & B64ENC_NO_LINEFEEDS) && !(state->flags & B64ENC_NO_LINEFEEDS)
&& my_fputs ("\n", state) == EOF) && my_fputs ("\n", state) == EOF)
goto write_error; goto write_error;
if ( (state->flags & B64ENC_USE_PGPCRC) ) if ( (state->flags & B64ENC_USE_PGPCRC) )
{ {
/* Write the CRC. */ /* Write the CRC. */
@ -420,4 +420,3 @@ b64enc_finish (struct b64state *state)
state->lasterr = err; state->lasterr = err;
return err; return err;
} }

View File

@ -82,7 +82,7 @@ get_dns_cert (const char *name, size_t max_size, IOBUF *iobuf,
adns_finish (state); adns_finish (state);
return -1; return -1;
} }
if (answer->status != adns_s_ok) if (answer->status != adns_s_ok)
{ {
/* log_error ("DNS query returned an error: %s (%s)\n", */ /* log_error ("DNS query returned an error: %s (%s)\n", */
/* adns_strerror (answer->status), */ /* adns_strerror (answer->status), */
@ -112,7 +112,7 @@ get_dns_cert (const char *name, size_t max_size, IOBUF *iobuf,
*iobuf = iobuf_temp_with_content ((char*)data, datalen); *iobuf = iobuf_temp_with_content ((char*)data, datalen);
rc = 1; rc = 1;
} }
else if (ctype == 6 && datalen && datalen < 1023 else if (ctype == 6 && datalen && datalen < 1023
&& datalen >= data[0]+1 && fpr && fpr_len && url) && datalen >= data[0]+1 && fpr && fpr_len && url)
{ {
/* CERT type is IPGP. We made sure tha the data is /* CERT type is IPGP. We made sure tha the data is
@ -126,7 +126,7 @@ get_dns_cert (const char *name, size_t max_size, IOBUF *iobuf,
} }
else else
*fpr = NULL; *fpr = NULL;
if (datalen > *fpr_len + 1) if (datalen > *fpr_len + 1)
{ {
*url = xmalloc (datalen - (*fpr_len+1) + 1); *url = xmalloc (datalen - (*fpr_len+1) + 1);
@ -135,11 +135,11 @@ get_dns_cert (const char *name, size_t max_size, IOBUF *iobuf,
} }
else else
*url = NULL; *url = NULL;
rc = 2; rc = 2;
} }
} }
adns_free (answer); adns_free (answer);
adns_finish (state); adns_finish (state);
return rc; return rc;

View File

@ -1,5 +1,5 @@
/* dotlock.c - dotfile locking /* dotlock.c - dotfile locking
* Copyright (C) 1998, 2000, 2001, 2003, 2004, * Copyright (C) 1998, 2000, 2001, 2003, 2004,
* 2005, 2006, 2008, 2010 Free Software Foundation, Inc. * 2005, 2006, 2008, 2010 Free Software Foundation, Inc.
* *
* This file is part of JNLIB. * This file is part of JNLIB.
@ -61,7 +61,7 @@
/* The object describing a lock. */ /* The object describing a lock. */
struct dotlock_handle struct dotlock_handle
{ {
struct dotlock_handle *next; struct dotlock_handle *next;
char *lockname; /* Name of the actual lockfile. */ char *lockname; /* Name of the actual lockfile. */
@ -112,7 +112,7 @@ disable_dotlock(void)
Calling this function with NULL does only install the atexit Calling this function with NULL does only install the atexit
handler and may thus be used to assure that the cleanup is called handler and may thus be used to assure that the cleanup is called
after all other atexit handlers. after all other atexit handlers.
This function creates a lock file in the same directory as This function creates a lock file in the same directory as
FILE_TO_LOCK using that name and a suffix of ".lock". Note that on FILE_TO_LOCK using that name and a suffix of ".lock". Note that on
POSIX systems a temporary file ".#lk.<hostname>.pid[.threadid] is POSIX systems a temporary file ".#lk.<hostname>.pid[.threadid] is
@ -174,7 +174,7 @@ create_dotlock (const char *file_to_lock)
nodename = "unknown"; nodename = "unknown";
else else
nodename = utsbuf.nodename; nodename = utsbuf.nodename;
#ifdef __riscos__ #ifdef __riscos__
{ {
char *iter = (char *) nodename; char *iter = (char *) nodename;
@ -223,15 +223,15 @@ create_dotlock (const char *file_to_lock)
"%s/%d", nodename, (int)getpid () ); "%s/%d", nodename, (int)getpid () );
#endif /* __riscos__ */ #endif /* __riscos__ */
do do
{ {
jnlib_set_errno (0); jnlib_set_errno (0);
fd = open (h->tname, O_WRONLY|O_CREAT|O_EXCL, fd = open (h->tname, O_WRONLY|O_CREAT|O_EXCL,
S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR ); S_IRUSR|S_IRGRP|S_IROTH|S_IWUSR );
} }
while (fd == -1 && errno == EINTR); while (fd == -1 && errno == EINTR);
if ( fd == -1 ) if ( fd == -1 )
{ {
all_lockfiles = h->next; all_lockfiles = h->next;
log_error (_("failed to create temporary file `%s': %s\n"), log_error (_("failed to create temporary file `%s': %s\n"),
@ -303,11 +303,11 @@ create_dotlock (const char *file_to_lock)
reasons why a lock file can't be created and thus the process reasons why a lock file can't be created and thus the process
would not stop as expected but spin til until Windows crashes. would not stop as expected but spin til until Windows crashes.
Our solution is to keep the lock file open; that does not Our solution is to keep the lock file open; that does not
harm. */ harm. */
{ {
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
wchar_t *wname = utf8_to_wchar (h->lockname); wchar_t *wname = utf8_to_wchar (h->lockname);
h->lockhd = INVALID_HANDLE_VALUE; h->lockhd = INVALID_HANDLE_VALUE;
if (wname) if (wname)
h->lockhd = CreateFile (wname, h->lockhd = CreateFile (wname,
@ -318,7 +318,7 @@ create_dotlock (const char *file_to_lock)
FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_ALWAYS, 0, NULL); NULL, OPEN_ALWAYS, 0, NULL);
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
jnlib_free (wname); jnlib_free (wname);
#endif #endif
} }
if (h->lockhd == INVALID_HANDLE_VALUE) if (h->lockhd == INVALID_HANDLE_VALUE)
@ -355,7 +355,7 @@ destroy_dotlock (dotlock_t h)
h->next = NULL; h->next = NULL;
break; break;
} }
/* Then destroy the lock. */ /* Then destroy the lock. */
if (!h->disable) if (!h->disable)
{ {
@ -364,7 +364,7 @@ destroy_dotlock (dotlock_t h)
{ {
OVERLAPPED ovl; OVERLAPPED ovl;
memset (&ovl, 0, sizeof ovl); memset (&ovl, 0, sizeof ovl);
UnlockFileEx (h->lockhd, 0, 1, 0, &ovl); UnlockFileEx (h->lockhd, 0, 1, 0, &ovl);
} }
CloseHandle (h->lockhd); CloseHandle (h->lockhd);
@ -414,7 +414,7 @@ make_dotlock (dotlock_t h, long timeout)
if ( h->disable ) if ( h->disable )
return 0; /* Locks are completely disabled. Return success. */ return 0; /* Locks are completely disabled. Return success. */
if ( h->locked ) if ( h->locked )
{ {
#ifndef __riscos__ #ifndef __riscos__
log_debug ("Oops, `%s' is already locked\n", h->lockname); log_debug ("Oops, `%s' is already locked\n", h->lockname);
@ -438,19 +438,19 @@ make_dotlock (dotlock_t h, long timeout)
return -1; return -1;
} }
# else /* __riscos__ */ # else /* __riscos__ */
if ( !renamefile(h->tname, h->lockname) ) if ( !renamefile(h->tname, h->lockname) )
{ {
h->locked = 1; h->locked = 1;
return 0; /* okay */ return 0; /* okay */
} }
if ( errno != EEXIST ) if ( errno != EEXIST )
{ {
log_error( "lock not made: rename() failed: %s\n", strerror(errno) ); log_error( "lock not made: rename() failed: %s\n", strerror(errno) );
return -1; return -1;
} }
# endif /* __riscos__ */ # endif /* __riscos__ */
if ( (pid = read_lockfile (h, &same_node)) == -1 ) if ( (pid = read_lockfile (h, &same_node)) == -1 )
{ {
if ( errno != ENOENT ) if ( errno != ENOENT )
{ {
@ -480,11 +480,11 @@ make_dotlock (dotlock_t h, long timeout)
# endif /* __riscos__ */ # endif /* __riscos__ */
} }
if ( timeout == -1 ) if ( timeout == -1 )
{ {
/* Wait until lock has been released. */ /* Wait until lock has been released. */
struct timeval tv; struct timeval tv;
log_info (_("waiting for lock (held by %d%s) %s...\n"), log_info (_("waiting for lock (held by %d%s) %s...\n"),
pid, maybe_dead, maybe_deadlock(h)? _("(deadlock?) "):""); pid, maybe_dead, maybe_deadlock(h)? _("(deadlock?) "):"");
@ -503,7 +503,7 @@ make_dotlock (dotlock_t h, long timeout)
OVERLAPPED ovl; OVERLAPPED ovl;
/* Lock one byte at offset 0. The offset is given by OVL. */ /* Lock one byte at offset 0. The offset is given by OVL. */
memset (&ovl, 0, sizeof ovl); memset (&ovl, 0, sizeof ovl);
if (LockFileEx (h->lockhd, (LOCKFILE_EXCLUSIVE_LOCK if (LockFileEx (h->lockhd, (LOCKFILE_EXCLUSIVE_LOCK
| LOCKFILE_FAIL_IMMEDIATELY), 0, 1, 0, &ovl)) | LOCKFILE_FAIL_IMMEDIATELY), 0, 1, 0, &ovl))
{ {
@ -518,7 +518,7 @@ make_dotlock (dotlock_t h, long timeout)
return -1; return -1;
} }
if ( timeout == -1 ) if ( timeout == -1 )
{ {
/* Wait until lock has been released. */ /* Wait until lock has been released. */
log_info (_("waiting for lock %s...\n"), h->lockname); log_info (_("waiting for lock %s...\n"), h->lockname);
@ -561,8 +561,8 @@ release_dotlock (dotlock_t h)
#ifdef HAVE_DOSISH_SYSTEM #ifdef HAVE_DOSISH_SYSTEM
{ {
OVERLAPPED ovl; OVERLAPPED ovl;
memset (&ovl, 0, sizeof ovl); memset (&ovl, 0, sizeof ovl);
if (!UnlockFileEx (h->lockhd, 0, 1, 0, &ovl)) if (!UnlockFileEx (h->lockhd, 0, 1, 0, &ovl))
{ {
log_error ("release_dotlock: error removing lockfile `%s': %s\n", log_error ("release_dotlock: error removing lockfile `%s': %s\n",
@ -573,7 +573,7 @@ release_dotlock (dotlock_t h)
#else #else
pid = read_lockfile (h, &same_node); pid = read_lockfile (h, &same_node);
if ( pid == -1 ) if ( pid == -1 )
{ {
log_error( "release_dotlock: lockfile error\n"); log_error( "release_dotlock: lockfile error\n");
return -1; return -1;
@ -594,7 +594,7 @@ release_dotlock (dotlock_t h)
/* Fixme: As an extra check we could check whether the link count is /* Fixme: As an extra check we could check whether the link count is
now really at 1. */ now really at 1. */
#else /* __riscos__ */ #else /* __riscos__ */
if ( renamefile (h->lockname, h->tname) ) if ( renamefile (h->lockname, h->tname) )
{ {
log_error ("release_dotlock: error renaming lockfile `%s' to `%s'\n", log_error ("release_dotlock: error renaming lockfile `%s' to `%s'\n",
h->lockname, h->tname); h->lockname, h->tname);
@ -622,7 +622,7 @@ read_lockfile (dotlock_t h, int *same_node )
char *buffer, *p; char *buffer, *p;
size_t expected_len; size_t expected_len;
int res, nread; int res, nread;
*same_node = 0; *same_node = 0;
expected_len = 10 + 1 + h->nodename_len + 1; expected_len = 10 + 1 + h->nodename_len + 1;
if ( expected_len >= sizeof buffer_space) if ( expected_len >= sizeof buffer_space)
@ -655,7 +655,7 @@ read_lockfile (dotlock_t h, int *same_node )
if (res < 0) if (res < 0)
{ {
log_info ("error reading lockfile `%s'", h->lockname ); log_info ("error reading lockfile `%s'", h->lockname );
close (fd); close (fd);
if (buffer != buffer_space) if (buffer != buffer_space)
jnlib_free (buffer); jnlib_free (buffer);
jnlib_set_errno (0); /* Do not return an inappropriate ERRNO. */ jnlib_set_errno (0); /* Do not return an inappropriate ERRNO. */
@ -679,7 +679,7 @@ read_lockfile (dotlock_t h, int *same_node )
if (buffer[10] != '\n' if (buffer[10] != '\n'
|| (buffer[10] = 0, pid = atoi (buffer)) == -1 || (buffer[10] = 0, pid = atoi (buffer)) == -1
#ifndef __riscos__ #ifndef __riscos__
|| !pid || !pid
#else /* __riscos__ */ #else /* __riscos__ */
|| (!pid && riscos_getpid()) || (!pid && riscos_getpid())
#endif /* __riscos__ */ #endif /* __riscos__ */
@ -693,7 +693,7 @@ read_lockfile (dotlock_t h, int *same_node )
} }
if (nread == expected_len if (nread == expected_len
&& !memcmp (h->tname+h->nodename_off, buffer+11, h->nodename_len) && !memcmp (h->tname+h->nodename_off, buffer+11, h->nodename_len)
&& buffer[11+h->nodename_len] == '\n') && buffer[11+h->nodename_len] == '\n')
*same_node = 1; *same_node = 1;
@ -711,10 +711,10 @@ void
dotlock_remove_lockfiles (void) dotlock_remove_lockfiles (void)
{ {
dotlock_t h, h2; dotlock_t h, h2;
h = all_lockfiles; h = all_lockfiles;
all_lockfiles = NULL; all_lockfiles = NULL;
while ( h ) while ( h )
{ {
h2 = h->next; h2 = h->next;
@ -722,4 +722,3 @@ dotlock_remove_lockfiles (void)
h = h2; h = h2;
} }
} }

View File

@ -81,6 +81,6 @@ dlclose (void * hd)
return 0; return 0;
} }
return -1; return -1;
} }
# endif /*__MINGW32__*/ # endif /*__MINGW32__*/
#endif /*LIBJNLIB_DYNLOAD_H*/ #endif /*LIBJNLIB_DYNLOAD_H*/

View File

@ -93,7 +93,7 @@
#if defined(HAVE_INTMAX_T) || defined(HAVE_UINTMAX_T) #if defined(HAVE_INTMAX_T) || defined(HAVE_UINTMAX_T)
# ifdef HAVE_STDINT_H # ifdef HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
# endif # endif
#endif #endif
#ifdef HAVE_LANGINFO_THOUSANDS_SEP #ifdef HAVE_LANGINFO_THOUSANDS_SEP
#include <langinfo.h> #include <langinfo.h>
@ -111,12 +111,12 @@
/* Allow redefinition of asprintf used malloc functions. */ /* Allow redefinition of asprintf used malloc functions. */
#if defined(_ESTREAM_PRINTF_MALLOC) #if defined(_ESTREAM_PRINTF_MALLOC)
#define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a)) #define my_printf_malloc(a) _ESTREAM_PRINTF_MALLOC((a))
#else #else
#define my_printf_malloc(a) malloc((a)) #define my_printf_malloc(a) malloc((a))
#endif #endif
#if defined(_ESTREAM_PRINTF_FREE) #if defined(_ESTREAM_PRINTF_FREE)
#define my_printf_free(a) _ESTREAM_PRINTF_FREE((a)) #define my_printf_free(a) _ESTREAM_PRINTF_FREE((a))
#else #else
#define my_printf_free(a) free((a)) #define my_printf_free(a) free((a))
#endif #endif
@ -233,7 +233,7 @@ typedef enum
/* A union used to store the actual values. */ /* A union used to store the actual values. */
typedef union typedef union
{ {
char a_char; char a_char;
signed char a_schar; signed char a_schar;
@ -317,7 +317,7 @@ dump_argspecs (argspec_t arg, size_t argcount)
int idx; int idx;
for (idx=0; argcount; argcount--, arg++, idx++) for (idx=0; argcount; argcount--, arg++, idx++)
fprintf (stderr, fprintf (stderr,
"%2d: len=%u flags=%u width=%d prec=%d mod=%d " "%2d: len=%u flags=%u width=%d prec=%d mod=%d "
"con=%d vt=%d pos=%d-%d-%d\n", "con=%d vt=%d pos=%d-%d-%d\n",
idx, idx,
@ -341,8 +341,8 @@ compute_type (argspec_t arg)
{ {
switch (arg->conspec) switch (arg->conspec)
{ {
case CONSPEC_UNKNOWN: case CONSPEC_UNKNOWN:
arg->vt = VALTYPE_UNSUPPORTED; arg->vt = VALTYPE_UNSUPPORTED;
break; break;
case CONSPEC_DECIMAL: case CONSPEC_DECIMAL:
@ -353,7 +353,7 @@ compute_type (argspec_t arg)
case LENMOD_LONG: arg->vt = VALTYPE_LONG; break; case LENMOD_LONG: arg->vt = VALTYPE_LONG; break;
case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG; break; case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG; break;
case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX; break; case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX; break;
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break; case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break; case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break;
default: arg->vt = VALTYPE_INT; break; default: arg->vt = VALTYPE_INT; break;
} }
@ -370,12 +370,12 @@ compute_type (argspec_t arg)
case LENMOD_LONG: arg->vt = VALTYPE_ULONG; break; case LENMOD_LONG: arg->vt = VALTYPE_ULONG; break;
case LENMOD_LONGLONG: arg->vt = VALTYPE_ULONGLONG; break; case LENMOD_LONGLONG: arg->vt = VALTYPE_ULONGLONG; break;
case LENMOD_INTMAX: arg->vt = VALTYPE_UINTMAX; break; case LENMOD_INTMAX: arg->vt = VALTYPE_UINTMAX; break;
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break; case LENMOD_SIZET: arg->vt = VALTYPE_SIZE; break;
case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break; case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF; break;
default: arg->vt = VALTYPE_UINT; break; default: arg->vt = VALTYPE_UINT; break;
} }
break; break;
case CONSPEC_FLOAT: case CONSPEC_FLOAT:
case CONSPEC_FLOAT_UP: case CONSPEC_FLOAT_UP:
case CONSPEC_EXP: case CONSPEC_EXP:
@ -391,9 +391,9 @@ compute_type (argspec_t arg)
default: arg->vt = VALTYPE_DOUBLE; break; default: arg->vt = VALTYPE_DOUBLE; break;
} }
break; break;
case CONSPEC_CHAR: case CONSPEC_CHAR:
arg->vt = VALTYPE_INT; arg->vt = VALTYPE_INT;
break; break;
case CONSPEC_STRING: case CONSPEC_STRING:
@ -416,12 +416,12 @@ compute_type (argspec_t arg)
case LENMOD_LONG: arg->vt = VALTYPE_LONG_PTR; break; case LENMOD_LONG: arg->vt = VALTYPE_LONG_PTR; break;
case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG_PTR; break; case LENMOD_LONGLONG: arg->vt = VALTYPE_LONGLONG_PTR; break;
case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX_PTR; break; case LENMOD_INTMAX: arg->vt = VALTYPE_INTMAX_PTR; break;
case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break; case LENMOD_SIZET: arg->vt = VALTYPE_SIZE_PTR; break;
case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF_PTR; break; case LENMOD_PTRDIFF: arg->vt = VALTYPE_PTRDIFF_PTR; break;
default: arg->vt = VALTYPE_INT_PTR; break; default: arg->vt = VALTYPE_INT_PTR; break;
} }
break; break;
} }
} }
@ -446,7 +446,7 @@ parse_format (const char *format,
if (!format) if (!format)
goto leave_einval; goto leave_einval;
for (; *format; format++) for (; *format; format++)
{ {
unsigned int flags; unsigned int flags;
@ -454,7 +454,7 @@ parse_format (const char *format,
lenmod_t lenmod; lenmod_t lenmod;
conspec_t conspec; conspec_t conspec;
int arg_pos, width_pos, precision_pos; int arg_pos, width_pos, precision_pos;
if (*format != '%') if (*format != '%')
continue; continue;
s = ++format; s = ++format;
@ -468,7 +468,7 @@ parse_format (const char *format,
if (*s >= '1' && *s <= '9') if (*s >= '1' && *s <= '9')
{ {
const char *save_s = s; const char *save_s = s;
arg_pos = (*s++ - '0'); arg_pos = (*s++ - '0');
for (; *s >= '0' && *s <= '9'; s++) for (; *s >= '0' && *s <= '9'; s++)
arg_pos = 10*arg_pos + (*s - '0'); arg_pos = 10*arg_pos + (*s - '0');
@ -482,7 +482,7 @@ parse_format (const char *format,
s = save_s; s = save_s;
} }
} }
/* Parse the flags. */ /* Parse the flags. */
flags = 0; flags = 0;
for ( ; *s; s++) for ( ; *s; s++)
@ -500,7 +500,7 @@ parse_format (const char *format,
} }
} }
flags_parsed: flags_parsed:
/* Parse the field width. */ /* Parse the field width. */
width_pos = 0; width_pos = 0;
if (*s == '*') if (*s == '*')
@ -583,11 +583,11 @@ parse_format (const char *format,
if (ignore_value) if (ignore_value)
precision = NO_FIELD_VALUE; precision = NO_FIELD_VALUE;
} }
/* Parse the length modifiers. */ /* Parse the length modifiers. */
switch (*s) switch (*s)
{ {
case 'h': case 'h':
if (s[1] == 'h') if (s[1] == 'h')
{ {
lenmod = LENMOD_CHAR; lenmod = LENMOD_CHAR;
@ -613,7 +613,7 @@ parse_format (const char *format,
case 'L': lenmod = LENMOD_LONGDBL; s++; break; case 'L': lenmod = LENMOD_LONGDBL; s++; break;
default: lenmod = LENMOD_NONE; break; default: lenmod = LENMOD_NONE; break;
} }
/* Parse the conversion specifier. */ /* Parse the conversion specifier. */
switch (*s) switch (*s)
{ {
@ -683,7 +683,7 @@ parse_format (const char *format,
*argspecs_addr = argspecs; *argspecs_addr = argspecs;
*r_argspecs_count = argcount; *r_argspecs_count = argcount;
return 0; /* Success. */ return 0; /* Success. */
leave_einval: leave_einval:
_set_errno (EINVAL); _set_errno (EINVAL);
leave: leave:
@ -714,14 +714,14 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs)
value->a_char_ptr = va_arg (vaargs, char *); value->a_char_ptr = va_arg (vaargs, char *);
break; break;
case VALTYPE_SCHAR: value->a_schar = va_arg (vaargs, int); break; case VALTYPE_SCHAR: value->a_schar = va_arg (vaargs, int); break;
case VALTYPE_SCHAR_PTR: case VALTYPE_SCHAR_PTR:
value->a_schar_ptr = va_arg (vaargs, signed char *); value->a_schar_ptr = va_arg (vaargs, signed char *);
break; break;
case VALTYPE_UCHAR: value->a_uchar = va_arg (vaargs, int); break; case VALTYPE_UCHAR: value->a_uchar = va_arg (vaargs, int); break;
case VALTYPE_SHORT: value->a_short = va_arg (vaargs, int); break; case VALTYPE_SHORT: value->a_short = va_arg (vaargs, int); break;
case VALTYPE_USHORT: value->a_ushort = va_arg (vaargs, int); break; case VALTYPE_USHORT: value->a_ushort = va_arg (vaargs, int); break;
case VALTYPE_SHORT_PTR: case VALTYPE_SHORT_PTR:
value->a_short_ptr = va_arg (vaargs, short *); value->a_short_ptr = va_arg (vaargs, short *);
break; break;
case VALTYPE_INT: case VALTYPE_INT:
value->a_int = va_arg (vaargs, int); value->a_int = va_arg (vaargs, int);
@ -735,20 +735,20 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs)
case VALTYPE_LONG: case VALTYPE_LONG:
value->a_long = va_arg (vaargs, long); value->a_long = va_arg (vaargs, long);
break; break;
case VALTYPE_ULONG: case VALTYPE_ULONG:
value->a_ulong = va_arg (vaargs, unsigned long); value->a_ulong = va_arg (vaargs, unsigned long);
break; break;
case VALTYPE_LONG_PTR: case VALTYPE_LONG_PTR:
value->a_long_ptr = va_arg (vaargs, long *); value->a_long_ptr = va_arg (vaargs, long *);
break; break;
#ifdef HAVE_LONG_LONG_INT #ifdef HAVE_LONG_LONG_INT
case VALTYPE_LONGLONG: case VALTYPE_LONGLONG:
value->a_longlong = va_arg (vaargs, long long int); value->a_longlong = va_arg (vaargs, long long int);
break; break;
case VALTYPE_ULONGLONG: case VALTYPE_ULONGLONG:
value->a_ulonglong = va_arg (vaargs, unsigned long long int); value->a_ulonglong = va_arg (vaargs, unsigned long long int);
break; break;
case VALTYPE_LONGLONG_PTR: case VALTYPE_LONGLONG_PTR:
value->a_longlong_ptr = va_arg (vaargs, long long *); value->a_longlong_ptr = va_arg (vaargs, long long *);
break; break;
#endif #endif
@ -763,31 +763,31 @@ read_values (valueitem_t valuetable, size_t valuetable_len, va_list vaargs)
case VALTYPE_STRING: case VALTYPE_STRING:
value->a_string = va_arg (vaargs, const char *); value->a_string = va_arg (vaargs, const char *);
break; break;
case VALTYPE_POINTER: case VALTYPE_POINTER:
value->a_void_ptr = va_arg (vaargs, void *); value->a_void_ptr = va_arg (vaargs, void *);
break; break;
#ifdef HAVE_INTMAX_T #ifdef HAVE_INTMAX_T
case VALTYPE_INTMAX: case VALTYPE_INTMAX:
value->a_intmax = va_arg (vaargs, intmax_t); value->a_intmax = va_arg (vaargs, intmax_t);
break; break;
case VALTYPE_INTMAX_PTR: case VALTYPE_INTMAX_PTR:
value->a_intmax_ptr = va_arg (vaargs, intmax_t *); value->a_intmax_ptr = va_arg (vaargs, intmax_t *);
break; break;
#endif #endif
#ifdef HAVE_UINTMAX_T #ifdef HAVE_UINTMAX_T
case VALTYPE_UINTMAX: case VALTYPE_UINTMAX:
value->a_uintmax = va_arg (vaargs, uintmax_t); value->a_uintmax = va_arg (vaargs, uintmax_t);
break; break;
#endif #endif
case VALTYPE_SIZE: case VALTYPE_SIZE:
value->a_size = va_arg (vaargs, size_t); value->a_size = va_arg (vaargs, size_t);
break; break;
case VALTYPE_SIZE_PTR: case VALTYPE_SIZE_PTR:
value->a_size_ptr = va_arg (vaargs, size_t *); value->a_size_ptr = va_arg (vaargs, size_t *);
break; break;
#ifdef HAVE_PTRDIFF_T #ifdef HAVE_PTRDIFF_T
case VALTYPE_PTRDIFF: case VALTYPE_PTRDIFF:
value->a_ptrdiff = va_arg (vaargs, ptrdiff_t); value->a_ptrdiff = va_arg (vaargs, ptrdiff_t);
break; break;
case VALTYPE_PTRDIFF_PTR: case VALTYPE_PTRDIFF_PTR:
value->a_ptrdiff_ptr = va_arg (vaargs, ptrdiff_t *); value->a_ptrdiff_ptr = va_arg (vaargs, ptrdiff_t *);
@ -822,7 +822,7 @@ pad_out (estream_printf_out_t outfnc, void *outfncarg,
*nbytes += n; *nbytes += n;
count -= n; count -= n;
} }
return 0; return 0;
} }
@ -859,18 +859,18 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
{ {
case VALTYPE_SHORT: along = value.a_short; break; case VALTYPE_SHORT: along = value.a_short; break;
case VALTYPE_INT: along = value.a_int; break; case VALTYPE_INT: along = value.a_int; break;
case VALTYPE_LONG: along = value.a_long; break; case VALTYPE_LONG: along = value.a_long; break;
#ifdef HAVE_LONG_LONG_INT #ifdef HAVE_LONG_LONG_INT
case VALTYPE_LONGLONG: along = value.a_longlong; break; case VALTYPE_LONGLONG: along = value.a_longlong; break;
case VALTYPE_SIZE: along = value.a_size; break; case VALTYPE_SIZE: along = value.a_size; break;
# ifdef HAVE_INTMAX_T # ifdef HAVE_INTMAX_T
case VALTYPE_INTMAX: along = value.a_intmax; break; case VALTYPE_INTMAX: along = value.a_intmax; break;
# endif # endif
# ifdef HAVE_PTRDIFF_T # ifdef HAVE_PTRDIFF_T
case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break; case VALTYPE_PTRDIFF: along = value.a_ptrdiff; break;
# endif # endif
#endif /*HAVE_LONG_LONG_INT*/ #endif /*HAVE_LONG_LONG_INT*/
default: default:
return -1; return -1;
} }
if (along < 0) if (along < 0)
@ -887,18 +887,18 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
{ {
case VALTYPE_USHORT: aulong = value.a_ushort; break; case VALTYPE_USHORT: aulong = value.a_ushort; break;
case VALTYPE_UINT: aulong = value.a_uint; break; case VALTYPE_UINT: aulong = value.a_uint; break;
case VALTYPE_ULONG: aulong = value.a_ulong; break; case VALTYPE_ULONG: aulong = value.a_ulong; break;
#ifdef HAVE_LONG_LONG_INT #ifdef HAVE_LONG_LONG_INT
case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break; case VALTYPE_ULONGLONG: aulong = value.a_ulonglong; break;
case VALTYPE_SIZE: aulong = value.a_size; break; case VALTYPE_SIZE: aulong = value.a_size; break;
# ifdef HAVE_UINTMAX_T # ifdef HAVE_UINTMAX_T
case VALTYPE_UINTMAX: aulong = value.a_uintmax; break; case VALTYPE_UINTMAX: aulong = value.a_uintmax; break;
# endif # endif
# ifdef HAVE_PTRDIFF_T # ifdef HAVE_PTRDIFF_T
case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break; case VALTYPE_PTRDIFF: aulong = value.a_ptrdiff; break;
# endif # endif
#endif /*HAVE_LONG_LONG_INT*/ #endif /*HAVE_LONG_LONG_INT*/
default: default:
return -1; return -1;
} }
} }
@ -929,7 +929,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
do do
{ {
if ((arg->flags & FLAG_GROUPING) if ((arg->flags & FLAG_GROUPING)
&& (++grouping == 3) && *grouping_string) && (++grouping == 3) && *grouping_string)
{ {
*--p = *grouping_string; *--p = *grouping_string;
@ -964,7 +964,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
if ((arg->flags & FLAG_ALT_CONV)) if ((arg->flags & FLAG_ALT_CONV))
n_extra += 2; n_extra += 2;
} }
n = pend - p; n = pend - p;
if ((arg->flags & FLAG_ZERO_PAD) if ((arg->flags & FLAG_ZERO_PAD)
@ -1009,7 +1009,7 @@ pr_integer (estream_printf_out_t outfnc, void *outfncarg,
if (rc) if (rc)
return rc; return rc;
} }
rc = outfnc (outfncarg, p, pend - p); rc = outfnc (outfncarg, p, pend - p);
if (rc) if (rc)
return rc; return rc;
@ -1062,7 +1062,7 @@ pr_float (estream_printf_out_t outfnc, void *outfncarg,
adblfloat = value.a_longdouble; adblfloat = value.a_longdouble;
use_dbl=1; break; use_dbl=1; break;
#endif #endif
default: default:
return -1; return -1;
} }
@ -1173,7 +1173,7 @@ pr_char (estream_printf_out_t outfnc, void *outfncarg,
if(rc) if(rc)
return rc; return rc;
*nbytes += 1; *nbytes += 1;
return 0; return 0;
} }
@ -1194,7 +1194,7 @@ pr_string (estream_printf_out_t outfnc, void *outfncarg,
string = "(null)"; string = "(null)";
if (arg->precision >= 0) if (arg->precision >= 0)
{ {
for (n=0,s=string; *s && n < arg->precision; s++) for (n=0,s=string; *s && n < arg->precision; s++)
n++; n++;
} }
else else
@ -1220,7 +1220,7 @@ pr_string (estream_printf_out_t outfnc, void *outfncarg,
if (rc) if (rc)
return rc; return rc;
} }
return 0; return 0;
} }
@ -1261,7 +1261,7 @@ pr_pointer (estream_printf_out_t outfnc, void *outfncarg,
*--p = '0'; *--p = '0';
*--p = 'x'; *--p = 'x';
*--p = '0'; *--p = '0';
rc = outfnc (outfncarg, p, pend - p); rc = outfnc (outfncarg, p, pend - p);
if (rc) if (rc)
return rc; return rc;
@ -1280,14 +1280,14 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg,
switch (arg->vt) switch (arg->vt)
{ {
case VALTYPE_SCHAR_PTR: case VALTYPE_SCHAR_PTR:
*value.a_schar_ptr = (signed char)(unsigned int)(*nbytes); *value.a_schar_ptr = (signed char)(unsigned int)(*nbytes);
break; break;
case VALTYPE_SHORT_PTR: case VALTYPE_SHORT_PTR:
*value.a_short_ptr = (short)(unsigned int)(*nbytes); *value.a_short_ptr = (short)(unsigned int)(*nbytes);
break; break;
case VALTYPE_LONG_PTR: case VALTYPE_LONG_PTR:
*value.a_long_ptr = (long)(*nbytes); *value.a_long_ptr = (long)(*nbytes);
break; break;
#ifdef HAVE_LONG_LONG_INT #ifdef HAVE_LONG_LONG_INT
case VALTYPE_LONGLONG_PTR: case VALTYPE_LONGLONG_PTR:
@ -1295,12 +1295,12 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg,
break; break;
#endif #endif
#ifdef HAVE_INTMAX_T #ifdef HAVE_INTMAX_T
case VALTYPE_INTMAX_PTR: case VALTYPE_INTMAX_PTR:
*value.a_intmax_ptr = (intmax_t)(*nbytes); *value.a_intmax_ptr = (intmax_t)(*nbytes);
break; break;
#endif #endif
case VALTYPE_SIZE_PTR: case VALTYPE_SIZE_PTR:
*value.a_size_ptr = (*nbytes); *value.a_size_ptr = (*nbytes);
break; break;
#ifdef HAVE_PTRDIFF_T #ifdef HAVE_PTRDIFF_T
case VALTYPE_PTRDIFF_PTR: case VALTYPE_PTRDIFF_PTR:
@ -1325,8 +1325,8 @@ pr_bytes_so_far (estream_printf_out_t outfnc, void *outfncarg,
holds the values and may be directly addressed using the position holds the values and may be directly addressed using the position
arguments given by ARGSPECS. MYERRNO is used for the "%m" arguments given by ARGSPECS. MYERRNO is used for the "%m"
conversion. NBYTES well be updated to reflect the number of bytes conversion. NBYTES well be updated to reflect the number of bytes
send to the output function. */ send to the output function. */
static int static int
do_format (estream_printf_out_t outfnc, void *outfncarg, do_format (estream_printf_out_t outfnc, void *outfncarg,
const char *format, argspec_t argspecs, size_t argspecs_len, const char *format, argspec_t argspecs, size_t argspecs_len,
valueitem_t valuetable, int myerrno, size_t *nbytes) valueitem_t valuetable, int myerrno, size_t *nbytes)
@ -1370,7 +1370,7 @@ do_format (estream_printf_out_t outfnc, void *outfncarg,
/* Save the next start. */ /* Save the next start. */
s += arg->length; s += arg->length;
format = s; format = s;
assert (argidx < argspecs_len); assert (argidx < argspecs_len);
argidx++; argidx++;
@ -1438,9 +1438,9 @@ do_format (estream_printf_out_t outfnc, void *outfncarg,
} }
if (rc) if (rc)
return rc; return rc;
arg++; arg++;
} }
/* Print out any trailing stuff. */ /* Print out any trailing stuff. */
n = s - format; n = s - format;
rc = n? outfnc (outfncarg, format, n) : 0; rc = n? outfnc (outfncarg, format, n) : 0;
@ -1458,7 +1458,7 @@ do_format (estream_printf_out_t outfnc, void *outfncarg,
output of the formatted stuff. FORMAT is the format specification output of the formatted stuff. FORMAT is the format specification
and VAARGS a variable argumemt list matching the arguments of and VAARGS a variable argumemt list matching the arguments of
FORMAT. */ FORMAT. */
int int
estream_format (estream_printf_out_t outfnc, estream_format (estream_printf_out_t outfnc,
void *outfncarg, void *outfncarg,
const char *format, va_list vaargs) const char *format, va_list vaargs)
@ -1493,7 +1493,7 @@ estream_format (estream_printf_out_t outfnc,
/* Check that all ARG_POS fields are set. */ /* Check that all ARG_POS fields are set. */
for (argidx=0,max_pos=0; argidx < argspecs_len; argidx++) for (argidx=0,max_pos=0; argidx < argspecs_len; argidx++)
{ {
if (argspecs[argidx].arg_pos != -1 if (argspecs[argidx].arg_pos != -1
&& argspecs[argidx].arg_pos > max_pos) && argspecs[argidx].arg_pos > max_pos)
max_pos = argspecs[argidx].arg_pos; max_pos = argspecs[argidx].arg_pos;
if (argspecs[argidx].width_pos > max_pos) if (argspecs[argidx].width_pos > max_pos)
@ -1574,13 +1574,13 @@ estream_format (estream_printf_out_t outfnc,
valuetable[validx].vt = VALTYPE_INT; valuetable[validx].vt = VALTYPE_INT;
} }
} }
/* Read all the arguments. This will error out for unsupported /* Read all the arguments. This will error out for unsupported
types and for not given positional arguments. */ types and for not given positional arguments. */
rc = read_values (valuetable, max_pos, vaargs); rc = read_values (valuetable, max_pos, vaargs);
if (rc) if (rc)
goto leave_einval; goto leave_einval;
/* for (validx=0; validx < max_pos; validx++) */ /* for (validx=0; validx < max_pos; validx++) */
/* fprintf (stderr, "%2d: vt=%d\n", validx, valuetable[validx].vt); */ /* fprintf (stderr, "%2d: vt=%d\n", validx, valuetable[validx].vt); */
@ -1589,7 +1589,7 @@ estream_format (estream_printf_out_t outfnc,
argspecs, argspecs_len, valuetable, myerrno, &nbytes); argspecs, argspecs_len, valuetable, myerrno, &nbytes);
goto leave; goto leave;
leave_einval: leave_einval:
_set_errno (EINVAL); _set_errno (EINVAL);
leave_error: leave_error:
@ -1623,11 +1623,11 @@ estream_printf (const char *format, ...)
{ {
int rc; int rc;
va_list arg_ptr; va_list arg_ptr;
va_start (arg_ptr, format); va_start (arg_ptr, format);
rc = estream_format (plain_stdio_out, stderr, format, arg_ptr); rc = estream_format (plain_stdio_out, stderr, format, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
return rc; return rc;
} }
@ -1637,16 +1637,16 @@ estream_fprintf (FILE *fp, const char *format, ...)
{ {
int rc; int rc;
va_list arg_ptr; va_list arg_ptr;
va_start (arg_ptr, format); va_start (arg_ptr, format);
rc = estream_format (plain_stdio_out, fp, format, arg_ptr); rc = estream_format (plain_stdio_out, fp, format, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
return rc; return rc;
} }
/* A replacement for vfprintf. */ /* A replacement for vfprintf. */
int int
estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr) estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr)
{ {
return estream_format (plain_stdio_out, fp, format, arg_ptr); return estream_format (plain_stdio_out, fp, format, arg_ptr);
@ -1693,7 +1693,7 @@ fixed_buffer_out (void *outfncarg, const char *buf, size_t buflen)
/* A replacement for vsnprintf. */ /* A replacement for vsnprintf. */
int int
estream_vsnprintf (char *buf, size_t bufsize, estream_vsnprintf (char *buf, size_t bufsize,
const char *format, va_list arg_ptr) const char *format, va_list arg_ptr)
{ {
@ -1718,7 +1718,7 @@ estream_vsnprintf (char *buf, size_t bufsize,
} }
/* A replacement for snprintf. */ /* A replacement for snprintf. */
int int
estream_snprintf (char *buf, size_t bufsize, const char *format, ...) estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
{ {
int rc; int rc;
@ -1727,7 +1727,7 @@ estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
va_start (arg_ptr, format); va_start (arg_ptr, format);
rc = estream_vsnprintf (buf, bufsize, format, arg_ptr); rc = estream_vsnprintf (buf, bufsize, format, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
return rc; return rc;
} }
@ -1737,7 +1737,7 @@ estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
dynamic_buffer_out. */ dynamic_buffer_out. */
struct dynamic_buffer_parm_s struct dynamic_buffer_parm_s
{ {
int error_flag; /* Internal helper. */ int error_flag; /* Internal helper. */
size_t alloced; /* Allocated size of the buffer. */ size_t alloced; /* Allocated size of the buffer. */
size_t used; /* Used size of the buffer. */ size_t used; /* Used size of the buffer. */
char *buffer; /* Malloced buffer. */ char *buffer; /* Malloced buffer. */
@ -1760,7 +1760,7 @@ dynamic_buffer_out (void *outfncarg, const char *buf, size_t buflen)
if (parm->used + buflen >= parm->alloced) if (parm->used + buflen >= parm->alloced)
{ {
char *p; char *p;
parm->alloced += buflen + 512; parm->alloced += buflen + 512;
p = realloc (parm->buffer, parm->alloced); p = realloc (parm->buffer, parm->alloced);
if (!p) if (!p)
@ -1783,7 +1783,7 @@ dynamic_buffer_out (void *outfncarg, const char *buf, size_t buflen)
/* A replacement for vasprintf. As with the BSD of vasprintf version -1 /* A replacement for vasprintf. As with the BSD of vasprintf version -1
will be returned on error and NULL stored at BUFP. On success the will be returned on error and NULL stored at BUFP. On success the
number of bytes printed will be returned. */ number of bytes printed will be returned. */
int int
estream_vasprintf (char **bufp, const char *format, va_list arg_ptr) estream_vasprintf (char **bufp, const char *format, va_list arg_ptr)
{ {
struct dynamic_buffer_parm_s parm; struct dynamic_buffer_parm_s parm;
@ -1798,7 +1798,7 @@ estream_vasprintf (char **bufp, const char *format, va_list arg_ptr)
*bufp = NULL; *bufp = NULL;
return -1; return -1;
} }
rc = estream_format (dynamic_buffer_out, &parm, format, arg_ptr); rc = estream_format (dynamic_buffer_out, &parm, format, arg_ptr);
if (!rc) if (!rc)
rc = dynamic_buffer_out (&parm, "", 1); /* Print terminating Nul. */ rc = dynamic_buffer_out (&parm, "", 1); /* Print terminating Nul. */
@ -1823,7 +1823,7 @@ estream_vasprintf (char **bufp, const char *format, va_list arg_ptr)
/* A replacement for asprintf. As with the BSD of asprintf version -1 /* A replacement for asprintf. As with the BSD of asprintf version -1
will be returned on error and NULL stored at BUFP. On success the will be returned on error and NULL stored at BUFP. On success the
number of bytes printed will be returned. */ number of bytes printed will be returned. */
int int
estream_asprintf (char **bufp, const char *format, ...) estream_asprintf (char **bufp, const char *format, ...)
{ {
int rc; int rc;
@ -1832,8 +1832,6 @@ estream_asprintf (char **bufp, const char *format, ...)
va_start (arg_ptr, format); va_start (arg_ptr, format);
rc = estream_vasprintf (bufp, format, arg_ptr); rc = estream_vasprintf (bufp, format, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
return rc; return rc;
} }

View File

@ -60,7 +60,7 @@
/* To use this file with libraries the following macro is useful: /* To use this file with libraries the following macro is useful:
#define _ESTREAM_EXT_SYM_PREFIX _foo_ #define _ESTREAM_EXT_SYM_PREFIX _foo_
This prefixes all external symbols with "_foo_". This prefixes all external symbols with "_foo_".
For the implementation of the code (estream-printf.c) the following For the implementation of the code (estream-printf.c) the following
@ -119,9 +119,9 @@ typedef int (*estream_printf_out_t)
(void *outfncarg, const char *buf, size_t buflen); (void *outfncarg, const char *buf, size_t buflen);
int estream_format (estream_printf_out_t outfnc, void *outfncarg, int estream_format (estream_printf_out_t outfnc, void *outfncarg,
const char *format, va_list vaargs) const char *format, va_list vaargs)
_ESTREAM_GCC_A_PRINTF(3,0); _ESTREAM_GCC_A_PRINTF(3,0);
int estream_printf (const char *format, ...) int estream_printf (const char *format, ...)
_ESTREAM_GCC_A_PRINTF(1,2); _ESTREAM_GCC_A_PRINTF(1,2);
int estream_fprintf (FILE *fp, const char *format, ... ) int estream_fprintf (FILE *fp, const char *format, ... )
_ESTREAM_GCC_A_PRINTF(2,3); _ESTREAM_GCC_A_PRINTF(2,3);
@ -129,8 +129,8 @@ int estream_vfprintf (FILE *fp, const char *format, va_list arg_ptr)
_ESTREAM_GCC_A_PRINTF(2,0); _ESTREAM_GCC_A_PRINTF(2,0);
int estream_snprintf (char *buf, size_t bufsize, const char *format, ...) int estream_snprintf (char *buf, size_t bufsize, const char *format, ...)
_ESTREAM_GCC_A_PRINTF(3,4); _ESTREAM_GCC_A_PRINTF(3,4);
int estream_vsnprintf (char *buf,size_t bufsize, int estream_vsnprintf (char *buf,size_t bufsize,
const char *format, va_list arg_ptr) const char *format, va_list arg_ptr)
_ESTREAM_GCC_A_PRINTF(3,0); _ESTREAM_GCC_A_PRINTF(3,0);
int estream_asprintf (char **bufp, const char *format, ...) int estream_asprintf (char **bufp, const char *format, ...)
_ESTREAM_GCC_A_PRINTF(2,3); _ESTREAM_GCC_A_PRINTF(2,3);

View File

@ -357,7 +357,7 @@ map_w32_to_errno (DWORD w32_err)
case ERROR_NOT_ENOUGH_MEMORY: case ERROR_NOT_ENOUGH_MEMORY:
return ENOMEM; return ENOMEM;
case ERROR_NO_DATA: case ERROR_NO_DATA:
return EPIPE; return EPIPE;
@ -406,7 +406,7 @@ static void
do_list_remove (estream_t stream, int with_locked_list) do_list_remove (estream_t stream, int with_locked_list)
{ {
estream_list_t list_obj; estream_list_t list_obj;
if (!with_locked_list) if (!with_locked_list)
ESTREAM_LIST_LOCK; ESTREAM_LIST_LOCK;
for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr) for (list_obj = estream_list; list_obj; list_obj = list_obj->cdr)
@ -509,7 +509,7 @@ do_init (void)
#else #else
initialized = 1; initialized = 1;
#endif #endif
atexit (do_deinit); atexit (do_deinit);
} }
return 0; return 0;
} }
@ -602,7 +602,7 @@ es_func_mem_read (void *cookie, void *buffer, size_t size)
memcpy (buffer, mem_cookie->memory + mem_cookie->offset, size); memcpy (buffer, mem_cookie->memory + mem_cookie->offset, size);
mem_cookie->offset += size; mem_cookie->offset += size;
} }
ret = size; ret = size;
return ret; return ret;
} }
@ -627,7 +627,7 @@ es_func_mem_write (void *cookie, const void *buffer, size_t size)
assert (mem_cookie->memory_size >= mem_cookie->offset); assert (mem_cookie->memory_size >= mem_cookie->offset);
nleft = mem_cookie->memory_size - mem_cookie->offset; nleft = mem_cookie->memory_size - mem_cookie->offset;
/* If we are not allowed to grow limit the size to the left space. */ /* If we are not allowed to grow limit the size to the left space. */
if (!mem_cookie->flags.grow && size > nleft) if (!mem_cookie->flags.grow && size > nleft)
size = nleft; size = nleft;
@ -668,20 +668,20 @@ es_func_mem_write (void *cookie, const void *buffer, size_t size)
_set_errno (ENOSPC); _set_errno (ENOSPC);
return -1; return -1;
} }
newbuf = mem_cookie->func_realloc (mem_cookie->memory, newsize); newbuf = mem_cookie->func_realloc (mem_cookie->memory, newsize);
if (!newbuf) if (!newbuf)
return -1; return -1;
mem_cookie->memory = newbuf; mem_cookie->memory = newbuf;
mem_cookie->memory_size = newsize; mem_cookie->memory_size = newsize;
assert (mem_cookie->memory_size >= mem_cookie->offset); assert (mem_cookie->memory_size >= mem_cookie->offset);
nleft = mem_cookie->memory_size - mem_cookie->offset; nleft = mem_cookie->memory_size - mem_cookie->offset;
assert (size <= nleft); assert (size <= nleft);
} }
memcpy (mem_cookie->memory + mem_cookie->offset, buffer, size); memcpy (mem_cookie->memory + mem_cookie->offset, buffer, size);
if (mem_cookie->offset + size > mem_cookie->data_len) if (mem_cookie->offset + size > mem_cookie->data_len)
mem_cookie->data_len = mem_cookie->offset + size; mem_cookie->data_len = mem_cookie->offset + size;
@ -743,7 +743,7 @@ es_func_mem_seek (void *cookie, off_t *offset, int whence)
_set_errno (ENOSPC); _set_errno (ENOSPC);
return -1; return -1;
} }
newbuf = mem_cookie->func_realloc (mem_cookie->memory, newsize); newbuf = mem_cookie->func_realloc (mem_cookie->memory, newsize);
if (!newbuf) if (!newbuf)
return -1; return -1;
@ -825,7 +825,7 @@ func_fd_create (void **cookie, int fd, unsigned int modeflags, int no_close)
*cookie = fd_cookie; *cookie = fd_cookie;
err = 0; err = 0;
} }
return err; return err;
} }
@ -836,7 +836,7 @@ es_func_fd_read (void *cookie, void *buffer, size_t size)
{ {
estream_cookie_fd_t file_cookie = cookie; estream_cookie_fd_t file_cookie = cookie;
ssize_t bytes_read; ssize_t bytes_read;
if (IS_INVALID_FD (file_cookie->fd)) if (IS_INVALID_FD (file_cookie->fd))
{ {
ESTREAM_SYS_YIELD (); ESTREAM_SYS_YIELD ();
@ -844,7 +844,7 @@ es_func_fd_read (void *cookie, void *buffer, size_t size)
} }
else else
{ {
do do
bytes_read = ESTREAM_SYS_READ (file_cookie->fd, buffer, size); bytes_read = ESTREAM_SYS_READ (file_cookie->fd, buffer, size);
while (bytes_read == -1 && errno == EINTR); while (bytes_read == -1 && errno == EINTR);
} }
@ -969,7 +969,7 @@ es_func_w32_create (void **cookie, HANDLE hd,
*cookie = w32_cookie; *cookie = w32_cookie;
err = 0; err = 0;
} }
return err; return err;
} }
@ -979,7 +979,7 @@ es_func_w32_read (void *cookie, void *buffer, size_t size)
{ {
estream_cookie_w32_t w32_cookie = cookie; estream_cookie_w32_t w32_cookie = cookie;
ssize_t bytes_read; ssize_t bytes_read;
if (w32_cookie->hd == INVALID_HANDLE_VALUE) if (w32_cookie->hd == INVALID_HANDLE_VALUE)
{ {
ESTREAM_SYS_YIELD (); ESTREAM_SYS_YIELD ();
@ -994,7 +994,7 @@ es_func_w32_read (void *cookie, void *buffer, size_t size)
bytes_read = pth_read ((int)w32_cookie->hd, buffer, size); bytes_read = pth_read ((int)w32_cookie->hd, buffer, size);
#else #else
DWORD nread, ec; DWORD nread, ec;
if (!ReadFile (w32_cookie->hd, buffer, size, &nread, NULL)) if (!ReadFile (w32_cookie->hd, buffer, size, &nread, NULL))
{ {
ec = GetLastError (); ec = GetLastError ();
@ -1116,7 +1116,7 @@ es_func_w32_destroy (void *cookie)
else if (w32_cookie->no_close) else if (w32_cookie->no_close)
err = 0; err = 0;
else else
{ {
if (!CloseHandle (w32_cookie->hd)) if (!CloseHandle (w32_cookie->hd))
{ {
_set_errno (map_w32_to_errno (GetLastError ())); _set_errno (map_w32_to_errno (GetLastError ()));
@ -1158,7 +1158,7 @@ typedef struct estream_cookie_fp
/* Create function for FILE objects. */ /* Create function for FILE objects. */
static int static int
func_fp_create (void **cookie, FILE *fp, func_fp_create (void **cookie, FILE *fp,
unsigned int modeflags, int no_close) unsigned int modeflags, int no_close)
{ {
estream_cookie_fp_t fp_cookie; estream_cookie_fp_t fp_cookie;
@ -1249,7 +1249,7 @@ es_func_fp_seek (void *cookie, off_t *offset, int whence)
if (!file_cookie->fp) if (!file_cookie->fp)
{ {
_set_errno (ESPIPE); _set_errno (ESPIPE);
return -1; return -1;
} }
if ( fseek (file_cookie->fp, (long int)*offset, whence) ) if ( fseek (file_cookie->fp, (long int)*offset, whence) )
@ -1415,7 +1415,7 @@ parse_mode (const char *modestr,
case ',': case ',':
goto keyvalue; goto keyvalue;
default: /* Ignore unknown flags. */ default: /* Ignore unknown flags. */
break; break;
} }
} }
@ -1536,10 +1536,10 @@ es_flush (estream_t stream)
they were asked to write, we have to check for they were asked to write, we have to check for
"(stream->data_offset - data_flushed) > 0" instead of "(stream->data_offset - data_flushed) > 0" instead of
"stream->data_offset - data_flushed". */ "stream->data_offset - data_flushed". */
data_flushed = 0; data_flushed = 0;
err = 0; err = 0;
while ((((ssize_t) (stream->data_offset - data_flushed)) > 0) && (! err)) while ((((ssize_t) (stream->data_offset - data_flushed)) > 0) && (! err))
{ {
ret = (*func_write) (stream->intern->cookie, ret = (*func_write) (stream->intern->cookie,
@ -1573,7 +1573,7 @@ es_flush (estream_t stream)
err = 0; err = 0;
out: out:
if (err) if (err)
stream->intern->indicators.err = 1; stream->intern->indicators.err = 1;
@ -1896,7 +1896,7 @@ es_readn (estream_t ES__RESTRICT stream,
if (err) if (err)
goto out; goto out;
stream->flags.writing = 0; stream->flags.writing = 0;
} }
/* Read unread data first. */ /* Read unread data first. */
while ((bytes_to_read - data_read_unread) && stream->unread_data_len) while ((bytes_to_read - data_read_unread) && stream->unread_data_len)
@ -1993,7 +1993,7 @@ es_seek (estream_t ES__RESTRICT stream, off_t offset, int whence,
off = off - stream->data_len + stream->data_offset; off = off - stream->data_len + stream->data_offset;
off -= stream->unread_data_len; off -= stream->unread_data_len;
} }
ret = (*func_seek) (stream->intern->cookie, &off, whence); ret = (*func_seek) (stream->intern->cookie, &off, whence);
if (ret == -1) if (ret == -1)
{ {
@ -2011,7 +2011,7 @@ es_seek (estream_t ES__RESTRICT stream, off_t offset, int whence,
stream->intern->offset = off; stream->intern->offset = off;
out: out:
if (err) if (err)
stream->intern->indicators.err = 1; stream->intern->indicators.err = 1;
@ -2035,11 +2035,11 @@ es_write_nbf (estream_t ES__RESTRICT stream,
{ {
err = EOPNOTSUPP; err = EOPNOTSUPP;
goto out; goto out;
} }
data_written = 0; data_written = 0;
err = 0; err = 0;
while (bytes_to_write - data_written) while (bytes_to_write - data_written)
{ {
ret = (*func_write) (stream->intern->cookie, ret = (*func_write) (stream->intern->cookie,
@ -2087,12 +2087,12 @@ es_write_fbf (estream_t ES__RESTRICT stream,
if (! err) if (! err)
{ {
/* Flushing resulted in empty container. */ /* Flushing resulted in empty container. */
data_to_write = bytes_to_write - data_written; data_to_write = bytes_to_write - data_written;
space_available = stream->buffer_size - stream->data_offset; space_available = stream->buffer_size - stream->data_offset;
if (data_to_write > space_available) if (data_to_write > space_available)
data_to_write = space_available; data_to_write = space_available;
memcpy (stream->buffer + stream->data_offset, memcpy (stream->buffer + stream->data_offset,
buffer + data_written, data_to_write); buffer + data_written, data_to_write);
stream->data_offset += data_to_write; stream->data_offset += data_to_write;
@ -2153,7 +2153,7 @@ es_writen (estream_t ES__RESTRICT stream,
data_written = 0; data_written = 0;
err = 0; err = 0;
if (!stream->flags.writing) if (!stream->flags.writing)
{ {
/* Switching to writing mode -> discard input data and seek to /* Switching to writing mode -> discard input data and seek to
@ -2188,7 +2188,7 @@ es_writen (estream_t ES__RESTRICT stream,
} }
out: out:
if (bytes_written) if (bytes_written)
*bytes_written = data_written; *bytes_written = data_written;
if (data_written) if (data_written)
@ -2212,7 +2212,7 @@ es_peek (estream_t ES__RESTRICT stream, unsigned char **ES__RESTRICT data,
if (err) if (err)
goto out; goto out;
stream->flags.writing = 0; stream->flags.writing = 0;
} }
if (stream->data_offset == stream->data_len) if (stream->data_offset == stream->data_len)
{ {
@ -2221,7 +2221,7 @@ es_peek (estream_t ES__RESTRICT stream, unsigned char **ES__RESTRICT data,
if (err) if (err)
goto out; goto out;
} }
if (data) if (data)
*data = stream->buffer + stream->data_offset; *data = stream->buffer + stream->data_offset;
if (data_len) if (data_len)
@ -2277,7 +2277,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length,
err = func_mem_create (&line_stream_cookie, NULL, 0, 0, err = func_mem_create (&line_stream_cookie, NULL, 0, 0,
BUFFER_BLOCK_SIZE, 1, BUFFER_BLOCK_SIZE, 1,
mem_realloc, mem_free, mem_realloc, mem_free,
O_RDWR, O_RDWR,
0); 0);
if (err) if (err)
@ -2333,7 +2333,7 @@ doreadline (estream_t ES__RESTRICT stream, size_t max_length,
goto out; goto out;
/* Complete line has been written to line_stream. */ /* Complete line has been written to line_stream. */
if ((max_length > 1) && (! line_size)) if ((max_length > 1) && (! line_size))
{ {
stream->intern->indicators.eof = 1; stream->intern->indicators.eof = 1;
@ -2429,7 +2429,7 @@ static int
es_get_indicator (estream_t stream, int ind_err, int ind_eof) es_get_indicator (estream_t stream, int ind_err, int ind_eof)
{ {
int ret = 0; int ret = 0;
if (ind_err) if (ind_err)
ret = stream->intern->indicators.err; ret = stream->intern->indicators.err;
else if (ind_eof) else if (ind_eof)
@ -2456,7 +2456,7 @@ es_set_buffering (estream_t ES__RESTRICT stream,
es_empty (stream); es_empty (stream);
es_set_indicators (stream, -1, 0); es_set_indicators (stream, -1, 0);
/* Free old buffer in case that was allocated by this function. */ /* Free old buffer in case that was allocated by this function. */
if (stream->intern->deallocate_buffer) if (stream->intern->deallocate_buffer)
{ {
@ -2470,7 +2470,7 @@ es_set_buffering (estream_t ES__RESTRICT stream,
else else
{ {
void *buffer_new; void *buffer_new;
if (buffer) if (buffer)
buffer_new = buffer; buffer_new = buffer;
else else
@ -2560,11 +2560,11 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode)
err = parse_mode (mode, &modeflags, &cmode); err = parse_mode (mode, &modeflags, &cmode);
if (err) if (err)
goto out; goto out;
err = func_file_create (&cookie, &fd, path, modeflags, cmode); err = func_file_create (&cookie, &fd, path, modeflags, cmode);
if (err) if (err)
goto out; goto out;
syshd.type = ES_SYSHD_FD; syshd.type = ES_SYSHD_FD;
syshd.u.fd = fd; syshd.u.fd = fd;
@ -2577,7 +2577,7 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode)
fname_set_internal (stream, path, 1); fname_set_internal (stream, path, 1);
out: out:
if (err && create_called) if (err && create_called)
(*estream_functions_fd.func_close) (cookie); (*estream_functions_fd.func_close) (cookie);
@ -2602,17 +2602,17 @@ es_mopen (unsigned char *ES__RESTRICT data, size_t data_n, size_t data_len,
cookie = 0; cookie = 0;
stream = NULL; stream = NULL;
create_called = 0; create_called = 0;
err = parse_mode (mode, &modeflags, NULL); err = parse_mode (mode, &modeflags, NULL);
if (err) if (err)
goto out; goto out;
err = func_mem_create (&cookie, data, data_n, data_len, err = func_mem_create (&cookie, data, data_n, data_len,
BUFFER_BLOCK_SIZE, grow, BUFFER_BLOCK_SIZE, grow,
func_realloc, func_free, modeflags, 0); func_realloc, func_free, modeflags, 0);
if (err) if (err)
goto out; goto out;
memset (&syshd, 0, sizeof syshd); memset (&syshd, 0, sizeof syshd);
create_called = 1; create_called = 1;
err = es_create (&stream, cookie, &syshd, err = es_create (&stream, cookie, &syshd,
@ -2642,13 +2642,13 @@ es_fopenmem (size_t memlimit, const char *ES__RESTRICT mode)
return NULL; return NULL;
modeflags |= O_RDWR; modeflags |= O_RDWR;
if (func_mem_create (&cookie, NULL, 0, 0, if (func_mem_create (&cookie, NULL, 0, 0,
BUFFER_BLOCK_SIZE, 1, BUFFER_BLOCK_SIZE, 1,
mem_realloc, mem_free, modeflags, mem_realloc, mem_free, modeflags,
memlimit)) memlimit))
return NULL; return NULL;
memset (&syshd, 0, sizeof syshd); memset (&syshd, 0, sizeof syshd);
if (es_create (&stream, cookie, &syshd, estream_functions_mem, modeflags, 0)) if (es_create (&stream, cookie, &syshd, estream_functions_mem, modeflags, 0))
(*estream_functions_mem.func_close) (cookie); (*estream_functions_mem.func_close) (cookie);
@ -2670,7 +2670,7 @@ es_fopencookie (void *ES__RESTRICT cookie,
stream = NULL; stream = NULL;
modeflags = 0; modeflags = 0;
err = parse_mode (mode, &modeflags, NULL); err = parse_mode (mode, &modeflags, NULL);
if (err) if (err)
goto out; goto out;
@ -2774,7 +2774,7 @@ do_fpopen (FILE *fp, const char *mode, int no_close, int with_locked_list)
return stream; return stream;
} }
/* Create an estream from the stdio stream FP. This mechanism is /* Create an estream from the stdio stream FP. This mechanism is
useful in case the stdio streams have special properties and may useful in case the stdio streams have special properties and may
not be mixed with fd based functions. This is for example the case not be mixed with fd based functions. This is for example the case
@ -2844,7 +2844,7 @@ do_sysopen (es_syshd_t *syshd, const char *mode, int no_close)
case ES_SYSHD_SOCK: case ES_SYSHD_SOCK:
stream = do_fdopen (syshd->u.fd, mode, no_close, 0); stream = do_fdopen (syshd->u.fd, mode, no_close, 0);
break; break;
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
case ES_SYSHD_HANDLE: case ES_SYSHD_HANDLE:
stream = do_w32open (syshd->u.handle, mode, no_close, 0); stream = do_w32open (syshd->u.handle, mode, no_close, 0);
@ -2922,7 +2922,7 @@ _es_get_std_stream (int fd)
stream = do_fdopen (custom_std_fds[1], "a", 1, 1); stream = do_fdopen (custom_std_fds[1], "a", 1, 1);
else if (custom_std_fds_valid[2]) else if (custom_std_fds_valid[2])
stream = do_fdopen (custom_std_fds[2], "a", 1, 1); stream = do_fdopen (custom_std_fds[2], "a", 1, 1);
if (!stream) if (!stream)
{ {
/* Second try is to use the standard C streams. */ /* Second try is to use the standard C streams. */
@ -2933,8 +2933,8 @@ _es_get_std_stream (int fd)
else else
stream = do_fpopen (stderr, "a", 1, 1); stream = do_fpopen (stderr, "a", 1, 1);
} }
if (!stream) if (!stream)
{ {
/* Last try: Create a bit bucket. */ /* Last try: Create a bit bucket. */
stream = do_fpopen (NULL, fd? "a":"r", 0, 1); stream = do_fpopen (NULL, fd? "a":"r", 0, 1);
@ -2950,7 +2950,7 @@ _es_get_std_stream (int fd)
stream->intern->stdstream_fd = fd; stream->intern->stdstream_fd = fd;
if (fd == 2) if (fd == 2)
es_set_buffering (stream, NULL, _IOLBF, 0); es_set_buffering (stream, NULL, _IOLBF, 0);
fname_set_internal (stream, fname_set_internal (stream,
fd == 0? "[stdin]" : fd == 0? "[stdin]" :
fd == 1? "[stdout]" : "[stderr]", 0); fd == 1? "[stdout]" : "[stderr]", 0);
} }
@ -2975,7 +2975,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode,
cookie = NULL; cookie = NULL;
create_called = 0; create_called = 0;
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
es_deinitialize (stream); es_deinitialize (stream);
@ -2983,7 +2983,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode,
err = parse_mode (mode, &modeflags, &cmode); err = parse_mode (mode, &modeflags, &cmode);
if (err) if (err)
goto leave; goto leave;
err = func_file_create (&cookie, &fd, path, modeflags, cmode); err = func_file_create (&cookie, &fd, path, modeflags, cmode);
if (err) if (err)
goto leave; goto leave;
@ -2999,7 +2999,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode,
{ {
if (create_called) if (create_called)
es_func_fd_destroy (cookie); es_func_fd_destroy (cookie);
do_close (stream, 0); do_close (stream, 0);
stream = NULL; stream = NULL;
} }
@ -3057,7 +3057,7 @@ es_onclose (estream_t stream, int mode,
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
err = do_onclose (stream, mode, fnc, fnc_value); err = do_onclose (stream, mode, fnc, fnc_value);
ESTREAM_UNLOCK (stream); ESTREAM_UNLOCK (stream);
return err; return err;
} }
@ -3073,7 +3073,7 @@ es_fileno_unlocked (estream_t stream)
{ {
case ES_SYSHD_FD: return syshd.u.fd; case ES_SYSHD_FD: return syshd.u.fd;
case ES_SYSHD_SOCK: return syshd.u.sock; case ES_SYSHD_SOCK: return syshd.u.sock;
default: default:
_set_errno (EINVAL); _set_errno (EINVAL);
return -1; return -1;
} }
@ -3094,7 +3094,7 @@ es_syshd_unlocked (estream_t stream, es_syshd_t *syshd)
_set_errno (EINVAL); _set_errno (EINVAL);
return -1; return -1;
} }
*syshd = stream->intern->syshd; *syshd = stream->intern->syshd;
return 0; return 0;
} }
@ -3211,7 +3211,7 @@ static int
do_fflush (estream_t stream) do_fflush (estream_t stream)
{ {
int err; int err;
if (stream->flags.writing) if (stream->flags.writing)
err = es_flush (stream); err = es_flush (stream);
else else
@ -3228,7 +3228,7 @@ int
es_fflush (estream_t stream) es_fflush (estream_t stream)
{ {
int err; int err;
if (stream) if (stream)
{ {
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
@ -3259,7 +3259,7 @@ int
es_fseeko (estream_t stream, off_t offset, int whence) es_fseeko (estream_t stream, off_t offset, int whence)
{ {
int err; int err;
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
err = es_seek (stream, offset, whence, NULL); err = es_seek (stream, offset, whence, NULL);
ESTREAM_UNLOCK (stream); ESTREAM_UNLOCK (stream);
@ -3272,7 +3272,7 @@ long int
es_ftell (estream_t stream) es_ftell (estream_t stream)
{ {
long int ret; long int ret;
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
ret = es_offset_calculate (stream); ret = es_offset_calculate (stream);
ESTREAM_UNLOCK (stream); ESTREAM_UNLOCK (stream);
@ -3333,7 +3333,7 @@ int
es_fgetc (estream_t stream) es_fgetc (estream_t stream)
{ {
int ret; int ret;
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
ret = es_getc_unlocked (stream); ret = es_getc_unlocked (stream);
ESTREAM_UNLOCK (stream); ESTREAM_UNLOCK (stream);
@ -3346,7 +3346,7 @@ int
es_fputc (int c, estream_t stream) es_fputc (int c, estream_t stream)
{ {
int ret; int ret;
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
ret = es_putc_unlocked (c, stream); ret = es_putc_unlocked (c, stream);
ESTREAM_UNLOCK (stream); ESTREAM_UNLOCK (stream);
@ -3458,10 +3458,10 @@ es_fgets (char *ES__RESTRICT buffer, int length, estream_t ES__RESTRICT stream)
{ {
unsigned char *s = (unsigned char*)buffer; unsigned char *s = (unsigned char*)buffer;
int c; int c;
if (!length) if (!length)
return NULL; return NULL;
c = EOF; c = EOF;
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
while (length > 1 && (c = es_getc_unlocked (stream)) != EOF && c != '\n') while (length > 1 && (c = es_getc_unlocked (stream)) != EOF && c != '\n')
@ -3525,7 +3525,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n,
if (*n) if (*n)
{ {
/* Caller wants us to use his buffer. */ /* Caller wants us to use his buffer. */
if (*n < (line_n + 1)) if (*n < (line_n + 1))
{ {
/* Provided buffer is too small -> resize. */ /* Provided buffer is too small -> resize. */
@ -3569,7 +3569,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n,
considered a byte stream ending in a LF. considered a byte stream ending in a LF.
If MAX_LENGTH is not NULL, it shall point to a value with the If MAX_LENGTH is not NULL, it shall point to a value with the
maximum allowed allocation. maximum allowed allocation.
Returns the length of the line. EOF is indicated by a line of Returns the length of the line. EOF is indicated by a line of
length zero. A truncated line is indicated my setting the value at length zero. A truncated line is indicated my setting the value at
@ -3593,7 +3593,7 @@ es_getline (char *ES__RESTRICT *ES__RESTRICT lineptr, size_t *ES__RESTRICT n,
released using es_free. released using es_free.
*/ */
ssize_t ssize_t
es_read_line (estream_t stream, es_read_line (estream_t stream,
char **addr_of_buffer, size_t *length_of_buffer, char **addr_of_buffer, size_t *length_of_buffer,
size_t *max_length) size_t *max_length)
{ {
@ -3605,7 +3605,7 @@ es_read_line (estream_t stream,
char *p; char *p;
if (!buffer) if (!buffer)
{ {
/* No buffer given - allocate a new one. */ /* No buffer given - allocate a new one. */
length = 256; length = 256;
buffer = mem_alloc (length); buffer = mem_alloc (length);
@ -3634,9 +3634,9 @@ es_read_line (estream_t stream,
while ((c = es_getc_unlocked (stream)) != EOF) while ((c = es_getc_unlocked (stream)) != EOF)
{ {
if (nbytes == length) if (nbytes == length)
{ {
/* Enlarge the buffer. */ /* Enlarge the buffer. */
if (maxlen && length > maxlen) if (maxlen && length > maxlen)
{ {
/* We are beyond our limit: Skip the rest of the line. */ /* We are beyond our limit: Skip the rest of the line. */
while (c != '\n' && (c=es_getc_unlocked (stream)) != EOF) while (c != '\n' && (c=es_getc_unlocked (stream)) != EOF)
@ -3653,7 +3653,7 @@ es_read_line (estream_t stream,
if (!*addr_of_buffer) if (!*addr_of_buffer)
{ {
int save_errno = errno; int save_errno = errno;
mem_free (buffer); mem_free (buffer);
*length_of_buffer = 0; *length_of_buffer = 0;
if (max_length) if (max_length)
*max_length = 0; *max_length = 0;
@ -3663,7 +3663,7 @@ es_read_line (estream_t stream,
} }
buffer = *addr_of_buffer; buffer = *addr_of_buffer;
*length_of_buffer = length; *length_of_buffer = length;
length -= 3; length -= 3;
p = buffer + nbytes; p = buffer + nbytes;
} }
*p++ = c; *p++ = c;
@ -3701,7 +3701,7 @@ es_vfprintf (estream_t ES__RESTRICT stream, const char *ES__RESTRICT format,
va_list ap) va_list ap)
{ {
int ret; int ret;
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
ret = es_print (stream, format, ap); ret = es_print (stream, format, ap);
ESTREAM_UNLOCK (stream); ESTREAM_UNLOCK (stream);
@ -3715,7 +3715,7 @@ es_fprintf_unlocked (estream_t ES__RESTRICT stream,
const char *ES__RESTRICT format, ...) const char *ES__RESTRICT format, ...)
{ {
int ret; int ret;
va_list ap; va_list ap;
va_start (ap, format); va_start (ap, format);
ret = es_print (stream, format, ap); ret = es_print (stream, format, ap);
@ -3730,7 +3730,7 @@ es_fprintf (estream_t ES__RESTRICT stream,
const char *ES__RESTRICT format, ...) const char *ES__RESTRICT format, ...)
{ {
int ret; int ret;
va_list ap; va_list ap;
va_start (ap, format); va_start (ap, format);
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
@ -3746,7 +3746,7 @@ int
es_printf_unlocked (const char *ES__RESTRICT format, ...) es_printf_unlocked (const char *ES__RESTRICT format, ...)
{ {
int ret; int ret;
va_list ap; va_list ap;
va_start (ap, format); va_start (ap, format);
ret = es_print (es_stdout, format, ap); ret = es_print (es_stdout, format, ap);
@ -3761,7 +3761,7 @@ es_printf (const char *ES__RESTRICT format, ...)
{ {
int ret; int ret;
estream_t stream = es_stdout; estream_t stream = es_stdout;
va_list ap; va_list ap;
va_start (ap, format); va_start (ap, format);
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
@ -3799,7 +3799,7 @@ es_asprintf (const char *ES__RESTRICT format, ...)
should use es_free to release the buffer. This function actually should use es_free to release the buffer. This function actually
belongs into estream-printf but we put it here as a convenience belongs into estream-printf but we put it here as a convenience
and because es_free is required anyway. */ and because es_free is required anyway. */
char * char *
es_vasprintf (const char *ES__RESTRICT format, va_list ap) es_vasprintf (const char *ES__RESTRICT format, va_list ap)
{ {
int rc; int rc;
@ -3830,7 +3830,7 @@ tmpfd (void)
int pid = GetCurrentProcessId (); int pid = GetCurrentProcessId ();
unsigned int value; unsigned int value;
int i; int i;
n = GetTempPath (MAX_PATH+1, buffer); n = GetTempPath (MAX_PATH+1, buffer);
if (!n || n > MAX_PATH || mystrlen (buffer) > MAX_PATH) if (!n || n > MAX_PATH || mystrlen (buffer) > MAX_PATH)
{ {
@ -3896,7 +3896,7 @@ tmpfd (void)
fp = NULL; fp = NULL;
fd = -1; fd = -1;
fp = tmpfile (); fp = tmpfile ();
if (! fp) if (! fp)
goto out; goto out;
@ -3928,7 +3928,7 @@ es_tmpfile (void)
stream = NULL; stream = NULL;
modeflags = O_RDWR | O_TRUNC | O_CREAT; modeflags = O_RDWR | O_TRUNC | O_CREAT;
cookie = NULL; cookie = NULL;
fd = tmpfd (); fd = tmpfd ();
if (fd == -1) if (fd == -1)
{ {
@ -3954,7 +3954,7 @@ es_tmpfile (void)
close (fd); close (fd);
stream = NULL; stream = NULL;
} }
return stream; return stream;
} }
@ -3964,7 +3964,7 @@ es_setvbuf (estream_t ES__RESTRICT stream,
char *ES__RESTRICT buf, int type, size_t size) char *ES__RESTRICT buf, int type, size_t size)
{ {
int err; int err;
if ((type == _IOFBF || type == _IOLBF || type == _IONBF) if ((type == _IOFBF || type == _IOLBF || type == _IONBF)
&& (!buf || size || type == _IONBF)) && (!buf || size || type == _IONBF))
{ {
@ -4036,7 +4036,7 @@ void *
es_opaque_get (estream_t stream) es_opaque_get (estream_t stream)
{ {
void *opaque; void *opaque;
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
es_opaque_ctrl (stream, NULL, &opaque); es_opaque_ctrl (stream, NULL, &opaque);
ESTREAM_UNLOCK (stream); ESTREAM_UNLOCK (stream);
@ -4111,10 +4111,10 @@ es_fname_get (estream_t stream)
Returns 0 on success or -1 on error. If BYTES_WRITTEN is not NULL Returns 0 on success or -1 on error. If BYTES_WRITTEN is not NULL
the number of bytes actually written are stored at this the number of bytes actually written are stored at this
address. */ address. */
int int
es_write_sanitized (estream_t ES__RESTRICT stream, es_write_sanitized (estream_t ES__RESTRICT stream,
const void * ES__RESTRICT buffer, size_t length, const void * ES__RESTRICT buffer, size_t length,
const char * delimiters, const char * delimiters,
size_t * ES__RESTRICT bytes_written) size_t * ES__RESTRICT bytes_written)
{ {
const unsigned char *p = buffer; const unsigned char *p = buffer;
@ -4124,9 +4124,9 @@ es_write_sanitized (estream_t ES__RESTRICT stream,
ESTREAM_LOCK (stream); ESTREAM_LOCK (stream);
for (; length; length--, p++, count++) for (; length; length--, p++, count++)
{ {
if (*p < 0x20 if (*p < 0x20
|| *p == 0x7f || *p == 0x7f
|| (delimiters || (delimiters
&& (strchr (delimiters, *p) || *p == '\\'))) && (strchr (delimiters, *p) || *p == '\\')))
{ {
es_putc_unlocked ('\\', stream); es_putc_unlocked ('\\', stream);
@ -4228,19 +4228,19 @@ es_write_hexstring (estream_t ES__RESTRICT stream,
#ifdef GNUPG_MAJOR_VERSION #ifdef GNUPG_MAJOR_VERSION
/* Special estream function to print an UTF8 string in the native /* Special estream function to print an UTF8 string in the native
encoding. The interface is the same as es_write_sanitized, however encoding. The interface is the same as es_write_sanitized, however
only one delimiter may be supported. only one delimiter may be supported.
THIS IS NOT A STANDARD ESTREAM FUNCTION AND ONLY USED BY GNUPG!. */ THIS IS NOT A STANDARD ESTREAM FUNCTION AND ONLY USED BY GNUPG!. */
int int
es_write_sanitized_utf8_buffer (estream_t stream, es_write_sanitized_utf8_buffer (estream_t stream,
const void *buffer, size_t length, const void *buffer, size_t length,
const char *delimiters, size_t *bytes_written) const char *delimiters, size_t *bytes_written)
{ {
const char *p = buffer; const char *p = buffer;
size_t i; size_t i;
/* We can handle plain ascii simpler, so check for it first. */ /* We can handle plain ascii simpler, so check for it first. */
for (i=0; i < length; i++ ) for (i=0; i < length; i++ )
{ {
if ( (p[i] & 0x80) ) if ( (p[i] & 0x80) )
break; break;

View File

@ -215,7 +215,7 @@ typedef struct es_cookie_io_functions
} es_cookie_io_functions_t; } es_cookie_io_functions_t;
enum es_syshd_types enum es_syshd_types
{ {
ES_SYSHD_NONE, /* No system handle available. */ ES_SYSHD_NONE, /* No system handle available. */
ES_SYSHD_FD, /* A file descriptor as returned by open(). */ ES_SYSHD_FD, /* A file descriptor as returned by open(). */

View File

@ -30,7 +30,7 @@ topheader == 1 && /\*\// { topheader = 2; print "" }
/AUDIT_NULL_EVENT/ { okay = 1 } /AUDIT_NULL_EVENT/ { okay = 1 }
!okay { next } !okay { next }
/AUDIT_LAST_EVENT/ { exit } /AUDIT_LAST_EVENT/ { exit }
/AUDIT_[A-Za-z_]+/ { /AUDIT_[A-Za-z_]+/ {
sub (/[,\/\*]+/, "", $1); sub (/[,\/\*]+/, "", $1);
desc = tolower (substr($1,7)); desc = tolower (substr($1,7));
gsub (/_/," ",desc); gsub (/_/," ",desc);

View File

@ -32,7 +32,7 @@
#ifdef HAVE_SIGNAL_H #ifdef HAVE_SIGNAL_H
# include <signal.h> # include <signal.h>
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */
@ -40,7 +40,7 @@
#undef USE_GNU_PTH #undef USE_GNU_PTH
#endif #endif
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
#include <pth.h> #include <pth.h>
#endif #endif
#include <sys/wait.h> #include <sys/wait.h>
@ -64,7 +64,7 @@
and some are not. However we want to use pth_fork and pth_waitpid and some are not. However we want to use pth_fork and pth_waitpid
here. Using a weak symbol works but is not portable - we should here. Using a weak symbol works but is not portable - we should
provide a an explicit dummy pth module instead of using the provide a an explicit dummy pth module instead of using the
pragma. */ pragma. */
#pragma weak pth_fork #pragma weak pth_fork
#pragma weak pth_waitpid #pragma weak pth_waitpid
@ -181,7 +181,7 @@ get_all_open_fds (void)
array = calloc (narray, sizeof *array); array = calloc (narray, sizeof *array);
if (!array) if (!array)
return NULL; return NULL;
/* Note: The list we return is ordered. */ /* Note: The list we return is ordered. */
for (idx=0, fd=0; fd < max_fd; fd++) for (idx=0, fd=0; fd < max_fd; fd++)
if (!(fstat (fd, &statbuf) == -1 && errno == EBADF)) if (!(fstat (fd, &statbuf) == -1 && errno == EBADF))
@ -258,7 +258,7 @@ do_exec (const char *pgmname, const char *argv[],
/* Close all other files. */ /* Close all other files. */
close_all_fds (3, NULL); close_all_fds (3, NULL);
if (preexec) if (preexec)
preexec (); preexec ();
execv (pgmname, arg_list); execv (pgmname, arg_list);
@ -328,7 +328,7 @@ create_pipe_and_estream (int filedes[2], estream_t *r_fp,
} }
return 0; return 0;
} }
/* Fork and exec the PGMNAME, see exechelp.h for details. */ /* Fork and exec the PGMNAME, see exechelp.h for details. */
@ -388,7 +388,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
} }
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
*pid = pth_fork? pth_fork () : fork (); *pid = pth_fork? pth_fork () : fork ();
#else #else
*pid = fork (); *pid = fork ();
@ -415,7 +415,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
} }
if (!*pid) if (!*pid)
{ {
/* This is the child. */ /* This is the child. */
gcry_control (GCRYCTL_TERM_SECMEM); gcry_control (GCRYCTL_TERM_SECMEM);
es_fclose (outfp); es_fclose (outfp);
@ -454,7 +454,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
{ {
gpg_error_t err; gpg_error_t err;
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
*pid = pth_fork? pth_fork () : fork (); *pid = pth_fork? pth_fork () : fork ();
#else #else
*pid = fork (); *pid = fork ();
@ -467,7 +467,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
} }
if (!*pid) if (!*pid)
{ {
gcry_control (GCRYCTL_TERM_SECMEM); gcry_control (GCRYCTL_TERM_SECMEM);
/* Run child. */ /* Run child. */
do_exec (pgmname, argv, infd, outfd, errfd, NULL); do_exec (pgmname, argv, infd, outfd, errfd, NULL);
@ -501,7 +501,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode)
&& errno == EINTR) && errno == EINTR)
; ;
} }
if (i == (pid_t)(-1)) if (i == (pid_t)(-1))
{ {
ec = gpg_err_code_from_errno (errno); ec = gpg_err_code_from_errno (errno);
@ -531,7 +531,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode)
log_error (_("error running `%s': terminated\n"), pgmname); log_error (_("error running `%s': terminated\n"), pgmname);
ec = GPG_ERR_GENERAL; ec = GPG_ERR_GENERAL;
} }
else else
{ {
if (r_exitcode) if (r_exitcode)
*r_exitcode = 0; *r_exitcode = 0;
@ -569,7 +569,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
if (access (pgmname, X_OK)) if (access (pgmname, X_OK))
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
pid = pth_fork? pth_fork () : fork (); pid = pth_fork? pth_fork () : fork ();
#else #else
pid = fork (); pid = fork ();
@ -596,12 +596,12 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
if (envp) if (envp)
for (i=0; envp[i]; i++) for (i=0; envp[i]; i++)
putenv (xstrdup (envp[i])); putenv (xstrdup (envp[i]));
do_exec (pgmname, argv, -1, -1, -1, NULL); do_exec (pgmname, argv, -1, -1, -1, NULL);
/*NOTREACHED*/ /*NOTREACHED*/
} }
if (waitpid (pid, NULL, 0) == -1) if (waitpid (pid, NULL, 0) == -1)
log_error ("waitpid failed in gnupg_spawn_process_detached: %s", log_error ("waitpid failed in gnupg_spawn_process_detached: %s",
strerror (errno)); strerror (errno));
@ -618,6 +618,6 @@ gnupg_kill_process (pid_t pid)
{ {
if (pid != (pid_t)(-1)) if (pid != (pid_t)(-1))
{ {
kill (pid, SIGTERM); kill (pid, SIGTERM);
} }
} }

View File

@ -32,7 +32,7 @@
#ifdef HAVE_SIGNAL_H #ifdef HAVE_SIGNAL_H
# include <signal.h> # include <signal.h>
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */
@ -40,7 +40,7 @@
#undef USE_GNU_PTH #undef USE_GNU_PTH
#endif #endif
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
#include <pth.h> #include <pth.h>
#endif #endif
@ -127,7 +127,7 @@ get_all_open_fds (void)
array = calloc (narray, sizeof *array); array = calloc (narray, sizeof *array);
if (!array) if (!array)
return NULL; return NULL;
/* Note: The list we return is ordered. */ /* Note: The list we return is ordered. */
for (idx=0, fd=0; fd < max_fd; fd++) for (idx=0, fd=0; fd < max_fd; fd++)
if (!(fstat (fd, &statbuf) == -1 && errno == EBADF)) if (!(fstat (fd, &statbuf) == -1 && errno == EBADF))
@ -184,7 +184,7 @@ build_w32_commandline_copy (char *buffer, const char *string)
/* Build a command line for use with W32's CreateProcess. On success /* Build a command line for use with W32's CreateProcess. On success
CMDLINE gets the address of a newly allocated string. */ CMDLINE gets the address of a newly allocated string. */
static gpg_error_t static gpg_error_t
build_w32_commandline (const char *pgmname, const char * const *argv, build_w32_commandline (const char *pgmname, const char * const *argv,
char **cmdline) char **cmdline)
{ {
int i, n; int i, n;
@ -212,7 +212,7 @@ build_w32_commandline (const char *pgmname, const char * const *argv,
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
p = build_w32_commandline_copy (p, pgmname); p = build_w32_commandline_copy (p, pgmname);
for (i=0; argv[i]; i++) for (i=0; argv[i]; i++)
{ {
*p++ = ' '; *p++ = ' ';
p = build_w32_commandline_copy (p, argv[i]); p = build_w32_commandline_copy (p, argv[i]);
@ -234,7 +234,7 @@ create_inheritable_pipe (HANDLE filedes[2], int inherit_idx)
memset (&sec_attr, 0, sizeof sec_attr ); memset (&sec_attr, 0, sizeof sec_attr );
sec_attr.nLength = sizeof sec_attr; sec_attr.nLength = sizeof sec_attr;
sec_attr.bInheritHandle = FALSE; sec_attr.bInheritHandle = FALSE;
if (!CreatePipe (&r, &w, &sec_attr, 0)) if (!CreatePipe (&r, &w, &sec_attr, 0))
return -1; return -1;
@ -296,7 +296,7 @@ do_create_pipe (int filedes[2], int inherit_idx)
log_error ("failed to translate osfhandle %p\n", fds[0]); log_error ("failed to translate osfhandle %p\n", fds[0]);
CloseHandle (fds[1]); CloseHandle (fds[1]);
} }
else else
{ {
filedes[1] = _open_osfhandle (handle_to_fd (fds[1]), 1); filedes[1] = _open_osfhandle (handle_to_fd (fds[1]), 1);
if (filedes[1] == -1) if (filedes[1] == -1)
@ -343,7 +343,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
{ {
gpg_error_t err; gpg_error_t err;
SECURITY_ATTRIBUTES sec_attr; SECURITY_ATTRIBUTES sec_attr;
PROCESS_INFORMATION pi = PROCESS_INFORMATION pi =
{ {
NULL, /* Returns process handle. */ NULL, /* Returns process handle. */
0, /* Returns primary thread handle. */ 0, /* Returns primary thread handle. */
@ -369,7 +369,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
if (r_errfp) if (r_errfp)
*r_errfp = NULL; *r_errfp = NULL;
*pid = (pid_t)(-1); /* Always required. */ *pid = (pid_t)(-1); /* Always required. */
if (infp) if (infp)
{ {
es_fflush (infp); es_fflush (infp);
@ -389,7 +389,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
default: default:
inhandle = INVALID_HANDLE_VALUE; inhandle = INVALID_HANDLE_VALUE;
break; break;
} }
if (inhandle == INVALID_HANDLE_VALUE) if (inhandle == INVALID_HANDLE_VALUE)
return gpg_err_make (errsource, GPG_ERR_INV_VALUE); return gpg_err_make (errsource, GPG_ERR_INV_VALUE);
/* FIXME: In case we can't get a system handle (e.g. due to /* FIXME: In case we can't get a system handle (e.g. due to
@ -455,11 +455,11 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
memset (&sec_attr, 0, sizeof sec_attr ); memset (&sec_attr, 0, sizeof sec_attr );
sec_attr.nLength = sizeof sec_attr; sec_attr.nLength = sizeof sec_attr;
sec_attr.bInheritHandle = FALSE; sec_attr.bInheritHandle = FALSE;
/* Build the command line. */ /* Build the command line. */
err = build_w32_commandline (pgmname, argv, &cmdline); err = build_w32_commandline (pgmname, argv, &cmdline);
if (err) if (err)
return err; return err;
if (inhandle != INVALID_HANDLE_VALUE) if (inhandle != INVALID_HANDLE_VALUE)
nullhd[0] = w32_open_null (0); nullhd[0] = w32_open_null (0);
@ -483,7 +483,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
cr_flags = (CREATE_DEFAULT_ERROR_MODE cr_flags = (CREATE_DEFAULT_ERROR_MODE
| ((flags & 128)? DETACHED_PROCESS : 0) | ((flags & 128)? DETACHED_PROCESS : 0)
| GetPriorityClass (GetCurrentProcess ()) | GetPriorityClass (GetCurrentProcess ())
| CREATE_SUSPENDED); | CREATE_SUSPENDED);
/* log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); */ /* log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); */
if (!CreateProcess (pgmname, /* Program to start. */ if (!CreateProcess (pgmname, /* Program to start. */
cmdline, /* Command line arguments. */ cmdline, /* Command line arguments. */
@ -526,7 +526,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
CloseHandle (outpipe[1]); CloseHandle (outpipe[1]);
if (errpipe[1] != INVALID_HANDLE_VALUE) if (errpipe[1] != INVALID_HANDLE_VALUE)
CloseHandle (errpipe[1]); CloseHandle (errpipe[1]);
/* log_debug ("CreateProcess ready: hProcess=%p hThread=%p" */ /* log_debug ("CreateProcess ready: hProcess=%p hThread=%p" */
/* " dwProcessID=%d dwThreadId=%d\n", */ /* " dwProcessID=%d dwThreadId=%d\n", */
/* pi.hProcess, pi.hThread, */ /* pi.hProcess, pi.hThread, */
@ -541,7 +541,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
/* Process has been created suspended; resume it now. */ /* Process has been created suspended; resume it now. */
ResumeThread (pi.hThread); ResumeThread (pi.hThread);
CloseHandle (pi.hThread); CloseHandle (pi.hThread);
if (r_outfp) if (r_outfp)
*r_outfp = outfp; *r_outfp = outfp;
@ -582,11 +582,11 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
memset (&sec_attr, 0, sizeof sec_attr ); memset (&sec_attr, 0, sizeof sec_attr );
sec_attr.nLength = sizeof sec_attr; sec_attr.nLength = sizeof sec_attr;
sec_attr.bInheritHandle = FALSE; sec_attr.bInheritHandle = FALSE;
/* Build the command line. */ /* Build the command line. */
err = build_w32_commandline (pgmname, argv, &cmdline); err = build_w32_commandline (pgmname, argv, &cmdline);
if (err) if (err)
return err; return err;
memset (&si, 0, sizeof si); memset (&si, 0, sizeof si);
si.cb = sizeof (si); si.cb = sizeof (si);
@ -633,7 +633,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
/* Process has been created suspended; resume it now. */ /* Process has been created suspended; resume it now. */
ResumeThread (pi.hThread); ResumeThread (pi.hThread);
CloseHandle (pi.hThread); CloseHandle (pi.hThread);
*pid = handle_to_pid (pi.hProcess); *pid = handle_to_pid (pi.hProcess);
return 0; return 0;
@ -660,7 +660,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode)
been implemented. A special W32 pth system call would even be been implemented. A special W32 pth system call would even be
better. */ better. */
code = WaitForSingleObject (proc, hang? INFINITE : 0); code = WaitForSingleObject (proc, hang? INFINITE : 0);
switch (code) switch (code)
{ {
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
ec = GPG_ERR_TIMEOUT; ec = GPG_ERR_TIMEOUT;
@ -694,14 +694,14 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *r_exitcode)
ec = 0; ec = 0;
} }
break; break;
default: default:
log_error ("WaitForSingleObject returned unexpected " log_error ("WaitForSingleObject returned unexpected "
"code %d for pid %d\n", code, (int)pid ); "code %d for pid %d\n", code, (int)pid );
ec = GPG_ERR_GENERAL; ec = GPG_ERR_GENERAL;
break; break;
} }
return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec); return gpg_err_make (GPG_ERR_SOURCE_DEFAULT, ec);
} }
@ -713,7 +713,7 @@ gnupg_release_process (pid_t pid)
if (pid != (pid_t)INVALID_HANDLE_VALUE) if (pid != (pid_t)INVALID_HANDLE_VALUE)
{ {
HANDLE process = (HANDLE)pid; HANDLE process = (HANDLE)pid;
CloseHandle (process); CloseHandle (process);
} }
} }
@ -732,7 +732,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
{ {
gpg_error_t err; gpg_error_t err;
SECURITY_ATTRIBUTES sec_attr; SECURITY_ATTRIBUTES sec_attr;
PROCESS_INFORMATION pi = PROCESS_INFORMATION pi =
{ {
NULL, /* Returns process handle. */ NULL, /* Returns process handle. */
0, /* Returns primary thread handle. */ 0, /* Returns primary thread handle. */
@ -757,11 +757,11 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
memset (&sec_attr, 0, sizeof sec_attr ); memset (&sec_attr, 0, sizeof sec_attr );
sec_attr.nLength = sizeof sec_attr; sec_attr.nLength = sizeof sec_attr;
sec_attr.bInheritHandle = FALSE; sec_attr.bInheritHandle = FALSE;
/* Build the command line. */ /* Build the command line. */
err = build_w32_commandline (pgmname, argv, &cmdline); err = build_w32_commandline (pgmname, argv, &cmdline);
if (err) if (err)
return err; return err;
/* Start the process. */ /* Start the process. */
memset (&si, 0, sizeof si); memset (&si, 0, sizeof si);
@ -772,7 +772,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
cr_flags = (CREATE_DEFAULT_ERROR_MODE cr_flags = (CREATE_DEFAULT_ERROR_MODE
| GetPriorityClass (GetCurrentProcess ()) | GetPriorityClass (GetCurrentProcess ())
| CREATE_NEW_PROCESS_GROUP | CREATE_NEW_PROCESS_GROUP
| DETACHED_PROCESS); | DETACHED_PROCESS);
/* log_debug ("CreateProcess(detached), path=`%s' cmdline=`%s'\n", */ /* log_debug ("CreateProcess(detached), path=`%s' cmdline=`%s'\n", */
/* pgmname, cmdline); */ /* pgmname, cmdline); */
if (!CreateProcess (pgmname, /* Program to start. */ if (!CreateProcess (pgmname, /* Program to start. */
@ -799,7 +799,7 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
/* pi.hProcess, pi.hThread, */ /* pi.hProcess, pi.hThread, */
/* (int) pi.dwProcessId, (int) pi.dwThreadId); */ /* (int) pi.dwProcessId, (int) pi.dwThreadId); */
CloseHandle (pi.hThread); CloseHandle (pi.hThread);
return 0; return 0;
} }
@ -814,7 +814,7 @@ gnupg_kill_process (pid_t pid)
if (pid != (pid_t) INVALID_HANDLE_VALUE) if (pid != (pid_t) INVALID_HANDLE_VALUE)
{ {
HANDLE process = (HANDLE) pid; HANDLE process = (HANDLE) pid;
/* Arbitrary error code. */ /* Arbitrary error code. */
TerminateProcess (process, 1); TerminateProcess (process, 1);
} }

View File

@ -32,7 +32,7 @@
#ifdef HAVE_SIGNAL_H #ifdef HAVE_SIGNAL_H
# include <signal.h> # include <signal.h>
#endif #endif
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */ #ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */
@ -40,7 +40,7 @@
#undef USE_GNU_PTH #undef USE_GNU_PTH
#endif #endif
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
#include <pth.h> #include <pth.h>
#endif #endif
@ -73,8 +73,8 @@
#define handle_to_pid(a) ((int)(a)) #define handle_to_pid(a) ((int)(a))
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
/* The data passed to the feeder_thread. */ /* The data passed to the feeder_thread. */
struct feeder_thread_parms struct feeder_thread_parms
{ {
estream_t stream; estream_t stream;
@ -173,7 +173,7 @@ leave:
} }
#endif /*USE_GNU_PTH*/ #endif /*USE_GNU_PTH*/
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
static void static void
feeder_onclose_notification (estream_t stream, void *opaque) feeder_onclose_notification (estream_t stream, void *opaque)
{ {
@ -191,11 +191,11 @@ feeder_onclose_notification (estream_t stream, void *opaque)
static gpg_error_t static gpg_error_t
start_feeder (estream_t stream, HANDLE hd, int direction) start_feeder (estream_t stream, HANDLE hd, int direction)
{ {
#ifdef USE_GNU_PTH #ifdef USE_GNU_PTH
gpg_error_t err; gpg_error_t err;
struct feeder_thread_parms *parm; struct feeder_thread_parms *parm;
pth_attr_t tattr; pth_attr_t tattr;
parm = xtrymalloc (sizeof *parm); parm = xtrymalloc (sizeof *parm);
if (!parm) if (!parm)
return gpg_error_from_syserror (); return gpg_error_from_syserror ();
@ -210,12 +210,12 @@ start_feeder (estream_t stream, HANDLE hd, int direction)
xfree (parm); xfree (parm);
return err; return err;
} }
tattr = pth_attr_new (); tattr = pth_attr_new ();
pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0); pth_attr_set (tattr, PTH_ATTR_JOINABLE, 0);
pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 64*1024); pth_attr_set (tattr, PTH_ATTR_STACK_SIZE, 64*1024);
pth_attr_set (tattr, PTH_ATTR_NAME, "exec-feeder"); pth_attr_set (tattr, PTH_ATTR_NAME, "exec-feeder");
log_debug ("spawning new feeder(%p, %p, %d)\n", stream, hd, direction); log_debug ("spawning new feeder(%p, %p, %d)\n", stream, hd, direction);
if(!pth_spawn (tattr, feeder_thread, parm)) if(!pth_spawn (tattr, feeder_thread, parm))
{ {
@ -291,7 +291,7 @@ get_all_open_fds (void)
array = calloc (narray, sizeof *array); array = calloc (narray, sizeof *array);
if (!array) if (!array)
return NULL; return NULL;
/* Note: The list we return is ordered. */ /* Note: The list we return is ordered. */
for (idx=0, fd=0; fd < max_fd; fd++) for (idx=0, fd=0; fd < max_fd; fd++)
if (!(fstat (fd, &statbuf) == -1 && errno == EBADF)) if (!(fstat (fd, &statbuf) == -1 && errno == EBADF))
@ -376,7 +376,7 @@ build_w32_commandline (const char * const *argv,
else else
strcpy (p, "-&S2=null "); strcpy (p, "-&S2=null ");
p += strlen (p); p += strlen (p);
*cmdline = NULL; *cmdline = NULL;
n = strlen (fdbuf); n = strlen (fdbuf);
for (i=0; (s = argv[i]); i++) for (i=0; (s = argv[i]); i++)
@ -393,7 +393,7 @@ build_w32_commandline (const char * const *argv,
return -1; return -1;
p = stpcpy (p, fdbuf); p = stpcpy (p, fdbuf);
for (i = 0; argv[i]; i++) for (i = 0; argv[i]; i++)
{ {
*p++ = ' '; *p++ = ' ';
p = copy_quoted (p, argv[i]); p = copy_quoted (p, argv[i]);
@ -518,7 +518,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
(void)preexec; (void)preexec;
(void)flags; (void)flags;
/* Setup return values. */ /* Setup return values. */
if (r_outfp) if (r_outfp)
*r_outfp = NULL; *r_outfp = NULL;
@ -623,7 +623,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
{ {
/* Fixme release other stuff/kill feeder. */ /* Fixme release other stuff/kill feeder. */
CloseHandle (errpipe.hd); CloseHandle (errpipe.hd);
return err; return err;
} }
log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline);
@ -645,11 +645,11 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
" dwProcessID=%d dwThreadId=%d\n", " dwProcessID=%d dwThreadId=%d\n",
pi.hProcess, pi.hThread, pi.hProcess, pi.hThread,
(int) pi.dwProcessId, (int) pi.dwThreadId); (int) pi.dwProcessId, (int) pi.dwThreadId);
/* Process has been created suspended; resume it now. */ /* Process has been created suspended; resume it now. */
ResumeThread (pi.hThread); ResumeThread (pi.hThread);
CloseHandle (pi.hThread); CloseHandle (pi.hThread);
if (r_outfp) if (r_outfp)
*r_outfp = outfp; *r_outfp = outfp;
@ -686,7 +686,7 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
/* Build the command line. */ /* Build the command line. */
err = build_w32_commandline (argv, 0, 0, 0, &cmdline); err = build_w32_commandline (argv, 0, 0, 0, &cmdline);
if (err) if (err)
return err; return err;
log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline);
if (!create_process (pgmname, cmdline, &pi)) if (!create_process (pgmname, cmdline, &pi))
@ -702,10 +702,10 @@ gnupg_spawn_process_fd (const char *pgmname, const char *argv[],
" dwProcessID=%d dwThreadId=%d\n", " dwProcessID=%d dwThreadId=%d\n",
pi.hProcess, pi.hThread, pi.hProcess, pi.hThread,
(int) pi.dwProcessId, (int) pi.dwThreadId); (int) pi.dwProcessId, (int) pi.dwThreadId);
/* Process has been created suspended; resume it now. */ /* Process has been created suspended; resume it now. */
ResumeThread (pi.hThread); ResumeThread (pi.hThread);
CloseHandle (pi.hThread); CloseHandle (pi.hThread);
*pid = handle_to_pid (pi.hProcess); *pid = handle_to_pid (pi.hProcess);
return 0; return 0;
@ -731,12 +731,12 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *exitcode)
been implemented. A special W32 pth system call would even be been implemented. A special W32 pth system call would even be
better. */ better. */
code = WaitForSingleObject (proc, hang? INFINITE : 0); code = WaitForSingleObject (proc, hang? INFINITE : 0);
switch (code) switch (code)
{ {
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
ec = GPG_ERR_TIMEOUT; ec = GPG_ERR_TIMEOUT;
break; break;
case WAIT_FAILED: case WAIT_FAILED:
log_error (_("waiting for process %d to terminate failed: %s\n"), log_error (_("waiting for process %d to terminate failed: %s\n"),
(int)pid, w32_strerror (-1)); (int)pid, w32_strerror (-1));
@ -765,7 +765,7 @@ gnupg_wait_process (const char *pgmname, pid_t pid, int hang, int *exitcode)
ec = 0; ec = 0;
} }
break; break;
default: default:
log_error ("WaitForSingleObject returned unexpected " log_error ("WaitForSingleObject returned unexpected "
"code %d for pid %d\n", code, (int)pid ); "code %d for pid %d\n", code, (int)pid );
@ -783,7 +783,7 @@ gnupg_release_process (pid_t pid)
if (pid != (pid_t)INVALID_HANDLE_VALUE) if (pid != (pid_t)INVALID_HANDLE_VALUE)
{ {
HANDLE process = (HANDLE)pid; HANDLE process = (HANDLE)pid;
CloseHandle (process); CloseHandle (process);
} }
} }
@ -805,11 +805,11 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
PROCESS_INFORMATION pi = {NULL }; PROCESS_INFORMATION pi = {NULL };
(void)envp; (void)envp;
/* Build the command line. */ /* Build the command line. */
err = build_w32_commandline (argv, 0, 0, 0, &cmdline); err = build_w32_commandline (argv, 0, 0, 0, &cmdline);
if (err) if (err)
return err; return err;
/* Note: There is no detached flag under CE. */ /* Note: There is no detached flag under CE. */
log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline);
@ -826,10 +826,10 @@ gnupg_spawn_process_detached (const char *pgmname, const char *argv[],
" dwProcessID=%d dwThreadId=%d\n", " dwProcessID=%d dwThreadId=%d\n",
pi.hProcess, pi.hThread, pi.hProcess, pi.hThread,
(int) pi.dwProcessId, (int) pi.dwThreadId); (int) pi.dwProcessId, (int) pi.dwThreadId);
/* Process has been created suspended; resume it now. */ /* Process has been created suspended; resume it now. */
ResumeThread (pi.hThread); ResumeThread (pi.hThread);
CloseHandle (pi.hThread); CloseHandle (pi.hThread);
return 0; return 0;
} }
@ -844,7 +844,7 @@ gnupg_kill_process (pid_t pid)
if (pid != (pid_t) INVALID_HANDLE_VALUE) if (pid != (pid_t) INVALID_HANDLE_VALUE)
{ {
HANDLE process = (HANDLE) pid; HANDLE process = (HANDLE) pid;
/* Arbitrary error code. */ /* Arbitrary error code. */
TerminateProcess (process, 1); TerminateProcess (process, 1);
} }

View File

@ -66,7 +66,7 @@ gpg_error_t gnupg_create_outbound_pipe (int filedes[2]);
The arguments for the process are expected in the NULL terminated The arguments for the process are expected in the NULL terminated
array ARGV. The program name itself should not be included there. array ARGV. The program name itself should not be included there.
If PREEXEC is not NULL, the given function will be called right If PREEXEC is not NULL, the given function will be called right
before the exec. before the exec.
Returns 0 on success or an error code. Calling gnupg_wait_process Returns 0 on success or an error code. Calling gnupg_wait_process
and gnupg_release_process is required if the function succeeded. and gnupg_release_process is required if the function succeeded.
@ -77,7 +77,7 @@ gpg_error_t gnupg_create_outbound_pipe (int filedes[2]);
This flag is only useful under W32 (but not W32CE) systems, This flag is only useful under W32 (but not W32CE) systems,
so that no new console is created and pops up a console so that no new console is created and pops up a console
window when starting the server. Does not work on W32CE. window when starting the server. Does not work on W32CE.
Bit 6: On W32 (but not on W32CE) run AllowSetForegroundWindow for Bit 6: On W32 (but not on W32CE) run AllowSetForegroundWindow for
the child. Note that due to unknown problems this actually the child. Note that due to unknown problems this actually
allows SetForegroundWindow for all childs of this process. allows SetForegroundWindow for all childs of this process.
@ -101,7 +101,7 @@ gnupg_spawn_process (const char *pgmname, const char *argv[],
included there. Calling gnupg_wait_process and included there. Calling gnupg_wait_process and
gnupg_release_process is required. Returns 0 on success or an gnupg_release_process is required. Returns 0 on success or an
error code. */ error code. */
gpg_error_t gnupg_spawn_process_fd (const char *pgmname, gpg_error_t gnupg_spawn_process_fd (const char *pgmname,
const char *argv[], const char *argv[],
int infd, int outfd, int errfd, int infd, int outfd, int errfd,
pid_t *pid); pid_t *pid);
@ -120,11 +120,11 @@ gpg_error_t gnupg_spawn_process_fd (const char *pgmname,
is then stored at R_EXITCODE. An exit code of -1 indicates is then stored at R_EXITCODE. An exit code of -1 indicates
that the process terminated abnormally (e.g. due to a signal). that the process terminated abnormally (e.g. due to a signal).
GPG_ERR_TIMEOUT GPG_ERR_TIMEOUT
The process is still running (returned only if HANG is false). The process is still running (returned only if HANG is false).
GPG_ERR_INV_VALUE GPG_ERR_INV_VALUE
An invalid PID has been specified. An invalid PID has been specified.
Other error codes may be returned as well. Unless otherwise noted, Other error codes may be returned as well. Unless otherwise noted,
-1 will be stored at R_EXITCODE. R_EXITCODE may be passed as NULL -1 will be stored at R_EXITCODE. R_EXITCODE may be passed as NULL

View File

@ -26,7 +26,7 @@ topheader == 0 && /^\/\*/ { topheader = 1 }
topheader == 1 { print $0 } topheader == 1 { print $0 }
topheader == 1 && /\*\// { topheader = 2; print "" } topheader == 1 && /\*\// { topheader = 2; print "" }
/^[ \t]+STATUS_[A-Za-z_]+/ { /^[ \t]+STATUS_[A-Za-z_]+/ {
sub (/[,\/\*]+/, "", $1); sub (/[,\/\*]+/, "", $1);
desc = substr($1,8); desc = substr($1,8);
printf "%d\t%s\t%s\n", code, $1, desc; printf "%d\t%s\t%s\n", code, $1, desc;
@ -37,4 +37,3 @@ topheader == 1 && /\*\// { topheader = 2; print "" }
END { END {
print "# end of status codes." print "# end of status codes."
} }

View File

@ -4,7 +4,7 @@
* This file is free software; as a special exception the author gives * This file is free software; as a special exception the author gives
* unlimited permission to copy and/or distribute it, with or without * unlimited permission to copy and/or distribute it, with or without
* modifications, as long as this notice is preserved. * modifications, as long as this notice is preserved.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY, to the extent permitted by law; without even * WITHOUT ANY WARRANTY, to the extent permitted by law; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

View File

@ -79,7 +79,7 @@ start_agent (void)
pth. We will need a context for each thread or serialize the pth. We will need a context for each thread or serialize the
access to the agent. */ access to the agent. */
if (agent_ctx) if (agent_ctx)
return 0; return 0;
err = start_new_gpg_agent (&agent_ctx, err = start_new_gpg_agent (&agent_ctx,
agentargs.errsource, agentargs.errsource,
@ -129,7 +129,7 @@ membuf_data_cb (void *opaque, const void *buffer, size_t length)
put_membuf (data, buffer, length); put_membuf (data, buffer, length);
return 0; return 0;
} }
/* Ask for a passphrase via gpg-agent. On success the caller needs to /* Ask for a passphrase via gpg-agent. On success the caller needs to
free the string stored at R_PASSPHRASE. On error NULL will be free the string stored at R_PASSPHRASE. On error NULL will be
@ -158,8 +158,8 @@ gnupg_get_passphrase (const char *cache_id,
gpg_error_t err; gpg_error_t err;
char line[ASSUAN_LINELENGTH]; char line[ASSUAN_LINELENGTH];
const char *arg1 = NULL; const char *arg1 = NULL;
char *arg2 = NULL; char *arg2 = NULL;
char *arg3 = NULL; char *arg3 = NULL;
char *arg4 = NULL; char *arg4 = NULL;
membuf_t data; membuf_t data;
@ -170,7 +170,7 @@ gnupg_get_passphrase (const char *cache_id,
return err; return err;
/* Check that the gpg-agent understands the repeat option. */ /* Check that the gpg-agent understands the repeat option. */
if (assuan_transact (agent_ctx, if (assuan_transact (agent_ctx,
"GETINFO cmd_has_option GET_PASSPHRASE repeat", "GETINFO cmd_has_option GET_PASSPHRASE repeat",
NULL, NULL, NULL, NULL, NULL, NULL)) NULL, NULL, NULL, NULL, NULL, NULL))
return gpg_error (GPG_ERR_NOT_SUPPORTED); return gpg_error (GPG_ERR_NOT_SUPPORTED);
@ -186,10 +186,10 @@ gnupg_get_passphrase (const char *cache_id,
if (!(arg4 = percent_plus_escape (desc_msg))) if (!(arg4 = percent_plus_escape (desc_msg)))
goto no_mem; goto no_mem;
snprintf (line, DIM(line)-1, snprintf (line, DIM(line)-1,
"GET_PASSPHRASE --data %s--repeat=%d -- %s %s %s %s", "GET_PASSPHRASE --data %s--repeat=%d -- %s %s %s %s",
check_quality? "--check ":"", check_quality? "--check ":"",
repeat, repeat,
arg1? arg1:"X", arg1? arg1:"X",
arg2? arg2:"X", arg2? arg2:"X",
arg3? arg3:"X", arg3? arg3:"X",
@ -203,10 +203,10 @@ gnupg_get_passphrase (const char *cache_id,
init_membuf_secure (&data, 64); init_membuf_secure (&data, 64);
else else
init_membuf (&data, 64); init_membuf (&data, 64);
err = assuan_transact (agent_ctx, line, err = assuan_transact (agent_ctx, line,
membuf_data_cb, &data, membuf_data_cb, &data,
default_inq_cb, NULL, NULL, NULL); default_inq_cb, NULL, NULL, NULL);
/* Older Pinentries return the old assuan error code for canceled /* Older Pinentries return the old assuan error code for canceled
which gets translated bt libassuan to GPG_ERR_ASS_CANCELED and which gets translated bt libassuan to GPG_ERR_ASS_CANCELED and
not to the code for a user cancel. Fix this here. */ not to the code for a user cancel. Fix this here. */
@ -224,7 +224,7 @@ gnupg_get_passphrase (const char *cache_id,
wipememory (p, n); wipememory (p, n);
xfree (p); xfree (p);
} }
else else
{ {
put_membuf (&data, "", 1); put_membuf (&data, "", 1);
*r_passphrase = get_membuf (&data, NULL); *r_passphrase = get_membuf (&data, NULL);

View File

@ -31,7 +31,7 @@
#ifdef HAVE_UNSIGNED_TIME_T #ifdef HAVE_UNSIGNED_TIME_T
# define IS_INVALID_TIME_T(a) ((a) == (time_t)(-1)) # define IS_INVALID_TIME_T(a) ((a) == (time_t)(-1))
#else #else
/* Error or 32 bit time_t and value after 2038-01-19. */ /* Error or 32 bit time_t and value after 2038-01-19. */
# define IS_INVALID_TIME_T(a) ((a) < 0) # define IS_INVALID_TIME_T(a) ((a) < 0)
#endif #endif
@ -46,8 +46,8 @@ static enum { NORMAL = 0, FROZEN, FUTURE, PAST } timemode;
/* Wrapper for the time(3). We use this here so we can fake the time /* Wrapper for the time(3). We use this here so we can fake the time
for tests */ for tests */
time_t time_t
gnupg_get_time () gnupg_get_time ()
{ {
time_t current = time (NULL); time_t current = time (NULL);
if (timemode == NORMAL) if (timemode == NORMAL)
@ -66,15 +66,15 @@ void
gnupg_get_isotime (gnupg_isotime_t timebuf) gnupg_get_isotime (gnupg_isotime_t timebuf)
{ {
time_t atime = gnupg_get_time (); time_t atime = gnupg_get_time ();
if (atime == (time_t)(-1)) if (atime == (time_t)(-1))
*timebuf = 0; *timebuf = 0;
else else
{ {
struct tm *tp; struct tm *tp;
#ifdef HAVE_GMTIME_R #ifdef HAVE_GMTIME_R
struct tm tmbuf; struct tm tmbuf;
tp = gmtime_r (&atime, &tmbuf); tp = gmtime_r (&atime, &tmbuf);
#else #else
tp = gmtime (&atime); tp = gmtime (&atime);
@ -128,7 +128,7 @@ gnupg_faked_time_p (void)
/* This function is used by gpg because OpenPGP defines the timestamp /* This function is used by gpg because OpenPGP defines the timestamp
as an unsigned 32 bit value. */ as an unsigned 32 bit value. */
u32 u32
make_timestamp (void) make_timestamp (void)
{ {
time_t t = gnupg_get_time (); time_t t = gnupg_get_time ();
@ -233,12 +233,12 @@ epoch2isotime (gnupg_isotime_t timebuf, time_t atime)
{ {
if (atime == (time_t)(-1)) if (atime == (time_t)(-1))
*timebuf = 0; *timebuf = 0;
else else
{ {
struct tm *tp; struct tm *tp;
#ifdef HAVE_GMTIME_R #ifdef HAVE_GMTIME_R
struct tm tmbuf; struct tm tmbuf;
tp = gmtime_r (&atime, &tmbuf); tp = gmtime_r (&atime, &tmbuf);
#else #else
tp = gmtime (&atime); tp = gmtime (&atime);
@ -296,7 +296,7 @@ strtimestamp (u32 stamp)
static char buffer[11+5]; static char buffer[11+5];
struct tm *tp; struct tm *tp;
time_t atime = stamp; time_t atime = stamp;
if (IS_INVALID_TIME_T (atime)) if (IS_INVALID_TIME_T (atime))
{ {
strcpy (buffer, "????" "-??" "-??"); strcpy (buffer, "????" "-??" "-??");
@ -320,7 +320,7 @@ isotimestamp (u32 stamp)
static char buffer[25+5]; static char buffer[25+5];
struct tm *tp; struct tm *tp;
time_t atime = stamp; time_t atime = stamp;
if (IS_INVALID_TIME_T (atime)) if (IS_INVALID_TIME_T (atime))
{ {
strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??"); strcpy (buffer, "????" "-??" "-??" " " "??" ":" "??" ":" "??");
@ -364,7 +364,7 @@ asctimestamp (u32 stamp)
/* NOTE: gcc -Wformat-noliteral will complain here. I have found no /* NOTE: gcc -Wformat-noliteral will complain here. I have found no
way to suppress this warning. */ way to suppress this warning. */
strftime (buffer, DIM(buffer)-1, fmt, tp); strftime (buffer, DIM(buffer)-1, fmt, tp);
# elif defined(HAVE_W32CE_SYSTEM) # elif defined(HAVE_W32CE_SYSTEM)
/* tzset is not available but %Z nevertheless prints a default /* tzset is not available but %Z nevertheless prints a default
nonsense timezone ("WILDABBR"). Thus we don't print the time nonsense timezone ("WILDABBR"). Thus we don't print the time
zone at all. */ zone at all. */
@ -400,7 +400,7 @@ static int
days_per_month (int y, int m) days_per_month (int y, int m)
{ {
int s; int s;
switch(m) switch(m)
{ {
case 1: case 3: case 5: case 7: case 8: case 10: case 12: case 1: case 3: case 5: case 7: case 8: case 10: case 12:
@ -460,19 +460,19 @@ jd2date (unsigned long jd, int *year, int *month, int *day)
m = (delta / 31) + 1; m = (delta / 31) + 1;
while( (delta = jd - date2jd (y, m, d)) > days_per_month (y,m)) while( (delta = jd - date2jd (y, m, d)) > days_per_month (y,m))
if (++m > 12) if (++m > 12)
{ {
m = 1; m = 1;
y++; y++;
} }
d = delta + 1 ; d = delta + 1 ;
if (d > days_per_month (y, m)) if (d > days_per_month (y, m))
{ {
d = 1; d = 1;
m++; m++;
} }
if (m > 12) if (m > 12)
{ {
m = 1; m = 1;
y++; y++;
} }
@ -499,7 +499,7 @@ check_isotime (const gnupg_isotime_t atime)
if (!*atime) if (!*atime)
return gpg_error (GPG_ERR_NO_VALUE); return gpg_error (GPG_ERR_NO_VALUE);
for (s=atime, i=0; i < 8; i++, s++) for (s=atime, i=0; i < 8; i++, s++)
if (!digitp (s)) if (!digitp (s))
return gpg_error (GPG_ERR_INV_TIME); return gpg_error (GPG_ERR_INV_TIME);
@ -566,7 +566,7 @@ add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds)
sec = atoi_2 (atime+13); sec = atoi_2 (atime+13);
if (year <= 1582) /* The julian date functions don't support this. */ if (year <= 1582) /* The julian date functions don't support this. */
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
sec += nseconds; sec += nseconds;
minute += sec/60; minute += sec/60;
@ -575,14 +575,14 @@ add_seconds_to_isotime (gnupg_isotime_t atime, int nseconds)
minute %= 60; minute %= 60;
ndays = hour/24; ndays = hour/24;
hour %= 24; hour %= 24;
jd = date2jd (year, month, day) + ndays; jd = date2jd (year, month, day) + ndays;
jd2date (jd, &year, &month, &day); jd2date (jd, &year, &month, &day);
if (year > 9999 || month > 12 || day > 31 if (year > 9999 || month > 12 || day > 31
|| year < 0 || month < 1 || day < 1) || year < 0 || month < 1 || day < 1)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
snprintf (atime, 16, "%04d%02d%02dT%02d%02d%02d", snprintf (atime, 16, "%04d%02d%02dT%02d%02d%02d",
year, month, day, hour, minute, sec); year, month, day, hour, minute, sec);
return 0; return 0;
@ -611,15 +611,15 @@ add_days_to_isotime (gnupg_isotime_t atime, int ndays)
sec = atoi_2 (atime+13); sec = atoi_2 (atime+13);
if (year <= 1582) /* The julian date functions don't support this. */ if (year <= 1582) /* The julian date functions don't support this. */
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
jd = date2jd (year, month, day) + ndays; jd = date2jd (year, month, day) + ndays;
jd2date (jd, &year, &month, &day); jd2date (jd, &year, &month, &day);
if (year > 9999 || month > 12 || day > 31 if (year > 9999 || month > 12 || day > 31
|| year < 0 || month < 1 || day < 1) || year < 0 || month < 1 || day < 1)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
snprintf (atime, 16, "%04d%02d%02dT%02d%02d%02d", snprintf (atime, 16, "%04d%02d%02dT%02d%02d%02d",
year, month, day, hour, minute, sec); year, month, day, hour, minute, sec);
return 0; return 0;

View File

@ -85,7 +85,3 @@ gnupg_rl_initialize (void)
rl_readline_name = "GnuPG"; rl_readline_name = "GnuPG";
#endif #endif
} }

View File

@ -52,7 +52,7 @@ findkey_fname (const char *key, const char *fname)
while (fgets (line, DIM(line)-1, fp)) while (fgets (line, DIM(line)-1, fp))
{ {
lnr++; lnr++;
if (!*line || line[strlen(line)-1] != '\n') if (!*line || line[strlen(line)-1] != '\n')
{ {
/* Eat until end of line. */ /* Eat until end of line. */
@ -65,7 +65,7 @@ findkey_fname (const char *key, const char *fname)
} }
else else
line[strlen(line)-1] = 0; /* Chop the LF. */ line[strlen(line)-1] = 0; /* Chop the LF. */
again: again:
if (!in_item) if (!in_item)
{ {
@ -96,7 +96,7 @@ findkey_fname (const char *key, const char *fname)
if (*line == '#') if (*line == '#')
continue; continue;
if (*line == '.') if (*line == '.')
{ {
if (spacep(line+1)) if (spacep(line+1))
p = line + 2; p = line + 2;
else else
@ -126,7 +126,7 @@ findkey_fname (const char *key, const char *fname)
log_error (_("error reading `%s', line %d: %s\n"), log_error (_("error reading `%s', line %d: %s\n"),
fname, lnr, gpg_strerror (err)); fname, lnr, gpg_strerror (err));
} }
fclose (fp); fclose (fp);
if (is_membuf_ready (&mb)) if (is_membuf_ready (&mb))
{ {
@ -182,7 +182,7 @@ findkey_locale (const char *key, const char *locname,
else else
result = NULL; result = NULL;
} }
if (!result && (!only_current_locale || !*locname) ) if (!result && (!only_current_locale || !*locname) )
{ {
/* Last try: Search in file without any locale info. ("help.txt") */ /* Last try: Search in file without any locale info. ("help.txt") */
@ -204,18 +204,18 @@ findkey_locale (const char *key, const char *locname,
/etc/gnupg/help.txt /etc/gnupg/help.txt
/usr/share/gnupg/help.LL.txt /usr/share/gnupg/help.LL.txt
/usr/share/gnupg/help.txt /usr/share/gnupg/help.txt
Here LL denotes the two digit language code of the current locale. Here LL denotes the two digit language code of the current locale.
If ONLY_CURRENT_LOCALE is set, the fucntion won;t fallback to the If ONLY_CURRENT_LOCALE is set, the fucntion won;t fallback to the
english valiant ("help.txt") unless that locale has been requested. english valiant ("help.txt") unless that locale has been requested.
The help file needs to be encoded in UTF-8, lines with a '#' in the The help file needs to be encoded in UTF-8, lines with a '#' in the
first column are comment lines and entirely ignored. Help keys are first column are comment lines and entirely ignored. Help keys are
identified by a key consisting of a single word with a single dot identified by a key consisting of a single word with a single dot
as the first character. All key lines listed without any as the first character. All key lines listed without any
intervening lines (except for comment lines) lead to the same help intervening lines (except for comment lines) lead to the same help
text. Lines following the key lines make up the actual hep texts. text. Lines following the key lines make up the actual hep texts.
*/ */
char * char *
@ -249,7 +249,7 @@ gnupg_get_help_string (const char *key, int only_current_locale)
if (!key || !*key) if (!key || !*key)
return NULL; return NULL;
result = findkey_locale (key, locname, only_current_locale, result = findkey_locale (key, locname, only_current_locale,
gnupg_sysconfdir ()); gnupg_sysconfdir ());
if (!result) if (!result)
result = findkey_locale (key, locname, only_current_locale, result = findkey_locale (key, locname, only_current_locale,

View File

@ -55,7 +55,7 @@ w32_try_mkdir (const char *dir)
CreateDirectory (wdir, NULL); CreateDirectory (wdir, NULL);
xfree (wdir); xfree (wdir);
} }
#else #else
CreateDirectory (dir, NULL); CreateDirectory (dir, NULL);
#endif #endif
} }
@ -115,7 +115,7 @@ standard_homedir (void)
if (!dir) if (!dir)
{ {
char path[MAX_PATH]; char path[MAX_PATH];
/* It might be better to use LOCAL_APPDATA because this is /* It might be better to use LOCAL_APPDATA because this is
defined as "non roaming" and thus more likely to be kept defined as "non roaming" and thus more likely to be kept
locally. For private keys this is desired. However, given locally. For private keys this is desired. However, given
@ -123,13 +123,13 @@ standard_homedir (void)
using a system roaming services might be better than to let using a system roaming services might be better than to let
them do it manually. A security conscious user will anyway them do it manually. A security conscious user will anyway
use the registry entry to have better control. */ use the registry entry to have better control. */
if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
NULL, 0, path) >= 0) NULL, 0, path) >= 0)
{ {
char *tmp = xmalloc (strlen (path) + 6 +1); char *tmp = xmalloc (strlen (path) + 6 +1);
strcpy (stpcpy (tmp, path), "\\gnupg"); strcpy (stpcpy (tmp, path), "\\gnupg");
dir = tmp; dir = tmp;
/* Try to create the directory if it does not yet exists. */ /* Try to create the directory if it does not yet exists. */
if (access (dir, F_OK)) if (access (dir, F_OK))
w32_try_mkdir (dir); w32_try_mkdir (dir);
@ -155,7 +155,7 @@ default_homedir (void)
if (!dir || !*dir) if (!dir || !*dir)
{ {
static const char *saved_dir; static const char *saved_dir;
if (!saved_dir) if (!saved_dir)
{ {
if (!dir || !*dir) if (!dir || !*dir)
@ -172,7 +172,7 @@ default_homedir (void)
if (tmp) if (tmp)
saved_dir = tmp; saved_dir = tmp;
} }
if (!saved_dir) if (!saved_dir)
saved_dir = standard_homedir (); saved_dir = standard_homedir ();
} }
@ -228,7 +228,7 @@ w32_rootdir (void)
if (!p) if (!p)
{ {
log_debug ("bad filename `%s' returned for this process\n", dir); log_debug ("bad filename `%s' returned for this process\n", dir);
*dir = 0; *dir = 0;
} }
} }
@ -247,8 +247,8 @@ w32_commondir (void)
{ {
char path[MAX_PATH]; char path[MAX_PATH];
if (w32_shgetfolderpath (NULL, CSIDL_COMMON_APPDATA, if (w32_shgetfolderpath (NULL, CSIDL_COMMON_APPDATA,
NULL, 0, path) >= 0) NULL, 0, path) >= 0)
{ {
char *tmp = xmalloc (strlen (path) + 4 +1); char *tmp = xmalloc (strlen (path) + 4 +1);
strcpy (stpcpy (tmp, path), "\\GNU"); strcpy (stpcpy (tmp, path), "\\GNU");
@ -263,7 +263,7 @@ w32_commondir (void)
dir = xstrdup (w32_rootdir ()); dir = xstrdup (w32_rootdir ());
} }
} }
return dir; return dir;
} }
#endif /*HAVE_W32_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/
@ -389,8 +389,8 @@ gnupg_cachedir (void)
for (comp = s1; *comp; comp++) for (comp = s1; *comp; comp++)
s1_len += 1 + strlen (*comp); s1_len += 1 + strlen (*comp);
if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, if (w32_shgetfolderpath (NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE,
NULL, 0, path) >= 0) NULL, 0, path) >= 0)
{ {
char *tmp = xmalloc (strlen (path) + s1_len + 1); char *tmp = xmalloc (strlen (path) + s1_len + 1);
char *p; char *p;
@ -475,49 +475,49 @@ gnupg_module_name (int which)
if (!name) \ if (!name) \
name = xstrconcat (gnupg_ ## a (), DIRSEP_S b EXEEXT_S, NULL); \ name = xstrconcat (gnupg_ ## a (), DIRSEP_S b EXEEXT_S, NULL); \
return name; \ return name; \
} while (0) } while (0)
switch (which) switch (which)
{ {
case GNUPG_MODULE_NAME_AGENT: case GNUPG_MODULE_NAME_AGENT:
#ifdef GNUPG_DEFAULT_AGENT #ifdef GNUPG_DEFAULT_AGENT
return GNUPG_DEFAULT_AGENT; return GNUPG_DEFAULT_AGENT;
#else #else
X(bindir, "gpg-agent"); X(bindir, "gpg-agent");
#endif #endif
case GNUPG_MODULE_NAME_PINENTRY: case GNUPG_MODULE_NAME_PINENTRY:
#ifdef GNUPG_DEFAULT_PINENTRY #ifdef GNUPG_DEFAULT_PINENTRY
return GNUPG_DEFAULT_PINENTRY; return GNUPG_DEFAULT_PINENTRY;
#else #else
X(bindir, "pinentry"); X(bindir, "pinentry");
#endif #endif
case GNUPG_MODULE_NAME_SCDAEMON: case GNUPG_MODULE_NAME_SCDAEMON:
#ifdef GNUPG_DEFAULT_SCDAEMON #ifdef GNUPG_DEFAULT_SCDAEMON
return GNUPG_DEFAULT_SCDAEMON; return GNUPG_DEFAULT_SCDAEMON;
#else #else
X(bindir, "scdaemon"); X(bindir, "scdaemon");
#endif #endif
case GNUPG_MODULE_NAME_DIRMNGR: case GNUPG_MODULE_NAME_DIRMNGR:
#ifdef GNUPG_DEFAULT_DIRMNGR #ifdef GNUPG_DEFAULT_DIRMNGR
return GNUPG_DEFAULT_DIRMNGR; return GNUPG_DEFAULT_DIRMNGR;
#else #else
X(bindir, "dirmngr"); X(bindir, "dirmngr");
#endif #endif
case GNUPG_MODULE_NAME_PROTECT_TOOL: case GNUPG_MODULE_NAME_PROTECT_TOOL:
#ifdef GNUPG_DEFAULT_PROTECT_TOOL #ifdef GNUPG_DEFAULT_PROTECT_TOOL
return GNUPG_DEFAULT_PROTECT_TOOL; return GNUPG_DEFAULT_PROTECT_TOOL;
#else #else
X(libexecdir, "gpg-protect-tool"); X(libexecdir, "gpg-protect-tool");
#endif #endif
case GNUPG_MODULE_NAME_DIRMNGR_LDAP: case GNUPG_MODULE_NAME_DIRMNGR_LDAP:
#ifdef GNUPG_DEFAULT_DIRMNGR_LDAP #ifdef GNUPG_DEFAULT_DIRMNGR_LDAP
return GNUPG_DEFAULT_DIRMNGR_LDAP; return GNUPG_DEFAULT_DIRMNGR_LDAP;
#else #else
X(libexecdir, "dirmngr_ldap"); X(libexecdir, "dirmngr_ldap");
#endif #endif
@ -536,7 +536,7 @@ gnupg_module_name (int which)
case GNUPG_MODULE_NAME_GPGCONF: case GNUPG_MODULE_NAME_GPGCONF:
X(bindir, "gpgconf"); X(bindir, "gpgconf");
default: default:
BUG (); BUG ();
} }
#undef X #undef X

View File

@ -176,21 +176,21 @@ static es_cookie_io_functions_t cookie_functions =
cookie_close cookie_close
}; };
struct cookie_s struct cookie_s
{ {
/* File descriptor or -1 if already closed. */ /* File descriptor or -1 if already closed. */
int fd; int fd;
/* TLS session context or NULL if not used. */ /* TLS session context or NULL if not used. */
gnutls_session_t tls_session; gnutls_session_t tls_session;
/* The remaining content length and a flag telling whether to use /* The remaining content length and a flag telling whether to use
the content length. */ the content length. */
longcounter_t content_length; longcounter_t content_length;
unsigned int content_length_valid:1; unsigned int content_length_valid:1;
/* Flag to communicate with the close handler. */ /* Flag to communicate with the close handler. */
unsigned int keep_socket:1; unsigned int keep_socket:1;
}; };
typedef struct cookie_s *cookie_t; typedef struct cookie_s *cookie_t;
@ -210,7 +210,7 @@ typedef struct header_s *header_t;
/* Our handle context. */ /* Our handle context. */
struct http_context_s struct http_context_s
{ {
unsigned int status_code; unsigned int status_code;
int sock; int sock;
@ -258,14 +258,14 @@ init_sockets (void)
if (initialized) if (initialized)
return; return;
if ( WSAStartup( MAKEWORD (REQ_WINSOCK_MINOR, REQ_WINSOCK_MAJOR), &wsdata ) ) if ( WSAStartup( MAKEWORD (REQ_WINSOCK_MINOR, REQ_WINSOCK_MAJOR), &wsdata ) )
{ {
log_error ("error initializing socket library: ec=%d\n", log_error ("error initializing socket library: ec=%d\n",
(int)WSAGetLastError () ); (int)WSAGetLastError () );
return; return;
} }
if ( LOBYTE(wsdata.wVersion) != REQ_WINSOCK_MAJOR if ( LOBYTE(wsdata.wVersion) != REQ_WINSOCK_MAJOR
|| HIBYTE(wsdata.wVersion) != REQ_WINSOCK_MINOR ) || HIBYTE(wsdata.wVersion) != REQ_WINSOCK_MINOR )
{ {
log_error ("socket library version is %x.%x - but %d.%d needed\n", log_error ("socket library version is %x.%x - but %d.%d needed\n",
LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion), LOBYTE(wsdata.wVersion), HIBYTE(wsdata.wVersion),
@ -290,7 +290,7 @@ static char *
make_header_line (const char *prefix, const char *suffix, make_header_line (const char *prefix, const char *suffix,
const void *data, size_t len ) const void *data, size_t len )
{ {
static unsigned char bintoasc[] = static unsigned char bintoasc[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz" "abcdefghijklmnopqrstuvwxyz"
"0123456789+/"; "0123456789+/";
@ -308,7 +308,7 @@ make_header_line (const char *prefix, const char *suffix,
*p++ = bintoasc[(((s[1]<<2)&074)|((s[2]>>6)&03))&077]; *p++ = bintoasc[(((s[1]<<2)&074)|((s[2]>>6)&03))&077];
*p++ = bintoasc[s[2]&077]; *p++ = bintoasc[s[2]&077];
} }
if ( len == 2 ) if ( len == 2 )
{ {
*p++ = bintoasc[(s[0] >> 2) & 077]; *p++ = bintoasc[(s[0] >> 2) & 077];
*p++ = bintoasc[(((s[0] <<4)&060)|((s[1] >> 4)&017))&077]; *p++ = bintoasc[(((s[0] <<4)&060)|((s[1] >> 4)&017))&077];
@ -336,7 +336,7 @@ http_register_tls_callback ( gpg_error_t (*cb) (http_t, void *, int) )
tls_callback = (gpg_error_t (*) (http_t, gnutls_session_t, int))cb; tls_callback = (gpg_error_t (*) (http_t, gnutls_session_t, int))cb;
#else #else
(void)cb; (void)cb;
#endif #endif
} }
@ -345,14 +345,14 @@ http_register_tls_callback ( gpg_error_t (*cb) (http_t, void *, int) )
pointer for completing the the request and to wait for the pointer for completing the the request and to wait for the
response. */ response. */
gpg_error_t gpg_error_t
_http_open (http_t *r_hd, http_req_t reqtype, const char *url, _http_open (http_t *r_hd, http_req_t reqtype, const char *url,
const char *auth, unsigned int flags, const char *proxy, const char *auth, unsigned int flags, const char *proxy,
void *tls_context, const char *srvtag, strlist_t headers, void *tls_context, const char *srvtag, strlist_t headers,
gpg_err_source_t errsource) gpg_err_source_t errsource)
{ {
gpg_error_t err; gpg_error_t err;
http_t hd; http_t hd;
*r_hd = NULL; *r_hd = NULL;
if (!(reqtype == HTTP_REQ_GET || reqtype == HTTP_REQ_POST)) if (!(reqtype == HTTP_REQ_GET || reqtype == HTTP_REQ_POST))
@ -370,7 +370,7 @@ _http_open (http_t *r_hd, http_req_t reqtype, const char *url,
err = _http_parse_uri (&hd->uri, url, 0, errsource); err = _http_parse_uri (&hd->uri, url, 0, errsource);
if (!err) if (!err)
err = send_request (hd, auth, proxy, srvtag, headers, errsource); err = send_request (hd, auth, proxy, srvtag, headers, errsource);
if (err) if (err)
{ {
if (!hd->fp_read && !hd->fp_write && hd->sock != -1) if (!hd->fp_read && !hd->fp_write && hd->sock != -1)
@ -408,7 +408,7 @@ _http_wait_response (http_t hd, gpg_err_source_t errsource)
cookie_t cookie; cookie_t cookie;
/* Make sure that we are in the data. */ /* Make sure that we are in the data. */
http_start_data (hd); http_start_data (hd);
/* Close the write stream but keep the socket open. */ /* Close the write stream but keep the socket open. */
cookie = hd->write_cookie; cookie = hd->write_cookie;
@ -455,7 +455,7 @@ _http_wait_response (http_t hd, gpg_err_source_t errsource)
be used as an HTTP proxy and any enabled $http_proxy gets be used as an HTTP proxy and any enabled $http_proxy gets
ignored. */ ignored. */
gpg_error_t gpg_error_t
_http_open_document (http_t *r_hd, const char *document, _http_open_document (http_t *r_hd, const char *document,
const char *auth, unsigned int flags, const char *proxy, const char *auth, unsigned int flags, const char *proxy,
void *tls_context, const char *srvtag, strlist_t headers, void *tls_context, const char *srvtag, strlist_t headers,
gpg_err_source_t errsource) gpg_err_source_t errsource)
@ -620,7 +620,7 @@ do_parse_uri (parsed_uri_t uri, int only_local_part, int no_scheme_check)
p++; p++;
if (*p == '/') /* There seems to be a hostname. */ if (*p == '/') /* There seems to be a hostname. */
{ {
p++; p++;
if ((p2 = strchr (p, '/'))) if ((p2 = strchr (p, '/')))
*p2++ = 0; *p2++ = 0;
@ -678,7 +678,7 @@ do_parse_uri (parsed_uri_t uri, int only_local_part, int no_scheme_check)
return GPG_ERR_BAD_URI; /* Path includes a Nul. */ return GPG_ERR_BAD_URI; /* Path includes a Nul. */
p = p2 ? p2 : NULL; p = p2 ? p2 : NULL;
if (!p || !*p) if (!p || !*p)
return 0; /* We don't have a query string. Okay. */ return 0; /* We don't have a query string. Okay. */
/* Now parse the query string. */ /* Now parse the query string. */
@ -902,7 +902,7 @@ send_request (http_t hd, const char *auth,
if ( (proxy && *proxy) if ( (proxy && *proxy)
|| ( (hd->flags & HTTP_FLAG_TRY_PROXY) || ( (hd->flags & HTTP_FLAG_TRY_PROXY)
&& (http_proxy = getenv (HTTP_PROXY_ENV)) && (http_proxy = getenv (HTTP_PROXY_ENV))
&& *http_proxy )) && *http_proxy ))
{ {
parsed_uri_t uri; parsed_uri_t uri;
@ -947,7 +947,7 @@ send_request (http_t hd, const char *auth,
if (hd->sock == -1) if (hd->sock == -1)
{ {
xfree (proxy_authstr); xfree (proxy_authstr);
return gpg_err_make (errsource, (save_errno return gpg_err_make (errsource, (save_errno
? gpg_err_code_from_errno (save_errno) ? gpg_err_code_from_errno (save_errno)
: GPG_ERR_NOT_FOUND)); : GPG_ERR_NOT_FOUND));
} }
@ -987,7 +987,7 @@ send_request (http_t hd, const char *auth,
if (auth || hd->uri->auth) if (auth || hd->uri->auth)
{ {
char *myauth; char *myauth;
if (auth) if (auth)
{ {
myauth = xtrystrdup (auth); myauth = xtrystrdup (auth);
@ -1015,14 +1015,14 @@ send_request (http_t hd, const char *auth,
return gpg_err_make (errsource, gpg_err_code_from_syserror ()); return gpg_err_make (errsource, gpg_err_code_from_syserror ());
} }
} }
p = build_rel_path (hd->uri); p = build_rel_path (hd->uri);
if (!p) if (!p)
return gpg_err_make (errsource, gpg_err_code_from_syserror ()); return gpg_err_make (errsource, gpg_err_code_from_syserror ());
if (http_proxy && *http_proxy) if (http_proxy && *http_proxy)
{ {
request = es_asprintf request = es_asprintf
("%s http://%s:%hu%s%s HTTP/1.0\r\n%s%s", ("%s http://%s:%hu%s%s HTTP/1.0\r\n%s%s",
hd->req_type == HTTP_REQ_GET ? "GET" : hd->req_type == HTTP_REQ_GET ? "GET" :
hd->req_type == HTTP_REQ_HEAD ? "HEAD" : hd->req_type == HTTP_REQ_HEAD ? "HEAD" :
@ -1034,13 +1034,13 @@ send_request (http_t hd, const char *auth,
else else
{ {
char portstr[35]; char portstr[35];
if (port == 80) if (port == 80)
*portstr = 0; *portstr = 0;
else else
snprintf (portstr, sizeof portstr, ":%u", port); snprintf (portstr, sizeof portstr, ":%u", port);
request = es_asprintf request = es_asprintf
("%s %s%s HTTP/1.0\r\nHost: %s%s\r\n%s", ("%s %s%s HTTP/1.0\r\nHost: %s%s\r\n%s",
hd->req_type == HTTP_REQ_GET ? "GET" : hd->req_type == HTTP_REQ_GET ? "GET" :
hd->req_type == HTTP_REQ_HEAD ? "HEAD" : hd->req_type == HTTP_REQ_HEAD ? "HEAD" :
@ -1099,7 +1099,7 @@ send_request (http_t hd, const char *auth,
} }
} }
} }
leave: leave:
es_free (request); es_free (request);
xfree (authstr); xfree (authstr);
@ -1228,7 +1228,7 @@ store_header (http_t hd, char *line)
while (*p == ' ' || *p == '\t') while (*p == ' ' || *p == '\t')
p++; p++;
value = p; value = p;
for (h=hd->headers; h; h = h->next) for (h=hd->headers; h; h = h->next)
if ( !strcmp (h->name, line) ) if ( !strcmp (h->name, line) )
break; break;
@ -1494,9 +1494,9 @@ connect_server (const char *server, unsigned short port,
if ( inaddr != INADDR_NONE ) if ( inaddr != INADDR_NONE )
{ {
struct sockaddr_in addr; struct sockaddr_in addr;
memset(&addr,0,sizeof(addr)); memset(&addr,0,sizeof(addr));
sock = socket(AF_INET,SOCK_STREAM,0); sock = socket(AF_INET,SOCK_STREAM,0);
if ( sock==INVALID_SOCKET ) if ( sock==INVALID_SOCKET )
{ {
@ -1504,9 +1504,9 @@ connect_server (const char *server, unsigned short port,
return -1; return -1;
} }
addr.sin_family = AF_INET; addr.sin_family = AF_INET;
addr.sin_port = htons(port); addr.sin_port = htons(port);
memcpy (&addr.sin_addr,&inaddr,sizeof(inaddr)); memcpy (&addr.sin_addr,&inaddr,sizeof(inaddr));
if (!my_connect (sock,(struct sockaddr *)&addr,sizeof(addr)) ) if (!my_connect (sock,(struct sockaddr *)&addr,sizeof(addr)) )
return sock; return sock;
@ -1575,7 +1575,7 @@ connect_server (const char *server, unsigned short port,
errno = save_errno; errno = save_errno;
return -1; return -1;
} }
if (my_connect (sock, ai->ai_addr, ai->ai_addrlen)) if (my_connect (sock, ai->ai_addr, ai->ai_addrlen))
last_errno = errno; last_errno = errno;
else else
@ -1608,7 +1608,7 @@ connect_server (const char *server, unsigned short port,
xfree (serverlist); xfree (serverlist);
return -1; return -1;
} }
addr.sin_family = host->h_addrtype; addr.sin_family = host->h_addrtype;
if (addr.sin_family != AF_INET) if (addr.sin_family != AF_INET)
{ {
@ -1675,7 +1675,7 @@ write_server (int sock, const char *data, size_t length)
{ {
#if defined(HAVE_W32_SYSTEM) && !defined(HAVE_PTH) #if defined(HAVE_W32_SYSTEM) && !defined(HAVE_PTH)
nwritten = send (sock, data, nleft, 0); nwritten = send (sock, data, nleft, 0);
if ( nwritten == SOCKET_ERROR ) if ( nwritten == SOCKET_ERROR )
{ {
log_info ("network write failed: ec=%d\n", (int)WSAGetLastError ()); log_info ("network write failed: ec=%d\n", (int)WSAGetLastError ());
return gpg_error (GPG_ERR_NETWORK); return gpg_error (GPG_ERR_NETWORK);
@ -1739,7 +1739,7 @@ cookie_read (void *cookie, void *buffer, size_t size)
if (nread == GNUTLS_E_AGAIN) if (nread == GNUTLS_E_AGAIN)
{ {
struct timeval tv; struct timeval tv;
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 50000; tv.tv_usec = 50000;
my_select (0, NULL, NULL, NULL, &tv); my_select (0, NULL, NULL, NULL, &tv);
@ -1762,7 +1762,7 @@ cookie_read (void *cookie, void *buffer, size_t size)
#elif defined(HAVE_W32_SYSTEM) #elif defined(HAVE_W32_SYSTEM)
/* Under Windows we need to use recv for a socket. */ /* Under Windows we need to use recv for a socket. */
nread = recv (c->fd, buffer, size, 0); nread = recv (c->fd, buffer, size, 0);
#else #else
nread = read (c->fd, buffer, size); nread = read (c->fd, buffer, size);
#endif #endif
} }
@ -1774,7 +1774,7 @@ cookie_read (void *cookie, void *buffer, size_t size)
if (nread < c->content_length) if (nread < c->content_length)
c->content_length -= nread; c->content_length -= nread;
else else
c->content_length = 0; c->content_length = 0;
} }
return nread; return nread;
@ -1793,7 +1793,7 @@ cookie_write (void *cookie, const void *buffer, size_t size)
int nleft = size; int nleft = size;
while (nleft > 0) while (nleft > 0)
{ {
nwritten = gnutls_record_send (c->tls_session, buffer, nleft); nwritten = gnutls_record_send (c->tls_session, buffer, nleft);
if (nwritten <= 0) if (nwritten <= 0)
{ {
if (nwritten == GNUTLS_E_INTERRUPTED) if (nwritten == GNUTLS_E_INTERRUPTED)
@ -1801,7 +1801,7 @@ cookie_write (void *cookie, const void *buffer, size_t size)
if (nwritten == GNUTLS_E_AGAIN) if (nwritten == GNUTLS_E_AGAIN)
{ {
struct timeval tv; struct timeval tv;
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 50000; tv.tv_usec = 50000;
my_select (0, NULL, NULL, NULL, &tv); my_select (0, NULL, NULL, NULL, &tv);

View File

@ -1,7 +1,7 @@
/* http.h - HTTP protocol handler /* http.h - HTTP protocol handler
* Copyright (C) 1999, 2000, 2001, 2003, 2006, * Copyright (C) 1999, 2000, 2001, 2003, 2006,
* 2010 Free Software Foundation, Inc. * 2010 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
* GnuPG is free software; you can redistribute it and/or modify * GnuPG is free software; you can redistribute it and/or modify
@ -18,12 +18,12 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef GNUPG_COMMON_HTTP_H #ifndef GNUPG_COMMON_HTTP_H
#define GNUPG_COMMON_HTTP_H #define GNUPG_COMMON_HTTP_H
#include <gpg-error.h> #include <gpg-error.h>
#include "../common/estream.h" #include "../common/estream.h"
struct uri_tuple_s struct uri_tuple_s
{ {
struct uri_tuple_s *next; struct uri_tuple_s *next;
const char *name; /* A pointer into name. */ const char *name; /* A pointer into name. */
@ -34,7 +34,7 @@ struct uri_tuple_s
}; };
typedef struct uri_tuple_s *uri_tuple_t; typedef struct uri_tuple_s *uri_tuple_t;
struct parsed_uri_s struct parsed_uri_s
{ {
/* All these pointers point into BUFFER; most stuff is not escaped. */ /* All these pointers point into BUFFER; most stuff is not escaped. */
char *scheme; /* Pointer to the scheme string (always lowercase). */ char *scheme; /* Pointer to the scheme string (always lowercase). */
@ -50,17 +50,17 @@ struct parsed_uri_s
}; };
typedef struct parsed_uri_s *parsed_uri_t; typedef struct parsed_uri_s *parsed_uri_t;
typedef enum typedef enum
{ {
HTTP_REQ_GET = 1, HTTP_REQ_GET = 1,
HTTP_REQ_HEAD = 2, HTTP_REQ_HEAD = 2,
HTTP_REQ_POST = 3 HTTP_REQ_POST = 3
} }
http_req_t; http_req_t;
/* We put the flag values into an enum, so that gdb can display them. */ /* We put the flag values into an enum, so that gdb can display them. */
enum enum
{ {
HTTP_FLAG_TRY_PROXY = 1, HTTP_FLAG_TRY_PROXY = 1,
HTTP_FLAG_SHUTDOWN = 2, HTTP_FLAG_SHUTDOWN = 2,
HTTP_FLAG_LOG_RESP = 8, HTTP_FLAG_LOG_RESP = 8,

View File

@ -69,7 +69,7 @@ i18n_switchto_utf8 (void)
if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8")) if (!bind_textdomain_codeset (PACKAGE_GT, "utf-8"))
{ {
xfree (orig_codeset); xfree (orig_codeset);
orig_codeset = NULL; orig_codeset = NULL;
} }
} }
return orig_codeset; return orig_codeset;

View File

@ -4,7 +4,7 @@
* This file is free software; as a special exception the author gives * This file is free software; as a special exception the author gives
* unlimited permission to copy and/or distribute it, with or without * unlimited permission to copy and/or distribute it, with or without
* modifications, as long as this notice is preserved. * modifications, as long as this notice is preserved.
* *
* This file is distributed in the hope that it will be useful, but * This file is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY, to the extent permitted by law; without even * WITHOUT ANY WARRANTY, to the extent permitted by law; without even
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
@ -21,7 +21,7 @@
# define N_(a) (a) # define N_(a) (a)
#else #else
# ifdef HAVE_LOCALE_H # ifdef HAVE_LOCALE_H
# include <locale.h> # include <locale.h>
# endif # endif
# ifdef ENABLE_NLS # ifdef ENABLE_NLS
# include <libintl.h> # include <libintl.h>

View File

@ -27,7 +27,7 @@
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
#include <windows.h> #include <windows.h>
#endif #endif
#ifdef HAVE_PTH #ifdef HAVE_PTH
#include <pth.h> #include <pth.h>
#endif #endif
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
@ -79,7 +79,7 @@ void
init_common_subsystems (int *argcp, char ***argvp) init_common_subsystems (int *argcp, char ***argvp)
{ {
/* Try to auto set the character set. */ /* Try to auto set the character set. */
set_native_charset (NULL); set_native_charset (NULL);
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
/* For W32 we need to initialize the socket layer. This is because /* For W32 we need to initialize the socket layer. This is because
@ -92,12 +92,12 @@ init_common_subsystems (int *argcp, char ***argvp)
# else # else
{ {
WSADATA wsadat; WSADATA wsadat;
WSAStartup (0x202, &wsadat); WSAStartup (0x202, &wsadat);
} }
# endif /*!HAVE_PTH*/ # endif /*!HAVE_PTH*/
#endif #endif
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
/* Register the sleep exit function before the estream init so that /* Register the sleep exit function before the estream init so that
the sleep will be called after the estream registered atexit the sleep will be called after the estream registered atexit
@ -173,7 +173,7 @@ parse_std_file_handles (int *argcp, char ***argvp)
s = *argv; s = *argv;
if (*s == '-' && s[1] == '&' && s[2] == 'S' if (*s == '-' && s[1] == '&' && s[2] == 'S'
&& (s[3] == '0' || s[3] == '1' || s[3] == '2') && (s[3] == '0' || s[3] == '1' || s[3] == '2')
&& s[4] == '=' && s[4] == '='
&& (strchr ("-01234567890", s[5]) || !strcmp (s+5, "null"))) && (strchr ("-01234567890", s[5]) || !strcmp (s+5, "null")))
{ {
if (s[5] == 'n') if (s[5] == 'n')
@ -200,6 +200,6 @@ parse_std_file_handles (int *argcp, char ***argvp)
argv[i] = NULL; argv[i] = NULL;
} }
} }
#endif /*HAVE_W32CE_SYSTEM*/ #endif /*HAVE_W32CE_SYSTEM*/

View File

@ -45,7 +45,7 @@
/*-- Begin configurable part. --*/ /*-- Begin configurable part. --*/
/* The size of the internal buffers. /* The size of the internal buffers.
NOTE: If you change this value you MUST also adjust the regression NOTE: If you change this value you MUST also adjust the regression
test "armored_key_8192" in armor.test! */ test "armored_key_8192" in armor.test! */
#define IOBUF_BUFFER_SIZE 8192 #define IOBUF_BUFFER_SIZE 8192
@ -71,7 +71,7 @@
typedef struct typedef struct
{ {
gnupg_fd_t fp; /* Open file pointer or handle. */ gnupg_fd_t fp; /* Open file pointer or handle. */
int keep_open; int keep_open;
int no_cache; int no_cache;
int eof_seen; int eof_seen;
int print_only_name; /* Flags indicating that fname is not a real file. */ int print_only_name; /* Flags indicating that fname is not a real file. */
@ -156,7 +156,7 @@ fd_cache_strcmp (const char *a, const char *b)
#ifdef HAVE_DOSISH_SYSTEM #ifdef HAVE_DOSISH_SYSTEM
for (; *a && *b; a++, b++) for (; *a && *b; a++, b++)
{ {
if (*a != *b && !((*a == '/' && *b == '\\') if (*a != *b && !((*a == '/' && *b == '\\')
|| (*a == '\\' && *b == '/')) ) || (*a == '\\' && *b == '/')) )
break; break;
} }
@ -327,7 +327,7 @@ direct_open (const char *fname, const char *mode)
/* /*
* Instead of closing an FD we keep it open and cache it for later reuse * Instead of closing an FD we keep it open and cache it for later reuse
* Note that this caching strategy only works if the process does not chdir. * Note that this caching strategy only works if the process does not chdir.
*/ */
static void static void
@ -878,7 +878,7 @@ block_filter (void *opaque, int control, iobuf_t chain, byte * buffer,
/* log_debug("partial: ctx=%p c=%02x size=%u\n", a, c, a->size); */ /* log_debug("partial: ctx=%p c=%02x size=%u\n", a, c, a->size); */
} }
else else
BUG (); BUG ();
} }
while (!rc && size && a->size) while (!rc && size && a->size)
@ -1483,13 +1483,13 @@ int
iobuf_ioctl (iobuf_t a, iobuf_ioctl_t cmd, int intval, void *ptrval) iobuf_ioctl (iobuf_t a, iobuf_ioctl_t cmd, int intval, void *ptrval)
{ {
if (cmd == IOBUF_IOCTL_KEEP_OPEN) if (cmd == IOBUF_IOCTL_KEEP_OPEN)
{ {
/* Keep system filepointer/descriptor open. This was used in /* Keep system filepointer/descriptor open. This was used in
the past by http.c; this ioctl is not directly used the past by http.c; this ioctl is not directly used
anymore. */ anymore. */
if (DBG_IOBUF) if (DBG_IOBUF)
log_debug ("iobuf-%d.%d: ioctl `%s' keep_open=%d\n", log_debug ("iobuf-%d.%d: ioctl `%s' keep_open=%d\n",
a ? a->no : -1, a ? a->subno : -1, a ? a->no : -1, a ? a->subno : -1,
a && a->desc ? a->desc : "?", a && a->desc ? a->desc : "?",
intval); intval);
for (; a; a = a->chain) for (; a; a = a->chain)
@ -1524,7 +1524,7 @@ iobuf_ioctl (iobuf_t a, iobuf_ioctl_t cmd, int intval, void *ptrval)
{ {
if (DBG_IOBUF) if (DBG_IOBUF)
log_debug ("iobuf-%d.%d: ioctl `%s' no_cache=%d\n", log_debug ("iobuf-%d.%d: ioctl `%s' no_cache=%d\n",
a ? a->no : -1, a ? a->subno : -1, a ? a->no : -1, a ? a->subno : -1,
a && a->desc? a->desc : "?", a && a->desc? a->desc : "?",
intval); intval);
for (; a; a = a->chain) for (; a; a = a->chain)
@ -1640,7 +1640,7 @@ iobuf_push_filter2 (iobuf_t a,
if (DBG_IOBUF) if (DBG_IOBUF)
{ {
log_debug ("iobuf-%d.%d: push `%s'\n", a->no, a->subno, log_debug ("iobuf-%d.%d: push `%s'\n", a->no, a->subno,
a->desc?a->desc:"?"); a->desc?a->desc:"?");
print_chain (a); print_chain (a);
} }
@ -2147,24 +2147,24 @@ iobuf_get_filelength (iobuf_t a, int *overflow)
if (overflow) if (overflow)
*overflow = 0; *overflow = 0;
if ( a->directfp ) if ( a->directfp )
{ {
FILE *fp = a->directfp; FILE *fp = a->directfp;
if ( !fstat(fileno(fp), &st) ) if ( !fstat(fileno(fp), &st) )
return st.st_size; return st.st_size;
log_error("fstat() failed: %s\n", strerror(errno) ); log_error("fstat() failed: %s\n", strerror(errno) );
return 0; return 0;
} }
/* Hmmm: file_filter may have already been removed */ /* Hmmm: file_filter may have already been removed */
for ( ; a; a = a->chain ) for ( ; a; a = a->chain )
if ( !a->chain && a->filter == file_filter ) if ( !a->chain && a->filter == file_filter )
{ {
file_filter_ctx_t *b = a->filter_ov; file_filter_ctx_t *b = a->filter_ov;
gnupg_fd_t fp = b->fp; gnupg_fd_t fp = b->fp;
#if defined(HAVE_W32_SYSTEM) #if defined(HAVE_W32_SYSTEM)
ulong size; ulong size;
static int (* __stdcall get_file_size_ex) (void *handle, static int (* __stdcall get_file_size_ex) (void *handle,
@ -2174,7 +2174,7 @@ iobuf_get_filelength (iobuf_t a, int *overflow)
if (!get_file_size_ex_initialized) if (!get_file_size_ex_initialized)
{ {
void *handle; void *handle;
handle = dlopen ("kernel32.dll", RTLD_LAZY); handle = dlopen ("kernel32.dll", RTLD_LAZY);
if (handle) if (handle)
{ {
@ -2184,21 +2184,21 @@ iobuf_get_filelength (iobuf_t a, int *overflow)
} }
get_file_size_ex_initialized = 1; get_file_size_ex_initialized = 1;
} }
if (get_file_size_ex) if (get_file_size_ex)
{ {
/* This is a newer system with GetFileSizeEx; we use this /* This is a newer system with GetFileSizeEx; we use this
then because it seem that GetFileSize won't return a then because it seem that GetFileSize won't return a
proper error in case a file is larger than 4GB. */ proper error in case a file is larger than 4GB. */
LARGE_INTEGER exsize; LARGE_INTEGER exsize;
if (get_file_size_ex (fp, &exsize)) if (get_file_size_ex (fp, &exsize))
{ {
if (!exsize.u.HighPart) if (!exsize.u.HighPart)
return exsize.u.LowPart; return exsize.u.LowPart;
if (overflow) if (overflow)
*overflow = 1; *overflow = 1;
return 0; return 0;
} }
} }
else else
@ -2215,14 +2215,14 @@ iobuf_get_filelength (iobuf_t a, int *overflow)
#endif #endif
break/*the for loop*/; break/*the for loop*/;
} }
return 0; return 0;
} }
/* Return the file descriptor of the underlying file or -1 if it is /* Return the file descriptor of the underlying file or -1 if it is
not available. */ not available. */
int int
iobuf_get_fd (iobuf_t a) iobuf_get_fd (iobuf_t a)
{ {
if (a->directfp) if (a->directfp)
@ -2501,7 +2501,7 @@ translate_file_handle (int fd, int for_write)
#elif defined(HAVE_W32_SYSTEM) #elif defined(HAVE_W32_SYSTEM)
{ {
int x; int x;
(void)for_write; (void)for_write;
if (fd == 0) if (fd == 0)
@ -2533,13 +2533,13 @@ iobuf_skip_rest (iobuf_t a, unsigned long n, int partial)
{ {
for (;;) for (;;)
{ {
if (a->nofast || a->d.start >= a->d.len) if (a->nofast || a->d.start >= a->d.len)
{ {
if (iobuf_readbyte (a) == -1) if (iobuf_readbyte (a) == -1)
{ {
break; break;
} }
} }
else else
{ {
unsigned long count = a->d.len - a->d.start; unsigned long count = a->d.len - a->d.start;
@ -2547,11 +2547,11 @@ iobuf_skip_rest (iobuf_t a, unsigned long n, int partial)
a->d.start = a->d.len; a->d.start = a->d.len;
} }
} }
} }
else else
{ {
unsigned long remaining = n; unsigned long remaining = n;
while (remaining > 0) while (remaining > 0)
{ {
if (a->nofast || a->d.start >= a->d.len) if (a->nofast || a->d.start >= a->d.len)
{ {
@ -2560,11 +2560,11 @@ iobuf_skip_rest (iobuf_t a, unsigned long n, int partial)
break; break;
} }
--remaining; --remaining;
} }
else else
{ {
unsigned long count = a->d.len - a->d.start; unsigned long count = a->d.len - a->d.start;
if (count > remaining) if (count > remaining)
{ {
count = remaining; count = remaining;
} }

View File

@ -38,7 +38,7 @@
/* Command codes for iobuf_ioctl. */ /* Command codes for iobuf_ioctl. */
typedef enum typedef enum
{ {
IOBUF_IOCTL_KEEP_OPEN = 1, /* Uses intval. */ IOBUF_IOCTL_KEEP_OPEN = 1, /* Uses intval. */
IOBUF_IOCTL_INVALIDATE_CACHE = 2, /* Uses ptrval. */ IOBUF_IOCTL_INVALIDATE_CACHE = 2, /* Uses ptrval. */

View File

@ -1,5 +1,5 @@
/* localename.c - Determine the current selected locale. /* localename.c - Determine the current selected locale.
Copyright (C) 1995-1999, 2000-2003, 2007, Copyright (C) 1995-1999, 2000-2003, 2007,
2008 Free Software Foundation, Inc. 2008 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
@ -17,7 +17,7 @@
*/ */
/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */ /* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
/* Win32 code written by Tor Lillqvist <tml@iki.fi>. */ /* Win32 code written by Tor Lillqvist <tml@iki.fi>. */
/* Modified for GpgOL use by Werner Koch <wk@gnupg.org>, 2005. */ /* Modified for GpgOL use by Werner Koch <wk@gnupg.org>, 2005. */
/* Modified for GnuPG use by Werner Koch <wk@gnupg.org>, 2007 */ /* Modified for GnuPG use by Werner Koch <wk@gnupg.org>, 2007 */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -68,7 +68,7 @@ do_nl_locale_name (int category, const char *categoryname)
# if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL # if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
(void)categoryname; (void)categoryname;
retval = setlocale (category, NULL); retval = setlocale (category, NULL);
# else # else
/* Setting of LC_ALL overwrites all other. */ /* Setting of LC_ALL overwrites all other. */
retval = getenv ("LC_ALL"); retval = getenv ("LC_ALL");
if (retval == NULL || retval[0] == '\0') if (retval == NULL || retval[0] == '\0')
@ -114,4 +114,3 @@ gnupg_messages_locale_name (void)
return s; return s;
} }

View File

@ -1,5 +1,5 @@
/* logging.c - Useful logging functions /* logging.c - Useful logging functions
* Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, * Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
* 2009, 2010 Free Software Foundation, Inc. * 2009, 2010 Free Software Foundation, Inc.
* *
* This file is part of JNLIB. * This file is part of JNLIB.
@ -134,7 +134,7 @@ writen (int fd, const void *buffer, size_t nbytes, int is_socket)
#ifndef HAVE_W32_SYSTEM #ifndef HAVE_W32_SYSTEM
(void)is_socket; /* Not required. */ (void)is_socket; /* Not required. */
#endif #endif
while (nleft > 0) while (nleft > 0)
{ {
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
@ -151,14 +151,14 @@ writen (int fd, const void *buffer, size_t nbytes, int is_socket)
nleft -= nwritten; nleft -= nwritten;
buf = buf + nwritten; buf = buf + nwritten;
} }
return 0; return 0;
} }
/* Returns true if STR represents a valid port number in decimal /* Returns true if STR represents a valid port number in decimal
notation and no garbage is following. */ notation and no garbage is following. */
static int static int
parse_portno (const char *str, unsigned short *r_port) parse_portno (const char *str, unsigned short *r_port)
{ {
unsigned int value; unsigned int value;
@ -177,7 +177,7 @@ parse_portno (const char *str, unsigned short *r_port)
} }
static ssize_t static ssize_t
fun_writer (void *cookie_arg, const void *buffer, size_t size) fun_writer (void *cookie_arg, const void *buffer, size_t size)
{ {
struct fun_cookie_s *cookie = cookie_arg; struct fun_cookie_s *cookie = cookie_arg;
@ -222,7 +222,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
else if (!strncmp (name, "socket://", 9) && name[9]) else if (!strncmp (name, "socket://", 9) && name[9])
name += 9; name += 9;
#endif #endif
if (af == AF_LOCAL) if (af == AF_LOCAL)
{ {
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
@ -255,7 +255,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
jnlib_set_errno (EINVAL); jnlib_set_errno (EINVAL);
addrlen = 0; addrlen = 0;
} }
else else
{ {
*p = 0; *p = 0;
#ifdef WITH_IPV6 #ifdef WITH_IPV6
@ -310,7 +310,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
addrlen = 0; addrlen = 0;
#endif /*!HAVE_INET_PTON*/ #endif /*!HAVE_INET_PTON*/
} }
jnlib_free (addrstr); jnlib_free (addrstr);
} }
@ -334,7 +334,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
cookie->fd = -1; cookie->fd = -1;
} }
} }
if (cookie->fd == -1) if (cookie->fd == -1)
{ {
if (!running_detached) if (!running_detached)
@ -357,21 +357,21 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
cookie->is_socket = 1; cookie->is_socket = 1;
} }
} }
log_socket = cookie->fd; log_socket = cookie->fd;
if (cookie->fd != -1) if (cookie->fd != -1)
{ {
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
if (cookie->use_writefile) if (cookie->use_writefile)
{ {
DWORD nwritten; DWORD nwritten;
WriteFile ((HANDLE)cookie->fd, buffer, size, &nwritten, NULL); WriteFile ((HANDLE)cookie->fd, buffer, size, &nwritten, NULL);
return (ssize_t)size; /* Okay. */ return (ssize_t)size; /* Okay. */
} }
#endif #endif
if (!writen (cookie->fd, buffer, size, cookie->is_socket)) if (!writen (cookie->fd, buffer, size, cookie->is_socket))
return (ssize_t)size; /* Okay. */ return (ssize_t)size; /* Okay. */
} }
if (!running_detached && cookie->fd != -1 if (!running_detached && cookie->fd != -1
@ -390,7 +390,7 @@ fun_writer (void *cookie_arg, const void *buffer, size_t size)
cookie->fd = -1; cookie->fd = -1;
log_socket = -1; log_socket = -1;
} }
return (ssize_t)size; return (ssize_t)size;
} }
@ -411,7 +411,7 @@ fun_closer (void *cookie_arg)
/* Common function to either set the logging to a file or a file /* Common function to either set the logging to a file or a file
descriptor. */ descriptor. */
static void static void
set_file_fd (const char *name, int fd) set_file_fd (const char *name, int fd)
{ {
estream_t fp; estream_t fp;
int want_socket; int want_socket;
@ -489,7 +489,7 @@ set_file_fd (const char *name, int fd)
es_cookie_io_functions_t io = { NULL }; es_cookie_io_functions_t io = { NULL };
io.func_write = fun_writer; io.func_write = fun_writer;
io.func_close = fun_closer; io.func_close = fun_closer;
fp = es_fopencookie (cookie, "w", io); fp = es_fopencookie (cookie, "w", io);
} }
@ -498,7 +498,7 @@ set_file_fd (const char *name, int fd)
fp = es_stderr; fp = es_stderr;
es_setvbuf (fp, NULL, _IOLBF, 0); es_setvbuf (fp, NULL, _IOLBF, 0);
logstream = fp; logstream = fp;
/* We always need to print the prefix and the pid for socket mode, /* We always need to print the prefix and the pid for socket mode,
@ -518,7 +518,7 @@ set_file_fd (const char *name, int fd)
tries the next time again to connect the socket. tries the next time again to connect the socket.
*/ */
void void
log_set_file (const char *name) log_set_file (const char *name)
{ {
set_file_fd (name? name: "-", -1); set_file_fd (name? name: "-", -1);
} }
@ -545,7 +545,7 @@ log_set_prefix (const char *text, unsigned int flags)
strncpy (prefix_buffer, text, sizeof (prefix_buffer)-1); strncpy (prefix_buffer, text, sizeof (prefix_buffer)-1);
prefix_buffer[sizeof (prefix_buffer)-1] = 0; prefix_buffer[sizeof (prefix_buffer)-1] = 0;
} }
with_prefix = (flags & JNLIB_LOG_WITH_PREFIX); with_prefix = (flags & JNLIB_LOG_WITH_PREFIX);
with_time = (flags & JNLIB_LOG_WITH_TIME); with_time = (flags & JNLIB_LOG_WITH_TIME);
with_pid = (flags & JNLIB_LOG_WITH_PID); with_pid = (flags & JNLIB_LOG_WITH_PID);
@ -635,7 +635,7 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr)
{ {
struct tm *tp; struct tm *tp;
time_t atime = time (NULL); time_t atime = time (NULL);
tp = localtime (&atime); tp = localtime (&atime);
es_fprintf_unlocked (logstream, "%04d-%02d-%02d %02d:%02d:%02d ", es_fprintf_unlocked (logstream, "%04d-%02d-%02d %02d:%02d:%02d ",
1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday, 1900+tp->tm_year, tp->tm_mon+1, tp->tm_mday,
@ -674,7 +674,7 @@ do_logv (int level, int ignore_arg_ptr, const char *fmt, va_list arg_ptr)
case JNLIB_LOG_FATAL: es_fputs_unlocked ("Fatal: ",logstream ); break; case JNLIB_LOG_FATAL: es_fputs_unlocked ("Fatal: ",logstream ); break;
case JNLIB_LOG_BUG: es_fputs_unlocked ("Ohhhh jeeee: ", logstream); break; case JNLIB_LOG_BUG: es_fputs_unlocked ("Ohhhh jeeee: ", logstream); break;
case JNLIB_LOG_DEBUG: es_fputs_unlocked ("DBG: ", logstream ); break; case JNLIB_LOG_DEBUG: es_fputs_unlocked ("DBG: ", logstream ); break;
default: default:
es_fprintf_unlocked (logstream,"[Unknown log level %d]: ", level); es_fprintf_unlocked (logstream,"[Unknown log level %d]: ", level);
break; break;
} }
@ -712,7 +712,7 @@ void
log_log (int level, const char *fmt, ...) log_log (int level, const char *fmt, ...)
{ {
va_list arg_ptr ; va_list arg_ptr ;
va_start (arg_ptr, fmt) ; va_start (arg_ptr, fmt) ;
do_logv (level, 0, fmt, arg_ptr); do_logv (level, 0, fmt, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
@ -750,7 +750,7 @@ void
log_info (const char *fmt, ...) log_info (const char *fmt, ...)
{ {
va_list arg_ptr ; va_list arg_ptr ;
va_start (arg_ptr, fmt); va_start (arg_ptr, fmt);
do_logv (JNLIB_LOG_INFO, 0, fmt, arg_ptr); do_logv (JNLIB_LOG_INFO, 0, fmt, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
@ -761,7 +761,7 @@ void
log_error (const char *fmt, ...) log_error (const char *fmt, ...)
{ {
va_list arg_ptr ; va_list arg_ptr ;
va_start (arg_ptr, fmt); va_start (arg_ptr, fmt);
do_logv (JNLIB_LOG_ERROR, 0, fmt, arg_ptr); do_logv (JNLIB_LOG_ERROR, 0, fmt, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
@ -775,7 +775,7 @@ void
log_fatal (const char *fmt, ...) log_fatal (const char *fmt, ...)
{ {
va_list arg_ptr ; va_list arg_ptr ;
va_start (arg_ptr, fmt); va_start (arg_ptr, fmt);
do_logv (JNLIB_LOG_FATAL, 0, fmt, arg_ptr); do_logv (JNLIB_LOG_FATAL, 0, fmt, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
@ -799,7 +799,7 @@ void
log_debug (const char *fmt, ...) log_debug (const char *fmt, ...)
{ {
va_list arg_ptr ; va_list arg_ptr ;
va_start (arg_ptr, fmt); va_start (arg_ptr, fmt);
do_logv (JNLIB_LOG_DEBUG, 0, fmt, arg_ptr); do_logv (JNLIB_LOG_DEBUG, 0, fmt, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
@ -810,7 +810,7 @@ void
log_printf (const char *fmt, ...) log_printf (const char *fmt, ...)
{ {
va_list arg_ptr; va_list arg_ptr;
va_start (arg_ptr, fmt); va_start (arg_ptr, fmt);
do_logv (fmt ? JNLIB_LOG_CONT : JNLIB_LOG_BEGIN, 0, fmt, arg_ptr); do_logv (fmt ? JNLIB_LOG_CONT : JNLIB_LOG_BEGIN, 0, fmt, arg_ptr);
va_end (arg_ptr); va_end (arg_ptr);
@ -861,4 +861,3 @@ bug_at( const char *file, int line )
abort (); /* Never called; just to make the compiler happy. */ abort (); /* Never called; just to make the compiler happy. */
} }
#endif #endif

View File

@ -87,8 +87,3 @@ void log_printhex (const char *text, const void *buffer, size_t length);
#endif /*LIBJNLIB_LOGGING_H*/ #endif /*LIBJNLIB_LOGGING_H*/

View File

@ -85,7 +85,7 @@ put_membuf (membuf_t *mb, const void *buf, size_t len)
if (mb->len + len >= mb->size) if (mb->len + len >= mb->size)
{ {
char *p; char *p;
mb->size += len + 1024; mb->size += len + 1024;
p = xtryrealloc (mb->buf, mb->size); p = xtryrealloc (mb->buf, mb->size);
if (!p) if (!p)
@ -94,7 +94,7 @@ put_membuf (membuf_t *mb, const void *buf, size_t len)
/* Wipe out what we already accumulated. This is required /* Wipe out what we already accumulated. This is required
in case we are storing sensitive data here. The membuf in case we are storing sensitive data here. The membuf
API does not provide another way to cleanup after an API does not provide another way to cleanup after an
error. */ error. */
wipememory (mb->buf, mb->len); wipememory (mb->buf, mb->len);
return; return;
} }
@ -158,4 +158,3 @@ peek_membuf (membuf_t *mb, size_t *len)
*len = mb->len; *len = mb->len;
return p; return p;
} }

View File

@ -22,12 +22,12 @@
/* The definition of the structure is private, we only need it here, /* The definition of the structure is private, we only need it here,
so it can be allocated on the stack. */ so it can be allocated on the stack. */
struct private_membuf_s struct private_membuf_s
{ {
size_t len; size_t len;
size_t size; size_t size;
char *buf; char *buf;
int out_of_core; int out_of_core;
}; };
typedef struct private_membuf_s membuf_t; typedef struct private_membuf_s membuf_t;

View File

@ -31,7 +31,7 @@ static void
my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr) my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr)
{ {
(void)dummy; (void)dummy;
/* Map the log levels. */ /* Map the log levels. */
switch (level) switch (level)
{ {
@ -42,7 +42,7 @@ my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr)
case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break; case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break;
case GCRY_LOG_BUG: level = JNLIB_LOG_BUG; break; case GCRY_LOG_BUG: level = JNLIB_LOG_BUG; break;
case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break; case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break;
default: level = JNLIB_LOG_ERROR; break; default: level = JNLIB_LOG_ERROR; break;
} }
log_logv (level, fmt, arg_ptr); log_logv (level, fmt, arg_ptr);
} }
@ -102,7 +102,7 @@ setup_libgcrypt_logging (void)
and "AES256". We can't fix that in libgcrypt but it is pretty and "AES256". We can't fix that in libgcrypt but it is pretty
safe to do it in an application. */ safe to do it in an application. */
const char * const char *
gnupg_cipher_algo_name (int algo) gnupg_cipher_algo_name (int algo)
{ {
const char *s; const char *s;
@ -139,7 +139,7 @@ void
print_utf8_buffer2 (estream_t stream, const void *p, size_t n, int delim) print_utf8_buffer2 (estream_t stream, const void *p, size_t n, int delim)
{ {
char tmp[2]; char tmp[2];
tmp[0] = delim; tmp[0] = delim;
tmp[1] = 0; tmp[1] = 0;
es_write_sanitized_utf8_buffer (stream, p, n, tmp, NULL); es_write_sanitized_utf8_buffer (stream, p, n, tmp, NULL);
@ -197,7 +197,7 @@ is_file_compressed (const char *s, int *ret_rc)
{ 3, { 0x1f, 0x8b, 0x08, 0x00 } }, /* gzip */ { 3, { 0x1f, 0x8b, 0x08, 0x00 } }, /* gzip */
{ 4, { 0x50, 0x4b, 0x03, 0x04 } }, /* (pk)zip */ { 4, { 0x50, 0x4b, 0x03, 0x04 } }, /* (pk)zip */
}; };
if ( iobuf_is_pipe_filename (s) || !ret_rc ) if ( iobuf_is_pipe_filename (s) || !ret_rc )
return 0; /* We can't check stdin or no file was given */ return 0; /* We can't check stdin or no file was given */
@ -225,7 +225,7 @@ is_file_compressed (const char *s, int *ret_rc)
} }
} }
leave: leave:
iobuf_close( a ); iobuf_close( a );
return rc; return rc;
} }
@ -262,7 +262,7 @@ static const char*
parse_version_number (const char *s, int *number) parse_version_number (const char *s, int *number)
{ {
int val = 0; int val = 0;
if (*s == '0' && digitp (s+1)) if (*s == '0' && digitp (s+1))
return NULL; /* Leading zeros are not allowed. */ return NULL; /* Leading zeros are not allowed. */
for (; digitp (s); s++ ) for (; digitp (s); s++ )
@ -330,4 +330,3 @@ gnupg_compare_version (const char *a, const char *b)
&& a_micro == b_micro && a_micro == b_micro
&& strcmp (a_plvl, b_plvl) >= 0)); && strcmp (a_plvl, b_plvl) >= 0));
} }

View File

@ -53,13 +53,13 @@ int
same_file_p (const char *name1, const char *name2) same_file_p (const char *name1, const char *name2)
{ {
int yes; int yes;
/* First try a shortcut. */ /* First try a shortcut. */
if (!compare_filenames (name1, name2)) if (!compare_filenames (name1, name2))
yes = 1; yes = 1;
else else
{ {
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
HANDLE file1, file2; HANDLE file1, file2;
BY_HANDLE_FILE_INFORMATION info1, info2; BY_HANDLE_FILE_INFORMATION info1, info2;
@ -72,7 +72,7 @@ same_file_p (const char *name1, const char *name2)
file1 = INVALID_HANDLE_VALUE; file1 = INVALID_HANDLE_VALUE;
jnlib_free (wname); jnlib_free (wname);
} }
#else #else
file1 = CreateFile (name1, 0, 0, NULL, OPEN_EXISTING, 0, NULL); file1 = CreateFile (name1, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
#endif #endif
if (file1 == INVALID_HANDLE_VALUE) if (file1 == INVALID_HANDLE_VALUE)
@ -106,7 +106,7 @@ same_file_p (const char *name1, const char *name2)
} }
#else /*!HAVE_W32_SYSTEM*/ #else /*!HAVE_W32_SYSTEM*/
struct stat info1, info2; struct stat info1, info2;
yes = (!stat (name1, &info1) && !stat (name2, &info2) yes = (!stat (name1, &info1) && !stat (name2, &info2)
&& info1.st_dev == info2.st_dev && info1.st_ino == info2.st_ino); && info1.st_dev == info2.st_dev && info1.st_ino == info2.st_ino);
#endif /*!HAVE_W32_SYSTEM*/ #endif /*!HAVE_W32_SYSTEM*/
@ -180,7 +180,7 @@ timegm (struct tm *tm)
} }
} }
if (old_zone) if (old_zone)
putenv (old_zone); putenv (old_zone);
} }
else else
gnupg_unsetenv("TZ"); gnupg_unsetenv("TZ");
@ -190,4 +190,3 @@ timegm (struct tm *tm)
#endif #endif
} }
#endif /*!HAVE_TIMEGM*/ #endif /*!HAVE_TIMEGM*/

View File

@ -28,12 +28,12 @@ cat <<EOF
/** /**
* gnupg_strerror: * gnupg_strerror:
* @err: Error code * @err: Error code
* *
* This function returns a textual representaion of the given * This function returns a textual representaion of the given
* errorcode. If this is an unknown value, a string with the value * errorcode. If this is an unknown value, a string with the value
* is returned (Beware: it is hold in a static buffer). * is returned (Beware: it is hold in a static buffer).
* *
* Return value: String with the error description. * Return value: String with the error description.
**/ **/
const char * const char *

View File

@ -24,13 +24,13 @@ cat <<EOF
/** /**
* gnupg_error_token: * gnupg_error_token:
* @err: Error code * @err: Error code
* *
* This function returns a textual representaion of the given * This function returns a textual representaion of the given
* errorcode. If this is an unknown value, a static string is returned. * errorcode. If this is an unknown value, a static string is returned.
* This function differs from gnupg_strerror that it yields the string * This function differs from gnupg_strerror that it yields the string
* representation of the macro which is never subject to i18n. * representation of the macro which is never subject to i18n.
* *
* Return value: String with the error token. * Return value: String with the error token.
**/ **/
const char * const char *

View File

@ -1,6 +1,6 @@
# mkstrtable.awk # mkstrtable.awk
# Copyright (C) 2003, 2004 g10 Code GmbH # Copyright (C) 2003, 2004 g10 Code GmbH
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as # modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of # published by the Free Software Foundation; either version 2 of
@ -181,5 +181,5 @@ END {
print " : " stop + 1 " - " skip ")"; print " : " stop + 1 " - " skip ")";
else else
print " : -1)"; print " : -1)";
} }

View File

@ -21,7 +21,7 @@
#ifndef GNUPG_COMMON_OPENPGPDEFS_H #ifndef GNUPG_COMMON_OPENPGPDEFS_H
#define GNUPG_COMMON_OPENPGPDEFS_H #define GNUPG_COMMON_OPENPGPDEFS_H
typedef enum typedef enum
{ {
PKT_NONE = 0, PKT_NONE = 0,
PKT_PUBKEY_ENC = 1, /* Public key encrypted packet. */ PKT_PUBKEY_ENC = 1, /* Public key encrypted packet. */
@ -44,11 +44,11 @@ typedef enum
PKT_MDC = 19, /* Manipulation detection code packet. */ PKT_MDC = 19, /* Manipulation detection code packet. */
PKT_COMMENT = 61, /* new comment packet (GnuPG specific). */ PKT_COMMENT = 61, /* new comment packet (GnuPG specific). */
PKT_GPG_CONTROL = 63 /* internal control packet (GnuPG specific). */ PKT_GPG_CONTROL = 63 /* internal control packet (GnuPG specific). */
} }
pkttype_t; pkttype_t;
typedef enum typedef enum
{ {
SIGSUBPKT_TEST_CRITICAL = -3, SIGSUBPKT_TEST_CRITICAL = -3,
SIGSUBPKT_LIST_UNHASHED = -2, SIGSUBPKT_LIST_UNHASHED = -2,
@ -76,11 +76,11 @@ typedef enum
SIGSUBPKT_SIGNERS_UID = 28, /* Signer's user id. */ SIGSUBPKT_SIGNERS_UID = 28, /* Signer's user id. */
SIGSUBPKT_REVOC_REASON = 29, /* Reason for revocation. */ SIGSUBPKT_REVOC_REASON = 29, /* Reason for revocation. */
SIGSUBPKT_FEATURES = 30, /* Feature flags. */ SIGSUBPKT_FEATURES = 30, /* Feature flags. */
SIGSUBPKT_SIGNATURE = 32, /* Embedded signature. */ SIGSUBPKT_SIGNATURE = 32, /* Embedded signature. */
SIGSUBPKT_FLAG_CRITICAL = 128 SIGSUBPKT_FLAG_CRITICAL = 128
} }
sigsubpkttype_t; sigsubpkttype_t;

View File

@ -46,13 +46,13 @@ percent_plus_escape (const char *string)
for (length=1, s=string; *s; s++) for (length=1, s=string; *s; s++)
{ {
if (*s == '+' || *s == '\"' || *s == '%' if (*s == '+' || *s == '\"' || *s == '%'
|| *(const unsigned char *)s < 0x20) || *(const unsigned char *)s < 0x20)
length += 3; length += 3;
else else
length++; length++;
} }
buffer = p = xtrymalloc (length); buffer = p = xtrymalloc (length);
if (!buffer) if (!buffer)
return NULL; return NULL;
@ -82,7 +82,7 @@ percent_plus_escape (const char *string)
done if WITHPLUS is true. An escaped Nul character will be done if WITHPLUS is true. An escaped Nul character will be
replaced by NULREPL. */ replaced by NULREPL. */
static size_t static size_t
do_unescape (unsigned char *buffer, const unsigned char *string, do_unescape (unsigned char *buffer, const unsigned char *string,
int withplus, int nulrepl) int withplus, int nulrepl)
{ {
unsigned char *p = buffer; unsigned char *p = buffer;
@ -90,7 +90,7 @@ do_unescape (unsigned char *buffer, const unsigned char *string,
while (*string) while (*string)
{ {
if (*string == '%' && string[1] && string[2]) if (*string == '%' && string[1] && string[2])
{ {
string++; string++;
*p = xtoi_2 (string); *p = xtoi_2 (string);
if (!*p) if (!*p)
@ -119,7 +119,7 @@ count_unescape (const unsigned char *string)
while (*string) while (*string)
{ {
if (*string == '%' && string[1] && string[2]) if (*string == '%' && string[1] && string[2])
{ {
string++; string++;
string++; string++;
} }
@ -181,7 +181,7 @@ do_unescape_inplace (char *string, int withplus, int nulrepl)
while (*string) while (*string)
{ {
if (*string == '%' && string[1] && string[2]) if (*string == '%' && string[1] && string[2])
{ {
string++; string++;
*p = xtoi_2 (string); *p = xtoi_2 (string);
if (!*p) if (!*p)
@ -226,4 +226,3 @@ percent_unescape_inplace (char *string, int nulrepl)
{ {
return do_unescape_inplace (string, 0, nulrepl); return do_unescape_inplace (string, 0, nulrepl);
} }

View File

@ -47,7 +47,7 @@
/* Parse the TXT resource record. Format is: /* Parse the TXT resource record. Format is:
v=pka1;fpr=a4d94e92b0986ab5ee9dcd755de249965b0358a2;uri=string v=pka1;fpr=a4d94e92b0986ab5ee9dcd755de249965b0358a2;uri=string
For simplicity white spaces are not allowed. Because we expect to For simplicity white spaces are not allowed. Because we expect to
use a new RRTYPE for this in the future we define the TXT really use a new RRTYPE for this in the future we define the TXT really
strict for simplicity: No white spaces, case sensitivity of the strict for simplicity: No white spaces, case sensitivity of the
@ -70,7 +70,7 @@ parse_txt_record (char *buffer, unsigned char *fpr)
*pend++ = 0; *pend++ = 0;
if (strcmp (p, "v=pka1")) if (strcmp (p, "v=pka1"))
return -1; /* Wrong or missing version. */ return -1; /* Wrong or missing version. */
p = pend; p = pend;
pend = strchr (p, ';'); pend = strchr (p, ';');
if (pend) if (pend)
@ -82,11 +82,11 @@ parse_txt_record (char *buffer, unsigned char *fpr)
fpr[i] = xtoi_2 (p); fpr[i] = xtoi_2 (p);
if (i != 20) if (i != 20)
return -1; /* Fingerprint consists not of exactly 40 hexbytes. */ return -1; /* Fingerprint consists not of exactly 40 hexbytes. */
p = pend; p = pend;
if (!p || !*p) if (!p || !*p)
{ {
*buffer = 0; *buffer = 0;
return 0; /* Success (no URI given). */ return 0; /* Success (no URI given). */
} }
if (strncmp (p, "uri=", 4)) if (strncmp (p, "uri=", 4))
@ -119,7 +119,7 @@ get_pka_info (const char *address, unsigned char *fpr)
char *name; char *name;
adns_answer *answer = NULL; adns_answer *answer = NULL;
char *buffer = NULL; char *buffer = NULL;
domain = strrchr (address, '@'); domain = strrchr (address, '@');
if (!domain || domain == address || !domain[1]) if (!domain || domain == address || !domain[1])
return NULL; /* Invalid mail address given. */ return NULL; /* Invalid mail address given. */
@ -146,7 +146,7 @@ get_pka_info (const char *address, unsigned char *fpr)
adns_finish (state); adns_finish (state);
return NULL; return NULL;
} }
if (answer->status != adns_s_ok if (answer->status != adns_s_ok
|| answer->type != adns_r_txt || !answer->nrrs) || answer->type != adns_r_txt || !answer->nrrs)
{ {
log_error ("DNS query returned an error: %s (%s)\n", log_error ("DNS query returned an error: %s (%s)\n",
@ -209,7 +209,7 @@ get_pka_info (const char *address, unsigned char *fpr)
expansion of the buffer. */ expansion of the buffer. */
if (anslen > PACKETSZ) if (anslen > PACKETSZ)
return NULL; /* DNS resolver returned a too long answer */ return NULL; /* DNS resolver returned a too long answer */
qdcount = ntohs (header.qdcount); qdcount = ntohs (header.qdcount);
ancount = ntohs (header.ancount); ancount = ntohs (header.ancount);
nscount = ntohs (header.nscount); nscount = ntohs (header.nscount);
@ -226,7 +226,7 @@ get_pka_info (const char *address, unsigned char *fpr)
rc = dn_skipname (p, pend); rc = dn_skipname (p, pend);
if (rc == -1) if (rc == -1)
return NULL; return NULL;
p += rc + QFIXEDSZ; p += rc + QFIXEDSZ;
} }
if (ancount > 1) if (ancount > 1)

View File

@ -49,8 +49,8 @@ struct session_environment_s
/* A list of environment vribales we pass from the acual user /* A list of environment vribales we pass from the acual user
(e.g. gpgme) down to the pinentry. We do not handle the locale (e.g. gpgme) down to the pinentry. We do not handle the locale
settings because they do not only depend on envvars. */ settings because they do not only depend on envvars. */
static struct static struct
{ {
const char *name; const char *name;
const char *assname; /* Name used by Assuan or NULL. */ const char *assname; /* Name used by Assuan or NULL. */
} stdenvnames[] = { } stdenvnames[] = {
@ -64,7 +64,7 @@ static struct
modules (eg "scim-bridge"). */ modules (eg "scim-bridge"). */
{ "QT_IM_MODULE" }, /* Used by Qt to select qt input { "QT_IM_MODULE" }, /* Used by Qt to select qt input
modules (eg "xim"). */ modules (eg "xim"). */
{ "PINENTRY_USER_DATA", "pinentry-user-data"} { "PINENTRY_USER_DATA", "pinentry-user-data"}
/* Used for communication with /* Used for communication with
non-standard Pinentries. */ non-standard Pinentries. */
}; };
@ -109,7 +109,7 @@ session_env_new (void)
se = xtrycalloc (1, sizeof *se); se = xtrycalloc (1, sizeof *se);
if (se) if (se)
{ {
se->arraysize = (lastallocatedarraysize? se->arraysize = (lastallocatedarraysize?
lastallocatedarraysize : INITIAL_ARRAYSIZE); lastallocatedarraysize : INITIAL_ARRAYSIZE);
se->array = xtrycalloc (se->arraysize, sizeof *se->array); se->array = xtrycalloc (se->arraysize, sizeof *se->array);
if (!se->array) if (!se->array)
@ -132,7 +132,7 @@ session_env_release (session_env_t se)
if (!se) if (!se)
return; return;
if (se->arraysize > INITIAL_ARRAYSIZE if (se->arraysize > INITIAL_ARRAYSIZE
&& se->arraysize <= MAXDEFAULT_ARRAYSIZE && se->arraysize <= MAXDEFAULT_ARRAYSIZE
&& se->arraysize > lastallocatedarraysize) && se->arraysize > lastallocatedarraysize)
lastallocatedarraysize = se->arraysize; lastallocatedarraysize = se->arraysize;
@ -249,7 +249,7 @@ gpg_error_t
session_env_putenv (session_env_t se, const char *string) session_env_putenv (session_env_t se, const char *string)
{ {
const char *s; const char *s;
if (!string || !*string) if (!string || !*string)
return gpg_error (GPG_ERR_INV_VALUE); return gpg_error (GPG_ERR_INV_VALUE);
s = strchr (string, '='); s = strchr (string, '=');
@ -325,7 +325,7 @@ session_env_getenv_or_default (session_env_t se, const char *name,
*r_default = 1; *r_default = 1;
return se->array[idx]->value; return se->array[idx]->value;
} }
/* Get the default value with an additional fallback for GPG_TTY. */ /* Get the default value with an additional fallback for GPG_TTY. */
defvalue = getenv (name); defvalue = getenv (name);
if ((!defvalue || !*defvalue) && !strcmp (name, "GPG_TTY") && ttyname (0)) if ((!defvalue || !*defvalue) && !strcmp (name, "GPG_TTY") && ttyname (0))
@ -339,7 +339,7 @@ session_env_getenv_or_default (session_env_t se, const char *name,
explicit error anyway and the following scan would then fail explicit error anyway and the following scan would then fail
anyway. */ anyway. */
update_var (se, name, strlen (name), defvalue, 1); update_var (se, name, strlen (name), defvalue, 1);
for (idx=0; idx < se->arrayused; idx++) for (idx=0; idx < se->arrayused; idx++)
if (se->array[idx] && !strcmp (se->array[idx]->name, name)) if (se->array[idx] && !strcmp (se->array[idx]->name, name))
{ {
@ -359,7 +359,7 @@ session_env_getenv_or_default (session_env_t se, const char *name,
R_DEFAULT is not NULL, the default flag is stored on return. The R_DEFAULT is not NULL, the default flag is stored on return. The
default flag indicates that the value has been taken from the default flag indicates that the value has been taken from the
process' environment. The caller must not change the returned process' environment. The caller must not change the returned
name or value. */ name or value. */
char * char *
session_env_listenv (session_env_t se, int *iterator, session_env_listenv (session_env_t se, int *iterator,
const char **r_value, int *r_default) const char **r_value, int *r_default)
@ -381,5 +381,3 @@ session_env_listenv (session_env_t se, int *iterator,
} }
return NULL; return NULL;
} }

View File

@ -23,20 +23,20 @@
struct session_environment_s; struct session_environment_s;
typedef struct session_environment_s *session_env_t; typedef struct session_environment_s *session_env_t;
const char *session_env_list_stdenvnames (int *iterator, const char *session_env_list_stdenvnames (int *iterator,
const char **r_assname); const char **r_assname);
session_env_t session_env_new (void); session_env_t session_env_new (void);
void session_env_release (session_env_t se); void session_env_release (session_env_t se);
gpg_error_t session_env_putenv (session_env_t se, const char *string); gpg_error_t session_env_putenv (session_env_t se, const char *string);
gpg_error_t session_env_setenv (session_env_t se, gpg_error_t session_env_setenv (session_env_t se,
const char *name, const char *value); const char *name, const char *value);
char *session_env_getenv (session_env_t se, const char *name); char *session_env_getenv (session_env_t se, const char *name);
char *session_env_getenv_or_default (session_env_t se, const char *name, char *session_env_getenv_or_default (session_env_t se, const char *name,
int *r_default); int *r_default);
char *session_env_listenv (session_env_t se, int *iterator, char *session_env_listenv (session_env_t se, int *iterator,
const char **r_value, int *r_default); const char **r_value, int *r_default);

View File

@ -51,7 +51,7 @@ sskip (unsigned char const **buf, int *depth)
const unsigned char *s = *buf; const unsigned char *s = *buf;
size_t n; size_t n;
int d = *depth; int d = *depth;
while (d > 0) while (d > 0)
{ {
if (*s == '(') if (*s == '(')
@ -70,7 +70,7 @@ sskip (unsigned char const **buf, int *depth)
return gpg_error (GPG_ERR_INV_SEXP); return gpg_error (GPG_ERR_INV_SEXP);
n = snext (&s); n = snext (&s);
if (!n) if (!n)
return gpg_error (GPG_ERR_INV_SEXP); return gpg_error (GPG_ERR_INV_SEXP);
s += n; s += n;
} }
} }
@ -123,6 +123,6 @@ smklen (char *help_buffer, size_t help_buflen, size_t value, size_t *length)
*length = (help_buffer + help_buflen) - p; *length = (help_buffer + help_buflen) - p;
return p; return p;
} }
#endif /*SEXP_PARSE_H*/ #endif /*SEXP_PARSE_H*/

View File

@ -52,7 +52,7 @@ make_canon_sexp (gcry_sexp_t sexp, unsigned char **r_buffer, size_t *r_buflen)
*r_buffer = NULL; *r_buffer = NULL;
if (r_buflen) if (r_buflen)
*r_buflen = 0;; *r_buflen = 0;;
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0); len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0);
if (!len) if (!len)
return gpg_error (GPG_ERR_BUG); return gpg_error (GPG_ERR_BUG);
@ -83,7 +83,7 @@ make_canon_sexp_pad (gcry_sexp_t sexp, int secure,
*r_buffer = NULL; *r_buffer = NULL;
if (r_buflen) if (r_buflen)
*r_buflen = 0;; *r_buflen = 0;;
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0); len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0);
if (!len) if (!len)
return gpg_error (GPG_ERR_BUG); return gpg_error (GPG_ERR_BUG);
@ -189,7 +189,7 @@ make_simple_sexp_from_hexstr (const char *line, size_t *nscanned)
*nscanned = n; *nscanned = n;
if (!n) if (!n)
return NULL; return NULL;
len = ((n+1) & ~0x01)/2; len = ((n+1) & ~0x01)/2;
numbufp = smklen (numbuf, sizeof numbuf, len, &numbuflen); numbufp = smklen (numbuf, sizeof numbuf, len, &numbuflen);
buf = xtrymalloc (1 + numbuflen + len + 1 + 1); buf = xtrymalloc (1 + numbuflen + len + 1 + 1);
if (!buf) if (!buf)
@ -252,7 +252,7 @@ hash_algo_from_sigval (const unsigned char *sigval)
return 0; /* Algorithm string is missing or too long. */ return 0; /* Algorithm string is missing or too long. */
memcpy (buffer, s, n); memcpy (buffer, s, n);
buffer[n] = 0; buffer[n] = 0;
return gcry_md_map_name (buffer); return gcry_md_map_name (buffer);
} }
@ -283,7 +283,7 @@ make_canon_sexp_from_rsa_pk (const void *m_arg, size_t mlen,
; ;
for (; elen && !*e; elen--, e++) for (; elen && !*e; elen--, e++)
; ;
/* Insert a leading zero if the number would be zero or interpreted /* Insert a leading zero if the number would be zero or interpreted
as negative. */ as negative. */
if (!mlen || (m[0] & 0x80)) if (!mlen || (m[0] & 0x80))
@ -300,7 +300,7 @@ make_canon_sexp_from_rsa_pk (const void *m_arg, size_t mlen,
+ strlen (part3) + 1); + strlen (part3) + 1);
if (!keybuf) if (!keybuf)
return NULL; return NULL;
p = stpcpy (keybuf, part1); p = stpcpy (keybuf, part1);
p = stpcpy (p, mlen_str); p = stpcpy (p, mlen_str);
if (m_extra) if (m_extra)
@ -314,7 +314,7 @@ make_canon_sexp_from_rsa_pk (const void *m_arg, size_t mlen,
memcpy (p, e, elen); memcpy (p, e, elen);
p += elen; p += elen;
p = stpcpy (p, part3); p = stpcpy (p, part3);
if (r_len) if (r_len)
*r_len = p - keybuf; *r_len = p - keybuf;
@ -373,8 +373,8 @@ get_rsa_pk_from_canon_sexp (const unsigned char *keydata, size_t keydatalen,
switch (*tok) switch (*tok)
{ {
case 'n': mpi = &rsa_n; mpi_len = &rsa_n_len; break; case 'n': mpi = &rsa_n; mpi_len = &rsa_n_len; break;
case 'e': mpi = &rsa_e; mpi_len = &rsa_e_len; break; case 'e': mpi = &rsa_e; mpi_len = &rsa_e_len; break;
default: mpi = NULL; mpi_len = NULL; break; default: mpi = NULL; mpi_len = NULL; break;
} }
if (mpi && *mpi) if (mpi && *mpi)
@ -425,7 +425,7 @@ get_pk_algo_from_canon_sexp (const unsigned char *keydata, size_t keydatalen,
const unsigned char *buf, *tok; const unsigned char *buf, *tok;
size_t buflen, toklen; size_t buflen, toklen;
int depth; int depth;
*r_algo = 0; *r_algo = 0;
buf = keydata; buf = keydata;

View File

@ -45,7 +45,7 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
{ {
# ifdef HAVE_SIGACTION # ifdef HAVE_SIGACTION
struct sigaction oact, nact; struct sigaction oact, nact;
if (check_ign) if (check_ign)
{ {
/* we don't want to change an IGN handler */ /* we don't want to change an IGN handler */
@ -58,11 +58,11 @@ init_one_signal (int sig, RETSIGTYPE (*handler)(int), int check_ign )
sigemptyset (&nact.sa_mask); sigemptyset (&nact.sa_mask);
nact.sa_flags = 0; nact.sa_flags = 0;
sigaction ( sig, &nact, NULL); sigaction ( sig, &nact, NULL);
# else # else
RETSIGTYPE (*ohandler)(int); RETSIGTYPE (*ohandler)(int);
ohandler = signal (sig, handler); ohandler = signal (sig, handler);
if (check_ign && ohandler == SIG_IGN) if (check_ign && ohandler == SIG_IGN)
{ {
/* Change it back if it was already set to IGN */ /* Change it back if it was already set to IGN */
signal (sig, SIG_IGN); signal (sig, SIG_IGN);
@ -96,7 +96,7 @@ got_fatal_signal (int sig)
if (caught_fatal_sig) if (caught_fatal_sig)
raise (sig); raise (sig);
caught_fatal_sig = 1; caught_fatal_sig = 1;
if (cleanup_fnc) if (cleanup_fnc)
cleanup_fnc (); cleanup_fnc ();
/* Better don't translate these messages. */ /* Better don't translate these messages. */
@ -118,7 +118,7 @@ got_fatal_signal (int sig)
this is a bug in that system, we will protect against it. */ this is a bug in that system, we will protect against it. */
if (sig < 0 || sig >= 100000) if (sig < 0 || sig >= 100000)
res = write (2, "?", 1); res = write (2, "?", 1);
else else
{ {
int i, value, any=0; int i, value, any=0;
@ -135,7 +135,7 @@ got_fatal_signal (int sig)
} }
} }
res = write (2, " caught ... exiting\n", 20); res = write (2, " caught ... exiting\n", 20);
/* Reset action to default action and raise signal again */ /* Reset action to default action and raise signal again */
init_one_signal (sig, SIG_DFL, 0); init_one_signal (sig, SIG_DFL, 0);
/* Fixme: remove_lockfiles ();*/ /* Fixme: remove_lockfiles ();*/

View File

@ -99,7 +99,7 @@ writen (int fd, const void *buf, size_t nbytes)
{ {
size_t nleft = nbytes; size_t nleft = nbytes;
int nwritten; int nwritten;
while (nleft > 0) while (nleft > 0)
{ {
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
@ -121,7 +121,7 @@ writen (int fd, const void *buf, size_t nbytes)
nleft -= nwritten; nleft -= nwritten;
buf = (const char*)buf + nwritten; buf = (const char*)buf + nwritten;
} }
return 0; return 0;
} }
@ -155,7 +155,7 @@ readline (int fd, char *buf, size_t buflen)
nleft -= n; nleft -= n;
buf += n; buf += n;
nread += n; nread += n;
for (; n && *p != '\n'; n--, p++) for (; n && *p != '\n'; n--, p++)
; ;
if (n) if (n)
@ -166,7 +166,7 @@ readline (int fd, char *buf, size_t buflen)
} }
} }
return nread; return nread;
} }
@ -177,8 +177,8 @@ agent_send_option (int fd, const char *name, const char *value)
char buf[200]; char buf[200];
int nread; int nread;
char *line; char *line;
int i; int i;
line = spwq_malloc (7 + strlen (name) + 1 + strlen (value) + 2); line = spwq_malloc (7 + strlen (name) + 1 + strlen (value) + 2);
if (!line) if (!line)
return SPWQ_OUT_OF_CORE; return SPWQ_OUT_OF_CORE;
@ -188,15 +188,15 @@ agent_send_option (int fd, const char *name, const char *value)
spwq_free (line); spwq_free (line);
if (i) if (i)
return i; return i;
/* get response */ /* get response */
nread = readline (fd, buf, DIM(buf)-1); nread = readline (fd, buf, DIM(buf)-1);
if (nread < 0) if (nread < 0)
return -nread; return -nread;
if (nread < 3) if (nread < 3)
return SPWQ_PROTOCOL_ERROR; return SPWQ_PROTOCOL_ERROR;
if (buf[0] == 'O' && buf[1] == 'K' && (buf[2] == ' ' || buf[2] == '\n')) if (buf[0] == 'O' && buf[1] == 'K' && (buf[2] == ' ' || buf[2] == '\n'))
return 0; /* okay */ return 0; /* okay */
return SPWQ_ERR_RESPONSE; return SPWQ_ERR_RESPONSE;
@ -204,7 +204,7 @@ agent_send_option (int fd, const char *name, const char *value)
/* Send all available options to the agent. */ /* Send all available options to the agent. */
static int static int
agent_send_all_options (int fd) agent_send_all_options (int fd)
{ {
char *dft_display = NULL; char *dft_display = NULL;
@ -239,7 +239,7 @@ agent_send_all_options (int fd)
return rc; return rc;
} }
#if defined(HAVE_SETLOCALE) #if defined(HAVE_SETLOCALE)
{ {
char *old_lc = NULL; char *old_lc = NULL;
char *dft_lc = NULL; char *dft_lc = NULL;
@ -330,9 +330,9 @@ agent_open (int *rfd)
*rfd = -1; *rfd = -1;
infostr = getenv ( "GPG_AGENT_INFO" ); infostr = getenv ( "GPG_AGENT_INFO" );
if ( !infostr || !*infostr ) if ( !infostr || !*infostr )
infostr = default_gpg_agent_info; infostr = default_gpg_agent_info;
if ( !infostr || !*infostr ) if ( !infostr || !*infostr )
{ {
#ifdef SPWQ_USE_LOGGING #ifdef SPWQ_USE_LOGGING
log_error (_("gpg-agent is not available in this session\n")); log_error (_("gpg-agent is not available in this session\n"));
@ -346,7 +346,7 @@ agent_open (int *rfd)
infostr = p; infostr = p;
if ( !(p = strchr ( infostr, PATHSEP_C)) || p == infostr if ( !(p = strchr ( infostr, PATHSEP_C)) || p == infostr
|| (p-infostr)+1 >= sizeof client_addr.sun_path ) || (p-infostr)+1 >= sizeof client_addr.sun_path )
{ {
#ifdef SPWQ_USE_LOGGING #ifdef SPWQ_USE_LOGGING
log_error ( _("malformed GPG_AGENT_INFO environment variable\n")); log_error ( _("malformed GPG_AGENT_INFO environment variable\n"));
@ -366,25 +366,25 @@ agent_open (int *rfd)
return SPWQ_PROTOCOL_ERROR; return SPWQ_PROTOCOL_ERROR;
} }
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
fd = _w32_sock_new (AF_UNIX, SOCK_STREAM, 0); fd = _w32_sock_new (AF_UNIX, SOCK_STREAM, 0);
#else #else
fd = socket (AF_UNIX, SOCK_STREAM, 0); fd = socket (AF_UNIX, SOCK_STREAM, 0);
#endif #endif
if (fd == -1) if (fd == -1)
{ {
#ifdef SPWQ_USE_LOGGING #ifdef SPWQ_USE_LOGGING
log_error ("can't create socket: %s\n", strerror(errno) ); log_error ("can't create socket: %s\n", strerror(errno) );
#endif #endif
return SPWQ_SYS_ERROR; return SPWQ_SYS_ERROR;
} }
memset (&client_addr, 0, sizeof client_addr); memset (&client_addr, 0, sizeof client_addr);
client_addr.sun_family = AF_UNIX; client_addr.sun_family = AF_UNIX;
strcpy (client_addr.sun_path, infostr); strcpy (client_addr.sun_path, infostr);
len = SUN_LEN (&client_addr); len = SUN_LEN (&client_addr);
#ifdef HAVE_W32_SYSTEM #ifdef HAVE_W32_SYSTEM
rc = _w32_sock_connect (fd, (struct sockaddr*)&client_addr, len ); rc = _w32_sock_connect (fd, (struct sockaddr*)&client_addr, len );
#else #else
rc = connect (fd, (struct sockaddr*)&client_addr, len ); rc = connect (fd, (struct sockaddr*)&client_addr, len );
@ -400,7 +400,7 @@ agent_open (int *rfd)
nread = readline (fd, line, DIM(line)); nread = readline (fd, line, DIM(line));
if (nread < 3 || !(line[0] == 'O' && line[1] == 'K' if (nread < 3 || !(line[0] == 'O' && line[1] == 'K'
&& (line[2] == '\n' || line[2] == ' ')) ) && (line[2] == '\n' || line[2] == ' ')) )
{ {
#ifdef SPWQ_USE_LOGGING #ifdef SPWQ_USE_LOGGING
log_error ( _("communication problem with gpg-agent\n")); log_error ( _("communication problem with gpg-agent\n"));
@ -434,7 +434,7 @@ copy_and_escape (char *buffer, const char *text)
int i; int i;
const unsigned char *s = (unsigned char *)text; const unsigned char *s = (unsigned char *)text;
char *p = buffer; char *p = buffer;
for (i=0; s[i]; i++) for (i=0; s[i]; i++)
{ {
@ -453,7 +453,7 @@ copy_and_escape (char *buffer, const char *text)
/* Set the name of the default socket to NAME. */ /* Set the name of the default socket to NAME. */
int int
simple_pw_set_socket (const char *name) simple_pw_set_socket (const char *name)
{ {
spwq_free (default_gpg_agent_info); spwq_free (default_gpg_agent_info);
@ -482,7 +482,7 @@ simple_pw_set_socket (const char *name)
errorcode; this error code might be 0 if the user canceled the errorcode; this error code might be 0 if the user canceled the
operation. The function returns NULL to indicate an error. */ operation. The function returns NULL to indicate an error. */
char * char *
simple_pwquery (const char *cacheid, simple_pwquery (const char *cacheid,
const char *tryagain, const char *tryagain,
const char *prompt, const char *prompt,
const char *description, const char *description,
@ -494,7 +494,7 @@ simple_pwquery (const char *cacheid,
char *result = NULL; char *result = NULL;
char *pw = NULL; char *pw = NULL;
char *p; char *p;
int rc, i; int rc, i;
rc = agent_open (&fd); rc = agent_open (&fd);
if (rc) if (rc)
@ -555,11 +555,11 @@ simple_pwquery (const char *cacheid,
rc = SPWQ_PROTOCOL_ERROR; rc = SPWQ_PROTOCOL_ERROR;
goto leave; goto leave;
} }
if (pw[0] == 'O' && pw[1] == 'K' && pw[2] == ' ') if (pw[0] == 'O' && pw[1] == 'K' && pw[2] == ' ')
{ /* we got a passphrase - convert it back from hex */ { /* we got a passphrase - convert it back from hex */
size_t pwlen = 0; size_t pwlen = 0;
for (i=3; i < nread && hexdigitp (pw+i); i+=2) for (i=3; i < nread && hexdigitp (pw+i); i+=2)
pw[pwlen++] = xtoi_2 (pw+i); pw[pwlen++] = xtoi_2 (pw+i);
pw[pwlen] = 0; /* make a C String */ pw[pwlen] = 0; /* make a C String */
@ -569,7 +569,7 @@ simple_pwquery (const char *cacheid,
else if ((nread > 7 && !memcmp (pw, "ERR 111", 7) else if ((nread > 7 && !memcmp (pw, "ERR 111", 7)
&& (pw[7] == ' ' || pw[7] == '\n') ) && (pw[7] == ' ' || pw[7] == '\n') )
|| ((nread > 4 && !memcmp (pw, "ERR ", 4) || ((nread > 4 && !memcmp (pw, "ERR ", 4)
&& (strtoul (pw+4, NULL, 0) & 0xffff) == 99)) ) && (strtoul (pw+4, NULL, 0) & 0xffff) == 99)) )
{ {
/* 111 is the old Assuan code for canceled which might still /* 111 is the old Assuan code for canceled which might still
be in use by old installations. 99 is GPG_ERR_CANCELED as be in use by old installations. 99 is GPG_ERR_CANCELED as
@ -588,14 +588,14 @@ simple_pwquery (const char *cacheid,
default: rc = SPWQ_GENERAL_ERROR; break; default: rc = SPWQ_GENERAL_ERROR; break;
} }
} }
else else
{ {
#ifdef SPWQ_USE_LOGGING #ifdef SPWQ_USE_LOGGING
log_error (_("problem with the agent\n")); log_error (_("problem with the agent\n"));
#endif #endif
rc = SPWQ_ERR_RESPONSE; rc = SPWQ_ERR_RESPONSE;
} }
leave: leave:
if (errorcode) if (errorcode)
*errorcode = rc; *errorcode = rc;
@ -659,13 +659,13 @@ simple_query (const char *query)
rc = SPWQ_PROTOCOL_ERROR; rc = SPWQ_PROTOCOL_ERROR;
goto leave; goto leave;
} }
if (response[0] == 'O' && response[1] == 'K') if (response[0] == 'O' && response[1] == 'K')
/* OK, do nothing. */; /* OK, do nothing. */;
else if ((nread > 7 && !memcmp (response, "ERR 111", 7) else if ((nread > 7 && !memcmp (response, "ERR 111", 7)
&& (response[7] == ' ' || response[7] == '\n') ) && (response[7] == ' ' || response[7] == '\n') )
|| ((nread > 4 && !memcmp (response, "ERR ", 4) || ((nread > 4 && !memcmp (response, "ERR ", 4)
&& (strtoul (response+4, NULL, 0) & 0xffff) == 99)) ) && (strtoul (response+4, NULL, 0) & 0xffff) == 99)) )
{ {
/* 111 is the old Assuan code for canceled which might still /* 111 is the old Assuan code for canceled which might still
be in use by old installations. 99 is GPG_ERR_CANCELED as be in use by old installations. 99 is GPG_ERR_CANCELED as
@ -675,14 +675,14 @@ simple_query (const char *query)
log_info (_("canceled by user\n") ); log_info (_("canceled by user\n") );
#endif #endif
} }
else else
{ {
#ifdef SPWQ_USE_LOGGING #ifdef SPWQ_USE_LOGGING
log_error (_("problem with the agent\n")); log_error (_("problem with the agent\n"));
#endif #endif
rc = SPWQ_ERR_RESPONSE; rc = SPWQ_ERR_RESPONSE;
} }
leave: leave:
if (fd != -1) if (fd != -1)
close (fd); close (fd);

View File

@ -50,7 +50,7 @@
If ERRORCODE is not NULL it should point a variable receiving an If ERRORCODE is not NULL it should point a variable receiving an
errorcode; this errocode might be 0 if the user canceled the errorcode; this errocode might be 0 if the user canceled the
operation. The function returns NULL to indicate an error. */ operation. The function returns NULL to indicate an error. */
char *simple_pwquery (const char *cacheid, char *simple_pwquery (const char *cacheid,
const char *tryagain, const char *tryagain,
const char *prompt, const char *prompt,
const char *description, const char *description,
@ -71,7 +71,7 @@ int simple_pw_set_socket (const char *name);
#define SPWQ_OUT_OF_CORE 1 #define SPWQ_OUT_OF_CORE 1
#define SPWQ_IO_ERROR 2 #define SPWQ_IO_ERROR 2
#define SPWQ_PROTOCOL_ERROR 3 #define SPWQ_PROTOCOL_ERROR 3
#define SPWQ_ERR_RESPONSE 4 #define SPWQ_ERR_RESPONSE 4
#define SPWQ_NO_AGENT 5 #define SPWQ_NO_AGENT 5
#define SPWQ_SYS_ERROR 6 #define SPWQ_SYS_ERROR 6
@ -108,8 +108,8 @@ int simple_pw_set_socket (const char *name);
default: \ default: \
return gpg_error (GPG_ERR_GENERAL); \ return gpg_error (GPG_ERR_GENERAL); \
} \ } \
} }
/* End of MAP_SPWQ_ERROR_IMPL. */ /* End of MAP_SPWQ_ERROR_IMPL. */
#endif /*SIMPLE_PWQUERY_H*/ #endif /*SIMPLE_PWQUERY_H*/

View File

@ -72,7 +72,7 @@ getsrv (const char *name,struct srventry **list)
{ {
adns_state state; adns_state state;
adns_answer *answer = NULL; adns_answer *answer = NULL;
rc = adns_init (&state, adns_if_noerrprint, NULL); rc = adns_init (&state, adns_if_noerrprint, NULL);
if (rc) if (rc)
{ {
@ -88,7 +88,7 @@ getsrv (const char *name,struct srventry **list)
adns_finish (state); adns_finish (state);
return -1; return -1;
} }
if (answer->status != adns_s_ok if (answer->status != adns_s_ok
|| answer->type != adns_r_srv || !answer->nrrs) || answer->type != adns_r_srv || !answer->nrrs)
{ {
log_error ("DNS query returned an error or no records: %s (%s)\n", log_error ("DNS query returned an error or no records: %s (%s)\n",
@ -109,7 +109,7 @@ getsrv (const char *name,struct srventry **list)
log_info ("hostname in SRV record too long - skipped\n"); log_info ("hostname in SRV record too long - skipped\n");
continue; continue;
} }
newlist = xtryrealloc (*list, (srvcount+1)*sizeof(struct srventry)); newlist = xtryrealloc (*list, (srvcount+1)*sizeof(struct srventry));
if (!newlist) if (!newlist)
goto fail; goto fail;
@ -117,7 +117,7 @@ getsrv (const char *name,struct srventry **list)
memset (&(*list)[srvcount], 0, sizeof(struct srventry)); memset (&(*list)[srvcount], 0, sizeof(struct srventry));
srv = &(*list)[srvcount]; srv = &(*list)[srvcount];
srvcount++; srvcount++;
srv->priority = answer->rrs.srvha[count].priority; srv->priority = answer->rrs.srvha[count].priority;
srv->weight = answer->rrs.srvha[count].weight; srv->weight = answer->rrs.srvha[count].weight;
srv->port = answer->rrs.srvha[count].port; srv->port = answer->rrs.srvha[count].port;
@ -134,29 +134,29 @@ getsrv (const char *name,struct srventry **list)
unsigned char *pt, *emsg; unsigned char *pt, *emsg;
int r; int r;
u16 dlen; u16 dlen;
r = res_query (name, C_IN, T_SRV, answer, sizeof answer); r = res_query (name, C_IN, T_SRV, answer, sizeof answer);
if (r < sizeof (HEADER) || r > sizeof answer) if (r < sizeof (HEADER) || r > sizeof answer)
return -1; return -1;
if (header->rcode != NOERROR || !(count=ntohs (header->ancount))) if (header->rcode != NOERROR || !(count=ntohs (header->ancount)))
return 0; /* Error or no record found. */ return 0; /* Error or no record found. */
emsg = &answer[r]; emsg = &answer[r];
pt = &answer[sizeof(HEADER)]; pt = &answer[sizeof(HEADER)];
/* Skip over the query */ /* Skip over the query */
rc = dn_skipname (pt, emsg); rc = dn_skipname (pt, emsg);
if (rc == -1) if (rc == -1)
goto fail; goto fail;
pt += rc + QFIXEDSZ; pt += rc + QFIXEDSZ;
while (count-- > 0 && pt < emsg) while (count-- > 0 && pt < emsg)
{ {
struct srventry *srv=NULL; struct srventry *srv=NULL;
u16 type,class; u16 type,class;
struct srventry *newlist; struct srventry *newlist;
newlist = xtryrealloc (*list, (srvcount+1)*sizeof(struct srventry)); newlist = xtryrealloc (*list, (srvcount+1)*sizeof(struct srventry));
if (!newlist) if (!newlist)
goto fail; goto fail;
@ -164,28 +164,28 @@ getsrv (const char *name,struct srventry **list)
memset(&(*list)[srvcount],0,sizeof(struct srventry)); memset(&(*list)[srvcount],0,sizeof(struct srventry));
srv=&(*list)[srvcount]; srv=&(*list)[srvcount];
srvcount++; srvcount++;
rc = dn_skipname(pt,emsg); /* the name we just queried for */ rc = dn_skipname(pt,emsg); /* the name we just queried for */
if (rc == -1) if (rc == -1)
goto fail; goto fail;
pt+=rc; pt+=rc;
/* Truncated message? */ /* Truncated message? */
if((emsg-pt)<16) if((emsg-pt)<16)
goto fail; goto fail;
type=*pt++ << 8; type=*pt++ << 8;
type|=*pt++; type|=*pt++;
/* We asked for SRV and got something else !? */ /* We asked for SRV and got something else !? */
if(type!=T_SRV) if(type!=T_SRV)
goto fail; goto fail;
class=*pt++ << 8; class=*pt++ << 8;
class|=*pt++; class|=*pt++;
/* We asked for IN and got something else !? */ /* We asked for IN and got something else !? */
if(class!=C_IN) if(class!=C_IN)
goto fail; goto fail;
pt+=4; /* ttl */ pt+=4; /* ttl */
dlen=*pt++ << 8; dlen=*pt++ << 8;
dlen|=*pt++; dlen|=*pt++;
@ -195,7 +195,7 @@ getsrv (const char *name,struct srventry **list)
srv->weight|=*pt++; srv->weight|=*pt++;
srv->port=*pt++ << 8; srv->port=*pt++ << 8;
srv->port|=*pt++; srv->port|=*pt++;
/* Get the name. 2782 doesn't allow name compression, but /* Get the name. 2782 doesn't allow name compression, but
dn_expand still works to pull the name out of the dn_expand still works to pull the name out of the
packet. */ packet. */
@ -215,17 +215,17 @@ getsrv (const char *name,struct srventry **list)
} }
} }
#endif /*!USE_ADNS*/ #endif /*!USE_ADNS*/
/* Now we have an array of all the srv records. */ /* Now we have an array of all the srv records. */
/* Order by priority */ /* Order by priority */
qsort(*list,srvcount,sizeof(struct srventry),priosort); qsort(*list,srvcount,sizeof(struct srventry),priosort);
/* For each priority, move the zero-weighted items first. */ /* For each priority, move the zero-weighted items first. */
for (i=0; i < srvcount; i++) for (i=0; i < srvcount; i++)
{ {
int j; int j;
for (j=i;j < srvcount && (*list)[i].priority == (*list)[j].priority; j++) for (j=i;j < srvcount && (*list)[i].priority == (*list)[j].priority; j++)
{ {
if((*list)[j].weight==0) if((*list)[j].weight==0)
@ -234,12 +234,12 @@ getsrv (const char *name,struct srventry **list)
if(j!=i) if(j!=i)
{ {
struct srventry temp; struct srventry temp;
memcpy (&temp,&(*list)[j],sizeof(struct srventry)); memcpy (&temp,&(*list)[j],sizeof(struct srventry));
memcpy (&(*list)[j],&(*list)[i],sizeof(struct srventry)); memcpy (&(*list)[j],&(*list)[i],sizeof(struct srventry));
memcpy (&(*list)[i],&temp,sizeof(struct srventry)); memcpy (&(*list)[i],&temp,sizeof(struct srventry));
} }
break; break;
} }
} }
@ -255,15 +255,15 @@ getsrv (const char *name,struct srventry **list)
{ {
int j; int j;
float prio_count=0,chose; float prio_count=0,chose;
for (j=i; j < srvcount && (*list)[i].priority == (*list)[j].priority; j++) for (j=i; j < srvcount && (*list)[i].priority == (*list)[j].priority; j++)
{ {
prio_count+=(*list)[j].weight; prio_count+=(*list)[j].weight;
(*list)[j].run_count=prio_count; (*list)[j].run_count=prio_count;
} }
chose=prio_count*rand()/RAND_MAX; chose=prio_count*rand()/RAND_MAX;
for (j=i;j<srvcount && (*list)[i].priority==(*list)[j].priority;j++) for (j=i;j<srvcount && (*list)[i].priority==(*list)[j].priority;j++)
{ {
if (chose<=(*list)[j].run_count) if (chose<=(*list)[j].run_count)
@ -272,7 +272,7 @@ getsrv (const char *name,struct srventry **list)
if(j!=i) if(j!=i)
{ {
struct srventry temp; struct srventry temp;
memcpy(&temp,&(*list)[j],sizeof(struct srventry)); memcpy(&temp,&(*list)[j],sizeof(struct srventry));
memcpy(&(*list)[j],&(*list)[i],sizeof(struct srventry)); memcpy(&(*list)[j],&(*list)[i],sizeof(struct srventry));
memcpy(&(*list)[i],&temp,sizeof(struct srventry)); memcpy(&(*list)[i],&temp,sizeof(struct srventry));
@ -281,7 +281,7 @@ getsrv (const char *name,struct srventry **list)
} }
} }
} }
return srvcount; return srvcount;
fail: fail:

View File

@ -27,7 +27,7 @@
/* Return the status string for code NO. */ /* Return the status string for code NO. */
const char * const char *
get_status_string ( int no ) get_status_string ( int no )
{ {
int idx = statusstr_msgidxof (no); int idx = statusstr_msgidxof (no);
if (idx == -1) if (idx == -1)
@ -41,7 +41,7 @@ const char *
get_inv_recpsgnr_code (gpg_error_t err) get_inv_recpsgnr_code (gpg_error_t err)
{ {
const char *errstr; const char *errstr;
switch (gpg_err_code (err)) switch (gpg_err_code (err))
{ {
case GPG_ERR_NO_PUBKEY: errstr = "1"; break; case GPG_ERR_NO_PUBKEY: errstr = "1"; break;

View File

@ -230,7 +230,7 @@ length_sans_trailing_chars (const unsigned char *line, size_t len,
{ {
const unsigned char *p, *mark; const unsigned char *p, *mark;
size_t n; size_t n;
for( mark=NULL, p=line, n=0; n < len; n++, p++ ) for( mark=NULL, p=line, n=0; n < len; n++, p++ )
{ {
if (strchr (trimchars, *p )) if (strchr (trimchars, *p ))
@ -241,8 +241,8 @@ length_sans_trailing_chars (const unsigned char *line, size_t len,
else else
mark = NULL; mark = NULL;
} }
if (mark) if (mark)
return mark - line; return mark - line;
return len; return len;
} }
@ -363,16 +363,16 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
{ {
const char *argv[32]; const char *argv[32];
int argc; int argc;
size_t n; size_t n;
int skip = 1; int skip = 1;
char *home_buffer = NULL; char *home_buffer = NULL;
char *name, *home, *p; char *name, *home, *p;
n = strlen (first_part) + 1; n = strlen (first_part) + 1;
argc = 0; argc = 0;
while ( (argv[argc] = va_arg (arg_ptr, const char *)) ) while ( (argv[argc] = va_arg (arg_ptr, const char *)) )
{ {
n += strlen (argv[argc]) + 1; n += strlen (argv[argc]) + 1;
if (argc >= DIM (argv)-1) if (argc >= DIM (argv)-1)
{ {
if (xmode) if (xmode)
@ -380,11 +380,11 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
jnlib_set_errno (EINVAL); jnlib_set_errno (EINVAL);
return NULL; return NULL;
} }
argc++; argc++;
} }
n++; n++;
home = NULL; home = NULL;
if (*first_part == '~') if (*first_part == '~')
{ {
if (first_part[1] == '/' || !first_part[1]) if (first_part[1] == '/' || !first_part[1])
@ -394,13 +394,13 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
if (!home) if (!home)
home = home_buffer = get_pwdir (xmode, NULL); home = home_buffer = get_pwdir (xmode, NULL);
if (home && *home) if (home && *home)
n += strlen (home); n += strlen (home);
} }
else else
{ {
/* This is the "~username/" or "~username" case. */ /* This is the "~username/" or "~username" case. */
char *user; char *user;
if (xmode) if (xmode)
user = jnlib_xstrdup (first_part+1); user = jnlib_xstrdup (first_part+1);
else else
@ -413,7 +413,7 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
if (p) if (p)
*p = 0; *p = 0;
skip = 1 + strlen (user); skip = 1 + strlen (user);
home = home_buffer = get_pwdir (xmode, user); home = home_buffer = get_pwdir (xmode, user);
jnlib_free (user); jnlib_free (user);
if (home) if (home)
@ -434,7 +434,7 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
return NULL; return NULL;
} }
} }
if (home) if (home)
p = stpcpy (stpcpy (name, home), first_part + skip); p = stpcpy (stpcpy (name, home), first_part + skip);
else else
@ -489,9 +489,9 @@ int
compare_filenames (const char *a, const char *b) compare_filenames (const char *a, const char *b)
{ {
#ifdef HAVE_DOSISH_SYSTEM #ifdef HAVE_DOSISH_SYSTEM
for ( ; *a && *b; a++, b++ ) for ( ; *a && *b; a++, b++ )
{ {
if (*a != *b if (*a != *b
&& (toupper (*(const unsigned char*)a) && (toupper (*(const unsigned char*)a)
!= toupper (*(const unsigned char*)b) ) != toupper (*(const unsigned char*)b) )
&& !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/'))) && !((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')))
@ -500,7 +500,7 @@ compare_filenames (const char *a, const char *b)
if ((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/')) if ((*a == '/' && *b == '\\') || (*a == '\\' && *b == '/'))
return 0; return 0;
else else
return (toupper (*(const unsigned char*)a) return (toupper (*(const unsigned char*)a)
- toupper (*(const unsigned char*)b)); - toupper (*(const unsigned char*)b));
#else #else
return strcmp(a,b); return strcmp(a,b);
@ -539,7 +539,7 @@ hextobyte (const char *s)
/* Print a BUFFER to stream FP while replacing all control characters /* Print a BUFFER to stream FP while replacing all control characters
and the characters DELIM and DELIM2 with standard C escape and the characters DELIM and DELIM2 with standard C escape
sequences. Returns the number of characters printed. */ sequences. Returns the number of characters printed. */
size_t size_t
print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length, print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length,
int delim, int delim2) int delim, int delim2)
{ {
@ -548,9 +548,9 @@ print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length,
for (; length; length--, p++, count++) for (; length; length--, p++, count++)
{ {
if (*p < 0x20 if (*p < 0x20
|| *p == 0x7f || *p == 0x7f
|| *p == delim || *p == delim
|| *p == delim2 || *p == delim2
|| ((delim || delim2) && *p=='\\')) || ((delim || delim2) && *p=='\\'))
{ {
@ -603,7 +603,7 @@ print_sanitized_buffer2 (FILE *fp, const void *buffer, size_t length,
} }
/* Same as print_sanitized_buffer2 but with just one delimiter. */ /* Same as print_sanitized_buffer2 but with just one delimiter. */
size_t size_t
print_sanitized_buffer (FILE *fp, const void *buffer, size_t length, print_sanitized_buffer (FILE *fp, const void *buffer, size_t length,
int delim) int delim)
{ {
@ -611,7 +611,7 @@ print_sanitized_buffer (FILE *fp, const void *buffer, size_t length,
} }
size_t size_t
print_sanitized_utf8_buffer (FILE *fp, const void *buffer, print_sanitized_utf8_buffer (FILE *fp, const void *buffer,
size_t length, int delim) size_t length, int delim)
{ {
@ -619,7 +619,7 @@ print_sanitized_utf8_buffer (FILE *fp, const void *buffer,
size_t i; size_t i;
/* We can handle plain ascii simpler, so check for it first. */ /* We can handle plain ascii simpler, so check for it first. */
for (i=0; i < length; i++ ) for (i=0; i < length; i++ )
{ {
if ( (p[i] & 0x80) ) if ( (p[i] & 0x80) )
break; break;
@ -638,20 +638,20 @@ print_sanitized_utf8_buffer (FILE *fp, const void *buffer,
} }
size_t size_t
print_sanitized_string2 (FILE *fp, const char *string, int delim, int delim2) print_sanitized_string2 (FILE *fp, const char *string, int delim, int delim2)
{ {
return string? print_sanitized_buffer2 (fp, string, strlen (string), return string? print_sanitized_buffer2 (fp, string, strlen (string),
delim, delim2):0; delim, delim2):0;
} }
size_t size_t
print_sanitized_string (FILE *fp, const char *string, int delim) print_sanitized_string (FILE *fp, const char *string, int delim)
{ {
return string? print_sanitized_buffer (fp, string, strlen (string), delim):0; return string? print_sanitized_buffer (fp, string, strlen (string), delim):0;
} }
size_t size_t
print_sanitized_utf8_string (FILE *fp, const char *string, int delim) print_sanitized_utf8_string (FILE *fp, const char *string, int delim)
{ {
return string? print_sanitized_utf8_buffer (fp, return string? print_sanitized_utf8_buffer (fp,
@ -671,7 +671,7 @@ sanitize_buffer (const void *p_arg, size_t n, int delim)
char *buffer, *d; char *buffer, *d;
/* First count length. */ /* First count length. */
for (save_n = n, save_p = p, buflen=1 ; n; n--, p++ ) for (save_n = n, save_p = p, buflen=1 ; n; n--, p++ )
{ {
if ( *p < 0x20 || *p == 0x7f || *p == delim || (delim && *p=='\\')) if ( *p < 0x20 || *p == 0x7f || *p == delim || (delim && *p=='\\'))
{ {
@ -743,7 +743,7 @@ const char *
w32_strerror (int ec) w32_strerror (int ec)
{ {
static char strerr[256]; static char strerr[256];
if (ec == -1) if (ec == -1)
ec = (int)GetLastError (); ec = (int)GetLastError ();
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
@ -755,7 +755,7 @@ w32_strerror (int ec)
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
strerr, DIM (strerr)-1, NULL); strerr, DIM (strerr)-1, NULL);
#endif #endif
return strerr; return strerr;
} }
#endif /*HAVE_W32_SYSTEM*/ #endif /*HAVE_W32_SYSTEM*/
@ -776,7 +776,7 @@ ascii_islower (int c)
return c >= 'a' && c <= 'z'; return c >= 'a' && c <= 'z';
} }
int int
ascii_toupper (int c) ascii_toupper (int c)
{ {
if (c >= 'a' && c <= 'z') if (c >= 'a' && c <= 'z')
@ -784,7 +784,7 @@ ascii_toupper (int c)
return c; return c;
} }
int int
ascii_tolower (int c) ascii_tolower (int c)
{ {
if (c >= 'A' && c <= 'Z') if (c >= 'A' && c <= 'Z')
@ -806,7 +806,7 @@ ascii_strcasecmp( const char *a, const char *b )
return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b)); return *a == *b? 0 : (ascii_toupper (*a) - ascii_toupper (*b));
} }
int int
ascii_strncasecmp (const char *a, const char *b, size_t n) ascii_strncasecmp (const char *a, const char *b, size_t n)
{ {
const unsigned char *p1 = (const unsigned char *)a; const unsigned char *p1 = (const unsigned char *)a;
@ -828,7 +828,7 @@ ascii_strncasecmp (const char *a, const char *b, size_t n)
++p2; ++p2;
} }
while (c1 == c2); while (c1 == c2);
return c1 - c2; return c1 - c2;
} }
@ -874,7 +874,7 @@ ascii_memcasemem (const void *haystack, size_t nhaystack,
{ {
const char *a = haystack; const char *a = haystack;
const char *b = a + nhaystack - nneedle; const char *b = a + nhaystack - nneedle;
for (; a <= b; a++) for (; a <= b; a++)
{ {
if ( !ascii_memcasecmp (a, needle, nneedle) ) if ( !ascii_memcasecmp (a, needle, nneedle) )
@ -1152,4 +1152,3 @@ xstrconcat (const char *s1, ...)
} }
return result; return result;
} }

View File

@ -103,7 +103,7 @@ void *memrchr (const void *buffer, int c, size_t n);
#ifndef HAVE_ISASCII #ifndef HAVE_ISASCII
static inline int static inline int
isascii (int c) isascii (int c)
{ {
return (((c) & ~0x7f) == 0); return (((c) & ~0x7f) == 0);

View File

@ -63,7 +63,7 @@ strlist_t
add_to_strlist_try (strlist_t *list, const char *string) add_to_strlist_try (strlist_t *list, const char *string)
{ {
strlist_t sl; strlist_t sl;
sl = jnlib_malloc (sizeof *sl + strlen (string)); sl = jnlib_malloc (sizeof *sl + strlen (string));
if (sl) if (sl)
{ {
@ -84,10 +84,10 @@ strlist_t
add_to_strlist2( strlist_t *list, const char *string, int is_utf8 ) add_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
{ {
strlist_t sl; strlist_t sl;
if (is_utf8) if (is_utf8)
sl = add_to_strlist( list, string ); sl = add_to_strlist( list, string );
else else
{ {
char *p = native_to_utf8( string ); char *p = native_to_utf8( string );
sl = add_to_strlist( list, p ); sl = add_to_strlist( list, p );
@ -125,7 +125,7 @@ strlist_t
append_to_strlist2( strlist_t *list, const char *string, int is_utf8 ) append_to_strlist2( strlist_t *list, const char *string, int is_utf8 )
{ {
strlist_t sl; strlist_t sl;
if( is_utf8 ) if( is_utf8 )
sl = append_to_strlist( list, string ); sl = append_to_strlist( list, string );
else else
@ -201,4 +201,3 @@ strlist_pop (strlist_t *list)
return str; return str;
} }

View File

@ -20,7 +20,7 @@
#ifndef LIBJNLIB_STRLIST_H #ifndef LIBJNLIB_STRLIST_H
#define LIBJNLIB_STRLIST_H #define LIBJNLIB_STRLIST_H
struct string_list struct string_list
{ {
struct string_list *next; struct string_list *next;
unsigned int flags; unsigned int flags;

View File

@ -46,7 +46,7 @@
# define WINVER 0x0500 /* Required for AllowSetForegroundWindow. */ # define WINVER 0x0500 /* Required for AllowSetForegroundWindow. */
# include <windows.h> # include <windows.h>
#endif #endif
#ifdef HAVE_PTH #ifdef HAVE_PTH
# include <pth.h> # include <pth.h>
#endif #endif
#include <fcntl.h> #include <fcntl.h>
@ -140,7 +140,7 @@ get_session_marker (size_t *rlen)
{ {
static byte marker[SIZEOF_UNSIGNED_LONG*2]; static byte marker[SIZEOF_UNSIGNED_LONG*2];
static int initialized; static int initialized;
if (!initialized) if (!initialized)
{ {
gcry_create_nonce (marker, sizeof marker); gcry_create_nonce (marker, sizeof marker);
@ -253,7 +253,7 @@ gnupg_sleep (unsigned int seconds)
the process will give up its timeslot. */ the process will give up its timeslot. */
if (!seconds) if (!seconds)
{ {
# ifdef HAVE_W32_SYSTEM # ifdef HAVE_W32_SYSTEM
Sleep (0); Sleep (0);
# else # else
sleep (0); sleep (0);
@ -262,7 +262,7 @@ gnupg_sleep (unsigned int seconds)
pth_sleep (seconds); pth_sleep (seconds);
#else #else
/* Fixme: make sure that a sleep won't wake up to early. */ /* Fixme: make sure that a sleep won't wake up to early. */
# ifdef HAVE_W32_SYSTEM # ifdef HAVE_W32_SYSTEM
Sleep (seconds*1000); Sleep (seconds*1000);
# else # else
sleep (seconds); sleep (seconds);
@ -287,7 +287,7 @@ translate_sys2libc_fd (gnupg_fd_t fd, int for_write)
if (fd == GNUPG_INVALID_FD) if (fd == GNUPG_INVALID_FD)
return -1; return -1;
/* Note that _open_osfhandle is currently defined to take and return /* Note that _open_osfhandle is currently defined to take and return
a long. */ a long. */
x = _open_osfhandle ((long)fd, for_write ? 1 : 0); x = _open_osfhandle ((long)fd, for_write ? 1 : 0);
@ -437,7 +437,7 @@ gnupg_tmpfile (void)
Must be called before we open any files! */ Must be called before we open any files! */
void void
gnupg_reopen_std (const char *pgmname) gnupg_reopen_std (const char *pgmname)
{ {
#if defined(HAVE_STAT) && !defined(HAVE_W32_SYSTEM) #if defined(HAVE_STAT) && !defined(HAVE_W32_SYSTEM)
struct stat statbuf; struct stat statbuf;
int did_stdin = 0; int did_stdin = 0;
@ -452,7 +452,7 @@ gnupg_reopen_std (const char *pgmname)
else else
did_stdin = 2; did_stdin = 2;
} }
if (fstat (STDOUT_FILENO, &statbuf) == -1 && errno == EBADF) if (fstat (STDOUT_FILENO, &statbuf) == -1 && errno == EBADF)
{ {
if (open ("/dev/null",O_WRONLY) == STDOUT_FILENO) if (open ("/dev/null",O_WRONLY) == STDOUT_FILENO)
@ -501,7 +501,7 @@ gnupg_reopen_std (const char *pgmname)
/* Hack required for Windows. */ /* Hack required for Windows. */
void void
gnupg_allow_set_foregound_window (pid_t pid) gnupg_allow_set_foregound_window (pid_t pid)
{ {
if (!pid) if (!pid)
@ -543,7 +543,7 @@ gnupg_remove (const char *fname)
defined on all systems. The format of the modestring is defined on all systems. The format of the modestring is
"-rwxrwxrwx" "-rwxrwxrwx"
'-' is a don't care or not set. 'r', 'w', 'x' are read allowed, '-' is a don't care or not set. 'r', 'w', 'x' are read allowed,
write allowed, execution allowed with the first group for the user, write allowed, execution allowed with the first group for the user,
the second for the group and the third for all others. If the the second for the group and the third for all others. If the
@ -555,7 +555,7 @@ gnupg_mkdir (const char *name, const char *modestr)
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
wchar_t *wname; wchar_t *wname;
(void)modestr; (void)modestr;
wname = utf8_to_wchar (name); wname = utf8_to_wchar (name);
if (!wname) if (!wname)
return -1; return -1;
@ -615,7 +615,7 @@ gnupg_setenv (const char *name, const char *value, int overwrite)
#endif #endif
} }
int int
gnupg_unsetenv (const char *name) gnupg_unsetenv (const char *name)
{ {
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
@ -633,7 +633,7 @@ gnupg_unsetenv (const char *name)
#ifdef HAVE_W32CE_SYSTEM #ifdef HAVE_W32CE_SYSTEM
/* There is a isatty function declaration in cegcc but it does not /* There is a isatty function declaration in cegcc but it does not
make sense, thus we redefine it. */ make sense, thus we redefine it. */
int int
_gnupg_isatty (int fd) _gnupg_isatty (int fd)
{ {
(void)fd; (void)fd;
@ -651,10 +651,10 @@ _gnupg_getenv (const char *name)
{ {
static int initialized; static int initialized;
static char *assuan_debug; static char *assuan_debug;
if (!initialized) if (!initialized)
{ {
assuan_debug = read_w32_registry_string (NULL, assuan_debug = read_w32_registry_string (NULL,
"\\Software\\GNU\\libassuan", "\\Software\\GNU\\libassuan",
"debug"); "debug");
initialized = 1; initialized = 1;
@ -667,4 +667,3 @@ _gnupg_getenv (const char *name)
} }
#endif /*HAVE_W32CE_SYSTEM*/ #endif /*HAVE_W32CE_SYSTEM*/

View File

@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>. * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/ */
/* /*
As of now this is only a test program for manual tests. As of now this is only a test program for manual tests.
@ -179,4 +179,3 @@ main (int argc, char **argv)
return !!errcount; return !!errcount;
} }

View File

@ -72,8 +72,8 @@ test_hex2bin (void)
unsigned char buffer[20]; unsigned char buffer[20];
int len; int len;
int i; int i;
for (i=0; valid[i]; i++) for (i=0; valid[i]; i++)
{ {
len = hex2bin (valid[i], buffer, sizeof buffer); len = hex2bin (valid[i], buffer, sizeof buffer);
@ -87,7 +87,7 @@ test_hex2bin (void)
fail (0); fail (0);
if (hex2bin (valid[2], buffer, sizeof buffer) != 41) if (hex2bin (valid[2], buffer, sizeof buffer) != 41)
fail (0); fail (0);
for (i=0; invalid[i]; i++) for (i=0; invalid[i]; i++)
{ {
len = hex2bin (invalid[i], buffer, sizeof buffer); len = hex2bin (invalid[i], buffer, sizeof buffer);
@ -107,7 +107,7 @@ test_hex2bin (void)
fail (0); fail (0);
if (hex2bin (valid2[1], buffer, 1) != 3) if (hex2bin (valid2[1], buffer, 1) != 3)
fail (0); fail (0);
for (i=0; invalid2[i]; i++) for (i=0; invalid2[i]; i++)
{ {
len = hex2bin (invalid2[i], buffer, 1); len = hex2bin (invalid2[i], buffer, 1);
@ -164,8 +164,8 @@ test_hexcolon2bin (void)
unsigned char buffer[20]; unsigned char buffer[20];
int len; int len;
int i; int i;
for (i=0; valid[i]; i++) for (i=0; valid[i]; i++)
{ {
len = hexcolon2bin (valid[i], buffer, sizeof buffer); len = hexcolon2bin (valid[i], buffer, sizeof buffer);
@ -179,7 +179,7 @@ test_hexcolon2bin (void)
fail (0); fail (0);
if (hexcolon2bin (valid[3], buffer, sizeof buffer) != 41) if (hexcolon2bin (valid[3], buffer, sizeof buffer) != 41)
fail (0); fail (0);
for (i=0; invalid[i]; i++) for (i=0; invalid[i]; i++)
{ {
len = hexcolon2bin (invalid[i], buffer, sizeof buffer); len = hexcolon2bin (invalid[i], buffer, sizeof buffer);
@ -199,7 +199,7 @@ test_hexcolon2bin (void)
fail (0); fail (0);
if (hexcolon2bin (valid2[1], buffer, 1) != 3) if (hexcolon2bin (valid2[1], buffer, 1) != 3)
fail (0); fail (0);
for (i=0; invalid2[i]; i++) for (i=0; invalid2[i]; i++)
{ {
len = hexcolon2bin (invalid2[i], buffer, 1); len = hexcolon2bin (invalid2[i], buffer, 1);
@ -234,10 +234,10 @@ test_bin2hex (void)
fail (0); fail (0);
if (strcmp (p, hexstuff)) if (strcmp (p, hexstuff))
fail (0); fail (0);
p = bin2hex (stuff, (size_t)(-1), NULL); p = bin2hex (stuff, (size_t)(-1), NULL);
if (p) if (p)
fail (0); fail (0);
if (errno != ENOMEM) if (errno != ENOMEM)
fail (1); fail (1);
} }
@ -263,13 +263,13 @@ test_bin2hexcolon (void)
p = bin2hexcolon (stuff, 20, NULL); p = bin2hexcolon (stuff, 20, NULL);
if (!p) if (!p)
fail (0); fail (0);
if (strcmp (p, hexstuff)) if (strcmp (p, hexstuff))
fail (0); fail (0);
p = bin2hexcolon (stuff, (size_t)(-1), NULL); p = bin2hexcolon (stuff, (size_t)(-1), NULL);
if (p) if (p)
fail (0); fail (0);
if (errno != ENOMEM) if (errno != ENOMEM)
fail (1); fail (1);
} }
@ -384,10 +384,10 @@ test_hex2str (void)
for (idx=0; tests[idx].hex; idx++) for (idx=0; tests[idx].hex; idx++)
{ {
char tmpbuf[100]; char tmpbuf[100];
assert (strlen (tests[idx].hex)+1 < sizeof tmpbuf); assert (strlen (tests[idx].hex)+1 < sizeof tmpbuf);
strcpy (tmpbuf, tests[idx].hex); strcpy (tmpbuf, tests[idx].hex);
/* Note: we still need to use 20 as buffer length because our /* Note: we still need to use 20 as buffer length because our
tests assume that. */ tests assume that. */
tail = hex2str (tmpbuf, tmpbuf, 20, &count); tail = hex2str (tmpbuf, tmpbuf, 20, &count);
@ -449,7 +449,7 @@ main (int argc, char **argv)
{ {
(void)argc; (void)argc;
(void)argv; (void)argv;
test_hex2bin (); test_hex2bin ();
test_hexcolon2bin (); test_hexcolon2bin ();
test_bin2hex (); test_bin2hex ();
@ -458,4 +458,3 @@ main (int argc, char **argv)
return 0; return 0;
} }

View File

@ -150,7 +150,7 @@ test_close_all_fds (void)
print_open_fds (array); print_open_fds (array);
free (array); free (array);
} }
/* Check whether the except list works. */ /* Check whether the except list works. */
close_all_fds (3, except); close_all_fds (3, except);
array = xget_all_open_fds (); array = xget_all_open_fds ();
@ -181,9 +181,8 @@ main (int argc, char **argv)
verbose = 1; verbose = 1;
argc--; argv++; argc--; argv++;
} }
test_close_all_fds (); test_close_all_fds ();
return 0; return 0;
} }

View File

@ -68,7 +68,7 @@ test_isotime2epoch (void)
fail (idx); fail (idx);
if (verbose) if (verbose)
fprintf (stderr, "string `%s' exp: %ld got: %ld\n", fprintf (stderr, "string `%s' exp: %ld got: %ld\n",
array[idx].string, (long)array[idx].expected, array[idx].string, (long)array[idx].expected,
(long)val); (long)val);
} }
if (array[idx].expected != INVALID) if (array[idx].expected != INVALID)
@ -100,4 +100,3 @@ main (int argc, char **argv)
return !!errcount; return !!errcount;
} }

View File

@ -52,7 +52,7 @@ main (int argc, char **argv)
result = gnupg_get_help_string (argc? argv[0]:NULL, 0); result = gnupg_get_help_string (argc? argv[0]:NULL, 0);
if (!result) if (!result)
{ {
fprintf (stderr, fprintf (stderr,
"Error: nothing found for `%s'\n", argc?argv[0]:"(null)"); "Error: nothing found for `%s'\n", argc?argv[0]:"(null)");
errcount++; errcount++;
} }
@ -64,4 +64,3 @@ main (int argc, char **argv)
return !!errcount; return !!errcount;
} }

View File

@ -37,31 +37,31 @@ test_percent_plus_escape (void)
const char *string; const char *string;
const char *expect; const char *expect;
} tbl[] = { } tbl[] = {
{ {
"", "",
"" ""
}, { }, {
"a", "a",
"a", "a",
}, { }, {
" ", " ",
"+", "+",
}, { }, {
" ", " ",
"++" "++"
}, { }, {
"+ +", "+ +",
"%2B+%2B" "%2B+%2B"
}, { }, {
"\" \"", "\" \"",
"%22+%22" "%22+%22"
}, { }, {
"%22", "%22",
"%2522" "%2522"
}, { }, {
"%% ", "%% ",
"%25%25+" "%25%25+"
}, { }, {
"\n ABC\t", "\n ABC\t",
"%0A+ABC%09" "%0A+ABC%09"
}, { NULL, NULL } }, { NULL, NULL }
@ -69,7 +69,7 @@ test_percent_plus_escape (void)
char *buf, *buf2; char *buf, *buf2;
int i; int i;
size_t len; size_t len;
for (i=0; tbl[i].string; i++) for (i=0; tbl[i].string; i++)
{ {
buf = percent_plus_escape (tbl[i].string); buf = percent_plus_escape (tbl[i].string);
@ -105,11 +105,10 @@ main (int argc, char **argv)
{ {
(void)argc; (void)argc;
(void)argv; (void)argv;
/* FIXME: We escape_unescape is not tested - only /* FIXME: We escape_unescape is not tested - only
percent_plus_unescape. */ percent_plus_unescape. */
test_percent_plus_escape (); test_percent_plus_escape ();
return 0; return 0;
} }

View File

@ -46,7 +46,7 @@ listall (session_env_t se)
while ( (name = session_env_listenv (se, &iterator, &value, &def)) ) while ( (name = session_env_listenv (se, &iterator, &value, &def)) )
if (verbose) if (verbose)
printf (" %s%s=%s\n", def? "[def] ":" ", name, value); printf (" %s%s=%s\n", def? "[def] ":" ", name, value);
} }
@ -150,7 +150,7 @@ test_all (void)
fprintf (stderr, "failed to get default of HOME\n"); fprintf (stderr, "failed to get default of HOME\n");
exit (1); exit (1);
} }
s = session_env_getenv (se, "HOME"); s = session_env_getenv (se, "HOME");
if (s) if (s)
fail(0); /* This is a default value, thus we should not see it. */ fail(0); /* This is a default value, thus we should not see it. */
@ -194,7 +194,7 @@ test_all (void)
/* Check that the other object is clean. */ /* Check that the other object is clean. */
{ {
int iterator = 0; int iterator = 0;
if (session_env_listenv (se_0, &iterator, NULL, NULL)) if (session_env_listenv (se_0, &iterator, NULL, NULL))
fail (0); fail (0);
} }
@ -211,7 +211,7 @@ test_all (void)
for (idx=0; idx < 500; idx++) for (idx=0; idx < 500; idx++)
{ {
char buf[100]; char buf[100];
snprintf (buf, sizeof buf, "FOO_%d=Value for %x", idx, idx); snprintf (buf, sizeof buf, "FOO_%d=Value for %x", idx, idx);
err = session_env_putenv (se, buf); err = session_env_putenv (se, buf);
if (err) if (err)
@ -230,7 +230,7 @@ test_all (void)
for (idx=0; idx < 500; idx++) for (idx=0; idx < 500; idx++)
{ {
char buf[100]; char buf[100];
snprintf (buf, sizeof buf, "FOO_%d", idx); snprintf (buf, sizeof buf, "FOO_%d", idx);
err = session_env_putenv (se, buf); err = session_env_putenv (se, buf);
if (err) if (err)
@ -243,7 +243,7 @@ test_all (void)
/* Check that all are deleted. */ /* Check that all are deleted. */
{ {
int iterator = 0; int iterator = 0;
if (session_env_listenv (se, &iterator, NULL, NULL)) if (session_env_listenv (se, &iterator, NULL, NULL))
fail (0); fail (0);
} }
@ -252,7 +252,7 @@ test_all (void)
for (idx=0; idx < 500; idx++) for (idx=0; idx < 500; idx++)
{ {
char buf[100]; char buf[100];
if (!(idx % 10)) if (!(idx % 10))
{ {
if ( !(idx % 3)) if ( !(idx % 3))
@ -266,7 +266,7 @@ test_all (void)
} }
listall (se); listall (se);
session_env_release (se); session_env_release (se);
session_env_release (se_0); session_env_release (se_0);
@ -291,4 +291,3 @@ main (int argc, char **argv)
return 0; return 0;
} }

View File

@ -35,7 +35,7 @@ test_hash_algo_from_sigval (void)
{ {
int algo; int algo;
/* A real world example. */ /* A real world example. */
unsigned char example1_rsa_sha1[] = unsigned char example1_rsa_sha1[] =
("\x28\x37\x3A\x73\x69\x67\x2D\x76\x61\x6C\x28\x33\x3A\x72\x73\x61" ("\x28\x37\x3A\x73\x69\x67\x2D\x76\x61\x6C\x28\x33\x3A\x72\x73\x61"
"\x28\x31\x3A\x73\x31\x32\x38\x3A\x17\xD2\xE9\x5F\xB4\x24\xD4\x1E" "\x28\x31\x3A\x73\x31\x32\x38\x3A\x17\xD2\xE9\x5F\xB4\x24\xD4\x1E"
"\x8C\xEE\x94\xDA\x41\x42\x1F\x26\x5E\xF4\x6D\xEC\x5B\xBD\x5B\x89" "\x8C\xEE\x94\xDA\x41\x42\x1F\x26\x5E\xF4\x6D\xEC\x5B\xBD\x5B\x89"
@ -48,7 +48,7 @@ test_hash_algo_from_sigval (void)
"\x27\xAC\x43\x45\xFA\x04\xD1\x22\x29\x29\x28\x34\x3A\x68\x61\x73" "\x27\xAC\x43\x45\xFA\x04\xD1\x22\x29\x29\x28\x34\x3A\x68\x61\x73"
"\x68\x34\x3A\x73\x68\x61\x31\x29\x29"); "\x68\x34\x3A\x73\x68\x61\x31\x29\x29");
/* The same but without the hash algo. */ /* The same but without the hash algo. */
unsigned char example1_rsa[] = unsigned char example1_rsa[] =
("\x28\x37\x3A\x73\x69\x67\x2D\x76\x61\x6C\x28\x33\x3A\x72\x73\x61" ("\x28\x37\x3A\x73\x69\x67\x2D\x76\x61\x6C\x28\x33\x3A\x72\x73\x61"
"\x28\x31\x3A\x73\x31\x32\x38\x3A\x17\xD2\xE9\x5F\xB4\x24\xD4\x1E" "\x28\x31\x3A\x73\x31\x32\x38\x3A\x17\xD2\xE9\x5F\xB4\x24\xD4\x1E"
"\x8C\xEE\x94\xDA\x41\x42\x1F\x26\x5E\xF4\x6D\xEC\x5B\xBD\x5B\x89" "\x8C\xEE\x94\xDA\x41\x42\x1F\x26\x5E\xF4\x6D\xEC\x5B\xBD\x5B\x89"
@ -105,7 +105,7 @@ test_make_canon_sexp_from_rsa_pk (void)
"\x3d\x14\xbb\xea\x63\x65\xa7\xf1\xf2\xf8\x97\x74\xa7\x29\x28\x31" "\x3d\x14\xbb\xea\x63\x65\xa7\xf1\xf2\xf8\x97\x74\xa7\x29\x28\x31"
"\x3a\x65\x34\x3a\x40\x00\x00\x81\x29\x29\x29", "\x3a\x65\x34\x3a\x40\x00\x00\x81\x29\x29\x29",
171 171
}, },
{ {
"\x63\xB4\x12\x48\x08\x48\xC0\x76\xAA\x8E\xF1\xF8\x7F\x5E\x9B\x89", "\x63\xB4\x12\x48\x08\x48\xC0\x76\xAA\x8E\xF1\xF8\x7F\x5E\x9B\x89",
16, 16,
@ -116,7 +116,7 @@ test_make_canon_sexp_from_rsa_pk (void)
"\x48\xc0\x76\xaa\x8e\xf1\xf8\x7f\x5e\x9b\x89\x29\x28\x31\x3a\x65" "\x48\xc0\x76\xaa\x8e\xf1\xf8\x7f\x5e\x9b\x89\x29\x28\x31\x3a\x65"
"\x31\x3a\x03\x29\x29\x29", "\x31\x3a\x03\x29\x29\x29",
54, 54,
}, },
{ {
"", "",
0, 0,
@ -149,7 +149,7 @@ test_make_canon_sexp_from_rsa_pk (void)
fprintf (stderr, "%s:%d: out of core\n", __FILE__, __LINE__); fprintf (stderr, "%s:%d: out of core\n", __FILE__, __LINE__);
exit (1); exit (1);
} }
if (length != tests[idx].resultlen) if (length != tests[idx].resultlen)
fail (idx); fail (idx);
if (memcmp (sexp, tests[idx].result, tests[idx].resultlen)) if (memcmp (sexp, tests[idx].result, tests[idx].resultlen))
@ -189,4 +189,3 @@ main (int argc, char **argv)
return 0; return 0;
} }

View File

@ -42,14 +42,14 @@ gethome (void)
if (!home_buffer) if (!home_buffer)
{ {
char *home = getenv("HOME"); char *home = getenv("HOME");
if(home) if(home)
home_buffer = xstrdup (home); home_buffer = xstrdup (home);
#if defined(HAVE_GETPWUID) && defined(HAVE_PWD_H) #if defined(HAVE_GETPWUID) && defined(HAVE_PWD_H)
else else
{ {
struct passwd *pwd; struct passwd *pwd;
pwd = getpwuid (getuid()); pwd = getpwuid (getuid());
if (pwd) if (pwd)
home_buffer = xstrdup (pwd->pw_dir); home_buffer = xstrdup (pwd->pw_dir);
@ -65,10 +65,10 @@ test_percent_escape (void)
{ {
char *result; char *result;
static struct { static struct {
const char *extra; const char *extra;
const char *value; const char *value;
const char *expected; const char *expected;
} tests[] = } tests[] =
{ {
{ NULL, "", "" }, { NULL, "", "" },
{ NULL, "%", "%25" }, { NULL, "%", "%25" },
@ -183,7 +183,7 @@ test_strconcat (void)
fail (0); fail (0);
else if (errno != EINVAL) else if (errno != EINVAL)
fail (0); fail (0);
#if __GNUC__ < 4 /* gcc 4.0 has a sentinel attribute. */ #if __GNUC__ < 4 /* gcc 4.0 has a sentinel attribute. */
out = strconcat (NULL); out = strconcat (NULL);
if (!out || *out) if (!out || *out)
@ -322,10 +322,10 @@ test_make_filename_try (void)
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
"1", "2", NULL); "1", "2", NULL);
if (!out || strcmp (out, if (!out || strcmp (out,
"1/2/3/4/5/6/7/8/9/10/" "1/2/3/4/5/6/7/8/9/10/"
"1/2/3/4/5/6/7/8/9/10/" "1/2/3/4/5/6/7/8/9/10/"
"1/2/3/4/5/6/7/8/9/10/" "1/2/3/4/5/6/7/8/9/10/"
"1/2")) "1/2"))
fail (0); fail (0);
xfree (out); xfree (out);
@ -411,4 +411,3 @@ main (int argc, char **argv)
xfree (home_buffer); xfree (home_buffer);
return 0; return 0;
} }

View File

@ -142,6 +142,3 @@ gpg_err_code_from_syserror (void)
return -1; return -1;
} }
#endif /*GPG_ERROR_H*/ #endif /*GPG_ERROR_H*/

View File

@ -86,4 +86,3 @@ main (int argc, char **argv)
return !!errcount; return !!errcount;
} }

View File

@ -36,8 +36,8 @@ cmp_time_s (struct tm *a, struct tm *b)
|| a->tm_mon != b->tm_mon || a->tm_mon != b->tm_mon
|| a->tm_mday != b->tm_mday || a->tm_mday != b->tm_mday
|| a->tm_hour != b->tm_hour || a->tm_hour != b->tm_hour
|| a->tm_min != b->tm_min || a->tm_min != b->tm_min
|| a->tm_sec != b->tm_sec || a->tm_sec != b->tm_sec
|| a->tm_wday != b->tm_wday || a->tm_wday != b->tm_wday
|| a->tm_yday != b->tm_yday || a->tm_yday != b->tm_yday
|| !a->tm_isdst != !b->tm_isdst) || !a->tm_isdst != !b->tm_isdst)
@ -51,7 +51,7 @@ static void
test_timegm (void) test_timegm (void)
{ {
static struct { static struct {
int year, mon, mday, hour, min, sec; int year, mon, mday, hour, min, sec;
} tvalues[] = { } tvalues[] = {
{ -1 }, { -1 },
{ -2, 1 }, { -2, 1 },
@ -103,12 +103,12 @@ test_timegm (void)
tbuf.tm_mday = tvalues[tidx].mday; tbuf.tm_mday = tvalues[tidx].mday;
tbuf.tm_hour = tvalues[tidx].hour; tbuf.tm_hour = tvalues[tidx].hour;
tbuf.tm_min = tvalues[tidx].min; tbuf.tm_min = tvalues[tidx].min;
tbuf.tm_sec = tvalues[tidx].sec; tbuf.tm_sec = tvalues[tidx].sec;
now = mktime (&tbuf); now = mktime (&tbuf);
} }
if (now == (time_t)(-1)) if (now == (time_t)(-1))
fail (tidx); fail (tidx);
tp = gmtime (&now); tp = gmtime (&now);
if (!tp) if (!tp)
fail (tidx); fail (tidx);
@ -119,7 +119,7 @@ test_timegm (void)
fail (tidx); fail (tidx);
if (atime != now) if (atime != now)
fail (tidx); fail (tidx);
tp = gmtime (&atime); tp = gmtime (&atime);
if (!tp) if (!tp)
fail (tidx); fail (tidx);
@ -142,4 +142,3 @@ main (int argc, char **argv)
return 0; return 0;
} }

Some files were not shown because too many files have changed in this diff Show More