aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/exec.c21
-rw-r--r--g10/gpg.c193
-rw-r--r--g10/misc.c3
-rw-r--r--g10/photoid.c7
4 files changed, 118 insertions, 106 deletions
diff --git a/g10/exec.c b/g10/exec.c
index 6ab24793f..331c5ec2a 100644
--- a/g10/exec.c
+++ b/g10/exec.c
@@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-/*
+/*
FIXME: We should replace most code in this module by our
spawn implementation from common/exechelp.c.
*/
@@ -33,7 +33,10 @@
#include <sys/wait.h>
#endif
#ifdef HAVE_DOSISH_SYSTEM
-#include <windows.h>
+# ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+# endif
+# include <windows.h>
#endif
#include <fcntl.h>
#include <unistd.h>
@@ -50,7 +53,7 @@
#include "exec.h"
#ifdef NO_EXEC
-int
+int
exec_write(struct exec_info **info,const char *program,
const char *args_in,const char *name,int writeonly,int binary)
{
@@ -71,7 +74,7 @@ set_exec_path(const char *path) { return G10ERR_GENERAL; }
/* This is a nicer system() for windows that waits for programs to
return before returning control to the caller. I hate helpful
computers. */
-static int
+static int
w32_system(const char *command)
{
PROCESS_INFORMATION pi;
@@ -103,7 +106,7 @@ w32_system(const char *command)
#endif
/* Replaces current $PATH */
-int
+int
set_exec_path(const char *path)
{
char *p;
@@ -126,7 +129,7 @@ set_exec_path(const char *path)
}
/* Makes a temp directory and filenames */
-static int
+static int
make_tempdir(struct exec_info *info)
{
char *tmp=opt.temp_dir,*namein=info->name,*nameout;
@@ -208,7 +211,7 @@ make_tempdir(struct exec_info *info)
/* Expands %i and %o in the args to the full temp files within the
temp directory. */
-static int
+static int
expand_args(struct exec_info *info,const char *args_in)
{
const char *ch = args_in;
@@ -297,7 +300,7 @@ expand_args(struct exec_info *info,const char *args_in)
If there are args, but no tempfiles, then it's a fork/exec/pipe via
shell -c. If there are tempfiles, then it's a system. */
-int
+int
exec_write(struct exec_info **info,const char *program,
const char *args_in,const char *name,int writeonly,int binary)
{
@@ -599,7 +602,7 @@ exec_finish(struct exec_info *info)
log_info(_("WARNING: unable to remove tempfile (%s) `%s': %s\n"),
"in",info->tempfile_in,strerror(errno));
}
-
+
if(info->tempfile_out)
{
if(unlink(info->tempfile_out)==-1)
diff --git a/g10/gpg.c b/g10/gpg.c
index b77309983..ffe964e6d 100644
--- a/g10/gpg.c
+++ b/g10/gpg.c
@@ -31,7 +31,10 @@
#endif
#include <fcntl.h>
#ifdef HAVE_W32_SYSTEM
-#include <windows.h>
+# ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+# endif
+# include <windows.h>
#endif
#define INCLUDED_BY_MAIN_MODULE 1
@@ -273,7 +276,7 @@ enum cmd_and_opt_values
oS2KDigest,
oS2KCipher,
oS2KCount,
- oSimpleSKChecksum,
+ oSimpleSKChecksum,
oDisplayCharset,
oNotDashEscaped,
oEscapeFrom,
@@ -302,7 +305,7 @@ enum cmd_and_opt_values
oNoAllowNonSelfsignedUID,
oAllowFreeformUID,
oNoAllowFreeformUID,
- oAllowSecretKeyImport,
+ oAllowSecretKeyImport,
oEnableSpecialFilenames,
oNoLiteral,
oSetFilesize,
@@ -392,7 +395,7 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_c (aListSecretKeys, "list-secret-keys", N_("list secret keys")),
ARGPARSE_c (aKeygen, "gen-key", N_("generate a new key pair")),
ARGPARSE_c (aGenRevoke, "gen-revoke",N_("generate a revocation certificate")),
- ARGPARSE_c (aDeleteKeys,"delete-keys",
+ ARGPARSE_c (aDeleteKeys,"delete-keys",
N_("remove keys from the public keyring")),
ARGPARSE_c (aDeleteSecretKeys, "delete-secret-keys",
N_("remove keys from the secret keyring")),
@@ -405,9 +408,9 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_c (aExport, "export" , N_("export keys") ),
ARGPARSE_c (aSendKeys, "send-keys" , N_("export keys to a key server") ),
ARGPARSE_c (aRecvKeys, "recv-keys" , N_("import keys from a key server") ),
- ARGPARSE_c (aSearchKeys, "search-keys" ,
+ ARGPARSE_c (aSearchKeys, "search-keys" ,
N_("search for keys on a key server") ),
- ARGPARSE_c (aRefreshKeys, "refresh-keys",
+ ARGPARSE_c (aRefreshKeys, "refresh-keys",
N_("update all keys from a keyserver")),
ARGPARSE_c (aLocateKeys, "locate-keys", "@"),
ARGPARSE_c (aFetchKeys, "fetch-keys" , "@" ),
@@ -596,7 +599,7 @@ static ARGPARSE_OPTS opts[] = {
/* More hidden commands and options. */
ARGPARSE_c (aPrintMDs, "print-mds", "@"), /* old */
ARGPARSE_c (aListTrustDB, "list-trustdb", "@"),
- /* Not yet used:
+ /* Not yet used:
ARGPARSE_c (aListTrustPath, "list-trust-path", "@"), */
ARGPARSE_c (aDeleteSecretAndPublicKeys,
"delete-secret-and-public-keys", "@"),
@@ -620,8 +623,8 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_n (oNoArmor, "no-armour", "@"),
ARGPARSE_s_n (oNoDefKeyring, "no-default-keyring", "@"),
ARGPARSE_s_n (oNoGreeting, "no-greeting", "@"),
- ARGPARSE_s_n (oNoOptions, "no-options", "@"),
- ARGPARSE_s_s (oHomedir, "homedir", "@"),
+ ARGPARSE_s_n (oNoOptions, "no-options", "@"),
+ ARGPARSE_s_s (oHomedir, "homedir", "@"),
ARGPARSE_s_n (oNoBatch, "no-batch", "@"),
ARGPARSE_s_n (oWithColons, "with-colons", "@"),
ARGPARSE_s_n (oWithKeyData,"with-key-data", "@"),
@@ -732,8 +735,8 @@ static ARGPARSE_OPTS opts[] = {
ARGPARSE_s_s (oKeyidFormat, "keyid-format", "@"),
ARGPARSE_s_n (oExitOnStatusWriteError, "exit-on-status-write-error", "@"),
ARGPARSE_s_i (oLimitCardInsertTries, "limit-card-insert-tries", "@"),
-
- ARGPARSE_s_n (oAllowMultisigVerification,
+
+ ARGPARSE_s_n (oAllowMultisigVerification,
"allow-multisig-verification", "@"),
ARGPARSE_s_n (oEnableDSA2, "enable-dsa2", "@"),
ARGPARSE_s_n (oDisableDSA2, "disable-dsa2", "@"),
@@ -788,7 +791,7 @@ make_libversion (const char *libname, const char *(*getfnc)(const char*))
{
const char *s;
char *result;
-
+
if (maybe_setuid)
{
gcry_control (GCRYCTL_INIT_SECMEM, 0, 0); /* Drop setuid. */
@@ -858,14 +861,14 @@ my_strusage( int level )
break;
case 35:
if( !ciphers )
- ciphers = build_list(_("Cipher: "), 'S',
+ ciphers = build_list(_("Cipher: "), 'S',
openpgp_cipher_algo_name,
openpgp_cipher_test_algo );
p = ciphers;
break;
case 36:
if( !digests )
- digests = build_list(_("Hash: "), 'H',
+ digests = build_list(_("Hash: "), 'H',
gcry_md_algo_name,
openpgp_md_test_algo );
p = digests;
@@ -961,7 +964,7 @@ static void
set_opt_session_env (const char *name, const char *value)
{
gpg_error_t err;
-
+
err = session_env_setenv (opt.session_env, name, value);
if (err)
log_fatal ("error setting session environment: %s\n",
@@ -995,7 +998,7 @@ set_debug (const char *level)
/* Unless the "guru" string has been used we don't want to allow
hashing debugging. The rationale is that people tend to
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)
opt.debug &= ~(DBG_HASHING_VALUE);
}
@@ -1019,17 +1022,17 @@ set_debug (const char *level)
if (opt.debug)
log_info ("enabled debug flags:%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
- (opt.debug & DBG_PACKET_VALUE )? " packet":"",
- (opt.debug & DBG_MPI_VALUE )? " mpi":"",
- (opt.debug & DBG_CIPHER_VALUE )? " cipher":"",
- (opt.debug & DBG_FILTER_VALUE )? " filter":"",
- (opt.debug & DBG_IOBUF_VALUE )? " iobuf":"",
- (opt.debug & DBG_MEMORY_VALUE )? " memory":"",
- (opt.debug & DBG_CACHE_VALUE )? " cache":"",
- (opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"",
- (opt.debug & DBG_TRUST_VALUE )? " trust":"",
- (opt.debug & DBG_HASHING_VALUE)? " hashing":"",
- (opt.debug & DBG_EXTPROG_VALUE)? " extprog":"",
+ (opt.debug & DBG_PACKET_VALUE )? " packet":"",
+ (opt.debug & DBG_MPI_VALUE )? " mpi":"",
+ (opt.debug & DBG_CIPHER_VALUE )? " cipher":"",
+ (opt.debug & DBG_FILTER_VALUE )? " filter":"",
+ (opt.debug & DBG_IOBUF_VALUE )? " iobuf":"",
+ (opt.debug & DBG_MEMORY_VALUE )? " memory":"",
+ (opt.debug & DBG_CACHE_VALUE )? " cache":"",
+ (opt.debug & DBG_MEMSTAT_VALUE)? " memstat":"",
+ (opt.debug & DBG_TRUST_VALUE )? " trust":"",
+ (opt.debug & DBG_HASHING_VALUE)? " hashing":"",
+ (opt.debug & DBG_EXTPROG_VALUE)? " extprog":"",
(opt.debug & DBG_CARD_IO_VALUE)? " cardio":"",
(opt.debug & DBG_ASSUAN_VALUE )? " assuan":"");
}
@@ -1092,7 +1095,7 @@ open_info_file (const char *fname, int for_write, int binary)
(void)for_write;
(void)binary;
return -1;
-#else
+#else
int fd;
if (binary)
@@ -1118,7 +1121,7 @@ open_info_file (const char *fname, int for_write, int binary)
if ( fd == -1)
log_error ( for_write? _("can't create `%s': %s\n")
: _("can't open `%s': %s\n"), fname, strerror(errno));
-
+
return fd;
#endif
}
@@ -1559,7 +1562,7 @@ list_config(char *items)
printf("\n");
any=1;
}
-
+
if(show_all || ascii_strcasecmp(name,"compress")==0)
{
printf("cfg:compress:");
@@ -1824,7 +1827,7 @@ get_default_configname (void)
if (configname)
{
char *tok;
-
+
xfree (configname);
configname = NULL;
@@ -1835,13 +1838,13 @@ get_default_configname (void)
else
break;
}
-
+
configname = make_filename (opt.homedir, name, NULL);
}
while (access (configname, R_OK));
xfree(name);
-
+
if (! configname)
configname = make_filename (opt.homedir, "gpg" EXTSEP_S "conf", NULL);
if (! access (configname, R_OK))
@@ -2048,7 +2051,7 @@ main (int argc, char **argv)
/* Initialize the secure memory. */
if (!gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0))
- got_secmem = 1;
+ got_secmem = 1;
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
/* There should be no way to get to this spot while still carrying
setuid privs. Just in case, bomb out if we are. */
@@ -2065,7 +2068,7 @@ main (int argc, char **argv)
malloc_hooks.free = gcry_free;
assuan_set_malloc_hooks (&malloc_hooks);
assuan_set_gpg_err_source (GPG_ERR_SOURCE_DEFAULT);
-
+
/* Try for a version specific config file first */
default_configname = get_default_configname ();
@@ -2125,55 +2128,55 @@ main (int argc, char **argv)
{
switch( pargs.r_opt )
{
- case aCheckKeys:
+ case aCheckKeys:
case aListConfig:
case aGPGConfList:
case aGPGConfTest:
case aListPackets:
- case aImport:
- case aFastImport:
- case aSendKeys:
- case aRecvKeys:
+ case aImport:
+ case aFastImport:
+ case aSendKeys:
+ case aRecvKeys:
case aSearchKeys:
case aRefreshKeys:
case aFetchKeys:
- case aExport:
+ case aExport:
#ifdef ENABLE_CARD_SUPPORT
case aCardStatus:
- case aCardEdit:
+ case aCardEdit:
case aChangePIN:
#endif /* ENABLE_CARD_SUPPORT*/
- case aListKeys:
+ case aListKeys:
case aLocateKeys:
- case aListSigs:
- case aExportSecret:
- case aExportSecretSub:
+ case aListSigs:
+ case aExportSecret:
+ case aExportSecretSub:
case aSym:
- case aClearsign:
- case aGenRevoke:
- case aDesigRevoke:
- case aPrimegen:
+ case aClearsign:
+ case aGenRevoke:
+ case aDesigRevoke:
+ case aPrimegen:
case aGenRandom:
case aPrintMD:
- case aPrintMDs:
- case aListTrustDB:
+ case aPrintMDs:
+ case aListTrustDB:
case aCheckTrustDB:
- case aUpdateTrustDB:
- case aFixTrustDB:
- case aListTrustPath:
- case aDeArmor:
- case aEnArmor:
- case aSign:
- case aSignKey:
+ case aUpdateTrustDB:
+ case aFixTrustDB:
+ case aListTrustPath:
+ case aDeArmor:
+ case aEnArmor:
+ case aSign:
+ case aSignKey:
case aLSignKey:
- case aStore:
- case aExportOwnerTrust:
- case aImportOwnerTrust:
+ case aStore:
+ case aExportOwnerTrust:
+ case aImportOwnerTrust:
case aRebuildKeydbCaches:
set_cmd (&cmd, pargs.r_opt);
break;
- case aKeygen:
+ case aKeygen:
case aEditKey:
case aDeleteSecretKeys:
case aDeleteSecretAndPublicKeys:
@@ -2223,7 +2226,7 @@ main (int argc, char **argv)
case oNoUseAgent:
obsolete_option (configname, configlineno, "--no-use-agent");
break;
- case oGpgAgentInfo:
+ case oGpgAgentInfo:
obsolete_option (configname, configlineno, "--gpg-agent-info");
break;
@@ -2286,12 +2289,12 @@ main (int argc, char **argv)
case oNoArmor: opt.no_armor=1; opt.armor=0; break;
case oNoDefKeyring: default_keyring = 0; break;
case oNoGreeting: nogreeting = 1; break;
- case oNoVerbose:
+ case oNoVerbose:
opt.verbose = 0;
gcry_control (GCRYCTL_SET_VERBOSITY, (int)opt.verbose);
opt.list_sigs=0;
break;
- case oQuickRandom:
+ case oQuickRandom:
gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0);
break;
case oEmitVersion: opt.no_version=0; break;
@@ -2321,12 +2324,12 @@ main (int argc, char **argv)
case oWithColons: opt.with_colons=':'; break;
case oWithSigCheck: opt.check_sigs = 1; /*FALLTHRU*/
- case oWithSigList: opt.list_sigs = 1; break;
+ case oWithSigList: opt.list_sigs = 1; break;
case oSkipVerify: opt.skip_verify=1; break;
- case oSkipHiddenRecipients:
- case oNoSkipHiddenRecipients:
+ case oSkipHiddenRecipients:
+ case oNoSkipHiddenRecipients:
/* Dummies for options to be used in 2.1. */
break;
@@ -2574,7 +2577,7 @@ main (int argc, char **argv)
case oCommandFile:
opt.command_fd = open_info_file (pargs.r.ret_str, 0, 1);
break;
- case oCipherAlgo:
+ case oCipherAlgo:
def_cipher_string = xstrdup(pargs.r.ret_str);
break;
case oDigestAlgo:
@@ -2604,12 +2607,12 @@ main (int argc, char **argv)
compress_algo_string = xstrdup(pargs.r.ret_str);
}
break;
- case oCertDigestAlgo:
+ case oCertDigestAlgo:
cert_digest_string = xstrdup(pargs.r.ret_str);
break;
- case oNoSecmemWarn:
- gcry_control (GCRYCTL_DISABLE_SECMEM_WARN);
+ case oNoSecmemWarn:
+ gcry_control (GCRYCTL_DISABLE_SECMEM_WARN);
break;
case oRequireSecmem: require_secmem=1; break;
@@ -2882,8 +2885,8 @@ main (int argc, char **argv)
}
break;
- case oStrict:
- case oNoStrict:
+ case oStrict:
+ case oNoStrict:
/* Not used */
break;
@@ -2908,8 +2911,8 @@ main (int argc, char **argv)
opt.exit_on_status_write_error = 1;
break;
- case oLimitCardInsertTries:
- opt.limit_card_insert_tries = pargs.r.ret_int;
+ case oLimitCardInsertTries:
+ opt.limit_card_insert_tries = pargs.r.ret_int;
break;
case oRequireCrossCert: opt.flags.require_cross_cert=1; break;
@@ -2943,7 +2946,7 @@ main (int argc, char **argv)
case oNoop: break;
- default:
+ default:
pargs.err = configfp? ARGPARSE_PRINT_WARNING:ARGPARSE_PRINT_ERROR;
break;
}
@@ -3350,12 +3353,12 @@ main (int argc, char **argv)
avoid adding the secret keyring for a couple of commands to
avoid unneeded access in case the secrings are stored on a
floppy.
-
+
We always need to add the keyrings if we are running under
SELinux, this is so that the rings are added to the list of
secured files. */
- if( ALWAYS_ADD_KEYRINGS
- || (cmd != aDeArmor && cmd != aEnArmor && cmd != aGPGConfTest) )
+ if( ALWAYS_ADD_KEYRINGS
+ || (cmd != aDeArmor && cmd != aEnArmor && cmd != aGPGConfTest) )
{
if (ALWAYS_ADD_KEYRINGS
|| (cmd != aCheckKeys && cmd != aListSigs && cmd != aListKeys
@@ -3405,11 +3408,11 @@ main (int argc, char **argv)
switch (cmd)
{
- case aStore:
- case aSym:
- case aSign:
- case aSignSym:
- case aClearsign:
+ case aStore:
+ case aSym:
+ case aSign:
+ case aSignSym:
+ case aClearsign:
if (!opt.quiet && any_explicit_recipient)
log_info (_("WARNING: recipients (-r) given "
"without using public key encryption\n"));
@@ -3579,7 +3582,7 @@ main (int argc, char **argv)
log_error("decrypt_message failed: %s\n", g10_errstr(rc) );
}
break;
-
+
case aSignKey:
if( argc != 1 )
wrong_args(_("--sign-key user-id"));
@@ -3951,7 +3954,7 @@ main (int argc, char **argv)
wrong_args("--import-ownertrust [file]");
import_ownertrust( argc? *argv:NULL );
break;
-
+
case aRebuildKeydbCaches:
if (argc)
wrong_args ("--rebuild-keydb-caches");
@@ -4064,7 +4067,7 @@ g10_exit( int rc )
gcry_control (GCRYCTL_DUMP_SECMEM_STATS );
emergency_cleanup ();
-
+
rc = rc? rc : log_get_errorcount(0)? 2 : g10_errors_seen? 1 : 0;
exit (rc);
}
@@ -4158,12 +4161,12 @@ print_hashline( gcry_md_hd_t md, int algo, const char *fname )
{
int i, n;
const byte *p;
-
+
if ( fname ) {
for (p = fname; *p; p++ ) {
if ( *p <= 32 || *p > 127 || *p == ':' || *p == '%' )
printf("%%%02X", *p );
- else
+ else
putchar( *p );
}
}
@@ -4171,7 +4174,7 @@ print_hashline( gcry_md_hd_t md, int algo, const char *fname )
printf("%d:", algo );
p = gcry_md_read (md, algo);
n = gcry_md_get_algo_dlen (algo);
- for(i=0; i < n ; i++, p++ )
+ for(i=0; i < n ; i++, p++ )
printf("%02X", *p );
putchar(':');
putchar('\n');
@@ -4229,7 +4232,7 @@ print_mds( const char *fname, int algo )
else {
gcry_md_final (md);
if ( opt.with_colons ) {
- if ( algo )
+ if ( algo )
print_hashline( md, algo, fname );
else {
print_hashline( md, GCRY_MD_MD5, fname );
@@ -4328,7 +4331,7 @@ add_policy_url( const char *string, int which )
sl=add_to_strlist( &opt.sig_policy_url, string );
if(critical)
- sl->flags |= 1;
+ sl->flags |= 1;
}
static void
@@ -4361,5 +4364,5 @@ add_keyserver_url( const char *string, int which )
sl=add_to_strlist( &opt.sig_keyserver_url, string );
if(critical)
- sl->flags |= 1;
+ sl->flags |= 1;
}
diff --git a/g10/misc.c b/g10/misc.c
index 1a937f1a6..6e9b31ef9 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -40,6 +40,9 @@
#ifdef HAVE_W32_SYSTEM
#include <time.h>
#include <process.h>
+#ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif
#include <windows.h>
#include <shlobj.h>
#ifndef CSIDL_APPDATA
diff --git a/g10/photoid.c b/g10/photoid.c
index 37156f296..615837e2e 100644
--- a/g10/photoid.c
+++ b/g10/photoid.c
@@ -21,7 +21,10 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>
-#ifdef _WIN32
+#ifdef _WIN32
+# ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+# endif
# include <windows.h>
# ifndef VER_PLATFORM_WIN32_WINDOWS
# define VER_PLATFORM_WIN32_WINDOWS 1
@@ -121,7 +124,7 @@ generate_photo_id(PKT_public_key *pk,const char *photo_name)
continue;
}
-
+
len=iobuf_get_filelength(file, &overflow);
if(len>6144 || overflow)
{