1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-01-03 12:11:33 +01:00

Change stack size for Wince.

Allow for a longer agent atartup under wince.
Print gpg output via estream.
This commit is contained in:
Werner Koch 2010-11-23 18:46:41 +00:00
parent bbd08dd146
commit b3f9e2130e
18 changed files with 167 additions and 86 deletions

View File

@ -1,3 +1,8 @@
2010-11-23 Werner Koch <wk@g10code.com>
* am/cmacros.am (extra_bin_ldflags): New. For W32CE set the stack
size to 256k.
2010-11-17 Werner Koch <wk@g10code.com> 2010-11-17 Werner Koch <wk@g10code.com>
* configure.ac (ENABLE_CARD_SUPPORT): Define. * configure.ac (ENABLE_CARD_SUPPORT): Define.

2
NEWS
View File

@ -4,7 +4,7 @@ Noteworthy changes in version 2.1.0beta2 (unreleased)
* TMPDIR is now also honored when creating a socket using * TMPDIR is now also honored when creating a socket using
--no-standard-socket and with symcryptrun's temp files. --no-standard-socket and with symcryptrun's temp files.
* Fixed a bug where Scdaemon sends a signal to Gpg-agent running in * Fixed a bug where SCdaemon sends a signal to Gpg-agent running in
non-daemon mode. non-daemon mode.

View File

@ -1,3 +1,7 @@
2010-11-23 Werner Koch <wk@g10code.com>
* Makefile.am (gpg_agent_LDFLAGS): Add extra_bin_ldflags.
2010-11-11 Werner Koch <wk@g10code.com> 2010-11-11 Werner Koch <wk@g10code.com>
* agent.h (opt): Add field SIGUSR2_ENABLED. * agent.h (opt): Add field SIGUSR2_ENABLED.

View File

@ -75,7 +75,7 @@ gpg_agent_CFLAGS = $(AM_CFLAGS) $(LIBASSUAN_CFLAGS) $(PTH_CFLAGS)
gpg_agent_LDADD = $(commonpth_libs) \ gpg_agent_LDADD = $(commonpth_libs) \
$(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \ $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(PTH_LIBS) \
$(GPG_ERROR_LIBS) $(LIBINTL) $(NETLIBS) $(LIBICONV) $(GPG_ERROR_LIBS) $(LIBINTL) $(NETLIBS) $(LIBICONV)
gpg_agent_LDFLAGS = $(gpg_agent_res_ldflags) gpg_agent_LDFLAGS = $(extra_bin_ldflags) $(gpg_agent_res_ldflags)
gpg_agent_DEPENDENCIES = $(gpg_agent_res_deps) gpg_agent_DEPENDENCIES = $(gpg_agent_res_deps)
gpg_protect_tool_SOURCES = \ gpg_protect_tool_SOURCES = \

View File

@ -54,11 +54,15 @@ endif
# Under Windows we use LockFileEx. WindowsCE provides this only on # Under Windows we use LockFileEx. WindowsCE provides this only on
# the WindowsMobile 6 platform and thus we need to use the coredll6 # the WindowsMobile 6 platform and thus we need to use the coredll6
# import library. # import library. We also want to use a stacksize of 256k instead of
# the 2MB which is the default with cegcc. 256k is the largest stack
# 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
else else
extra_sys_libs = extra_sys_libs =
extra_bin_ldflags =
endif endif

View File

@ -1,3 +1,10 @@
2010-11-23 Werner Koch <wk@g10code.com>
* asshelp.c (SECS_TO_WAIT_FOR_AGENT, SECS_TO_WAIT_FOR_DIRMNGR):
Use these constants. For W32CE increase them to 30 seconds.
(start_new_gpg_agent): Print time to startup agent.
(start_new_dirmngr): Ditto.
2010-11-04 Werner Koch <wk@g10code.com> 2010-11-04 Werner Koch <wk@g10code.com>
* logging.c (do_logv) [W32]: Don't set a default log stream if the * logging.c (do_logv) [W32]: Don't set a default log stream if the

View File

@ -42,6 +42,15 @@
# define lock_spawn_t dotlock_t # define lock_spawn_t dotlock_t
#endif #endif
/* The time we wait until the agent or the dirmngr are ready for
operation after we started them before giving up. */
#ifdef HAVE_W32CE_SYSTEM
# define SECS_TO_WAIT_FOR_AGENT 30
# define SECS_TO_WAIT_FOR_DIRMNGR 30
#else
# define SECS_TO_WAIT_FOR_AGENT 5
# define SECS_TO_WAIT_FOR_DIRMNGR 5
#endif
/* A bitfield that specifies the assuan categories to log. This is /* A bitfield that specifies the assuan categories to log. This is
identical to the default log handler of libassuan. We need to do identical to the default log handler of libassuan. We need to do
@ -335,6 +344,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
gpg_error_t err = 0; gpg_error_t err = 0;
char *infostr, *p; char *infostr, *p;
assuan_context_t ctx; assuan_context_t ctx;
int did_success_msg = 0;
*r_ctx = NULL; *r_ctx = NULL;
@ -423,16 +433,19 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
if (verbose) if (verbose)
log_info (_("waiting %d seconds for the agent " log_info (_("waiting %d seconds for the agent "
"to come up\n"), 5); "to come up\n"), SECS_TO_WAIT_FOR_AGENT);
for (i=0; i < 5; i++) for (i=0; i < SECS_TO_WAIT_FOR_AGENT; i++)
{ {
gnupg_sleep (1); gnupg_sleep (1);
err = assuan_socket_connect (ctx, sockname, 0, 0); err = assuan_socket_connect (ctx, sockname, 0, 0);
if (!err) if (!err)
{ {
if (verbose && !debug) if (verbose)
log_info (_("connection to agent" {
" established\n")); log_info (_("connection to agent "
"established (%ds)\n"), i+1);
did_success_msg = 1;
}
break; break;
} }
} }
@ -517,7 +530,7 @@ start_new_gpg_agent (assuan_context_t *r_ctx,
return gpg_err_make (errsource, GPG_ERR_NO_AGENT); return gpg_err_make (errsource, GPG_ERR_NO_AGENT);
} }
if (debug) if (debug && !did_success_msg)
log_debug (_("connection to agent established\n")); log_debug (_("connection to agent established\n"));
err = assuan_transact (ctx, "RESET", err = assuan_transact (ctx, "RESET",
@ -552,6 +565,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
gpg_error_t err; gpg_error_t err;
assuan_context_t ctx; assuan_context_t ctx;
const char *sockname; const char *sockname;
int did_success_msg = 0;
*r_ctx = NULL; *r_ctx = NULL;
@ -612,16 +626,19 @@ start_new_dirmngr (assuan_context_t *r_ctx,
if (verbose) if (verbose)
log_info (_("waiting %d seconds for the dirmngr to come up\n"), log_info (_("waiting %d seconds for the dirmngr to come up\n"),
5); SECS_TO_WAIT_FOR_DIRMNGR);
for (i=0; i < 5; i++) for (i=0; i < SECS_TO_WAIT_FOR_DIRMNGR; i++)
{ {
gnupg_sleep (1); gnupg_sleep (1);
err = assuan_socket_connect (ctx, sockname, 0, 0); err = assuan_socket_connect (ctx, sockname, 0, 0);
if (!err) if (!err)
{ {
if (verbose && !debug) if (verbose)
log_info (_("connection to the dirmngr" {
" established\n")); log_info (_("connection to the dirmngr"
" established (%ds)\n"), i+1);
did_success_msg = 1;
}
break; break;
} }
} }
@ -646,7 +663,7 @@ start_new_dirmngr (assuan_context_t *r_ctx,
return gpg_err_make (errsource, GPG_ERR_NO_DIRMNGR); return gpg_err_make (errsource, GPG_ERR_NO_DIRMNGR);
} }
if (debug) if (debug && !did_success_msg)
log_debug (_("connection to the dirmngr established\n")); log_debug (_("connection to the dirmngr established\n"));
*r_ctx = ctx; *r_ctx = ctx;

View File

@ -1,3 +1,8 @@
2010-11-23 Werner Koch <wk@g10code.com>
* Makefile.am (dirmngr_LDFLAGS): Add extra_bin_ldflags.
(dirmngr_client_LDFLAGS): Ditto.
2010-10-21 Werner Koch <wk@g10code.com> 2010-10-21 Werner Koch <wk@g10code.com>
* dirmngr.c (main): Changed faked system time warning * dirmngr.c (main): Changed faked system time warning

View File

@ -63,7 +63,7 @@ dirmngr_LDADD = $(libcommonpth) ../gl/libgnu.a $(DNSLIBS) $(LIBASSUAN_LIBS) \
if !USE_LDAPWRAPPER if !USE_LDAPWRAPPER
dirmngr_LDADD += $(LDAPLIBS) dirmngr_LDADD += $(LDAPLIBS)
endif endif
dirmngr_LDFLAGS = $(extra_bin_ldflags)
if USE_LDAPWRAPPER if USE_LDAPWRAPPER
dirmngr_ldap_SOURCES = dirmngr_ldap.c $(ldap_url) dirmngr_ldap_SOURCES = dirmngr_ldap.c $(ldap_url)
@ -76,7 +76,9 @@ endif
dirmngr_client_SOURCES = dirmngr-client.c dirmngr_client_SOURCES = dirmngr-client.c
dirmngr_client_LDADD = $(libcommon) no-libgcrypt.o \ dirmngr_client_LDADD = $(libcommon) no-libgcrypt.o \
../gl/libgnu.a $(LIBASSUAN_LIBS) \ ../gl/libgnu.a $(LIBASSUAN_LIBS) \
$(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) $(GPG_ERROR_LIBS) $(LIBINTL) \
$(LIBICONV)
dirmngr_client_LDFLAGS = $(extra_bin_ldflags)
no-libgcrypt.c : $(top_srcdir)/tools/no-libgcrypt.c no-libgcrypt.c : $(top_srcdir)/tools/no-libgcrypt.c

View File

@ -1,3 +1,13 @@
2010-11-23 Werner Koch <wk@g10code.com>
* Makefile.am (gpg2_LDFLAGS, gpgv2_LDFLAGS): Add extra_bin_ldflags.
* plaintext.c (handle_plaintext): Change to use estream.
s/rc/err/. Replace some xmalloc by xtrymalloc. Use more
gpg_strerror.
* options.h (struct): Change type of OUTFP to estream_t.
* decrypt.c (decrypt_message_fd): Adjust accordingly.
2010-11-17 Werner Koch <wk@g10code.com> 2010-11-17 Werner Koch <wk@g10code.com>
* keyedit.c (find_pk_from_sknode): Remove. * keyedit.c (find_pk_from_sknode): Remove.

View File

@ -123,8 +123,10 @@ LDADD = $(needed_libs) ../common/libgpgrl.a \
$(LIBINTL) $(CAPLIBS) $(NETLIBS) $(LIBINTL) $(CAPLIBS) $(NETLIBS)
gpg2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ gpg2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
$(LIBICONV) $(extra_sys_libs) $(LIBICONV) $(extra_sys_libs)
gpg2_LDFLAGS = $(extra_bin_ldflags)
gpgv2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \ gpgv2_LDADD = $(LDADD) $(LIBGCRYPT_LIBS) $(LIBASSUAN_LIBS) $(GPG_ERROR_LIBS) \
$(LIBICONV) $(extra_sys_libs) $(LIBICONV) $(extra_sys_libs)
gpgv2_LDFLAGS = $(extra_bin_ldflags)
t_common_ldadd = t_common_ldadd =
module_tests = t-rmd160 module_tests = t-rmd160

View File

@ -135,7 +135,7 @@ decrypt_message_fd (ctrl_t ctrl, int input_fd, int output_fd)
#warning Need to fix this if we want to use g13 #warning Need to fix this if we want to use g13
opt.outfp = NULL; opt.outfp = NULL;
#else #else
opt.outfp = fdopen (dup (output_fd), "wb"); opt.outfp = es_fdopen_nc (output_fd, "wb");
#endif #endif
if (!opt.outfp) if (!opt.outfp)
{ {
@ -161,7 +161,7 @@ decrypt_message_fd (ctrl_t ctrl, int input_fd, int output_fd)
err = proc_encryption_packets (ctrl, NULL, fp ); err = proc_encryption_packets (ctrl, NULL, fp );
iobuf_close (fp); iobuf_close (fp);
fclose (opt.outfp); es_fclose (opt.outfp);
opt.outfp = NULL; opt.outfp = NULL;
release_armor_context (afx); release_armor_context (afx);
release_progress_context (pfx); release_progress_context (pfx);

View File

@ -43,7 +43,7 @@ struct
unsigned debug; unsigned debug;
int armor; int armor;
char *outfile; char *outfile;
FILE *outfp; /* Hack, sometimes used in place of outfile. */ estream_t outfp; /* Hack, sometimes used in place of outfile. */
off_t max_output; off_t max_output;
int dry_run; int dry_run;
int list_only; int list_only;

View File

@ -49,9 +49,9 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
int nooutput, int clearsig) int nooutput, int clearsig)
{ {
char *fname = NULL; char *fname = NULL;
FILE *fp = NULL; estream_t fp = NULL;
static off_t count = 0; static off_t count = 0;
int rc = 0; int err = 0;
int c; int c;
int convert = (pt->mode == 't' || pt->mode == 'u'); int convert = (pt->mode == 't' || pt->mode == 'u');
#ifdef __riscos__ #ifdef __riscos__
@ -69,7 +69,7 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
output will be written to it. This is to make sure that no output will be written to it. This is to make sure that no
not-yet-flushed stuff will be written after the plaintext not-yet-flushed stuff will be written after the plaintext
status message. */ status message. */
fflush (stdout); es_fflush (es_stdout);
snprintf (status, sizeof status, snprintf (status, sizeof status,
"%X %lu ", (byte) pt->mode, (ulong) pt->timestamp); "%X %lu ", (byte) pt->mode, (ulong) pt->timestamp);
@ -78,7 +78,7 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
if (!pt->is_partial) if (!pt->is_partial)
{ {
sprintf (status, "%lu", (ulong) pt->len); snprintf (status, sizeof status, "%lu", (ulong) pt->len);
write_status_text (STATUS_PLAINTEXT_LENGTH, status); write_status_text (STATUS_PLAINTEXT_LENGTH, status);
} }
} }
@ -88,11 +88,21 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
; ;
else if (opt.outfp) else if (opt.outfp)
{ {
fname = xstrdup ("[FP]"); fname = xtrystrdup ("[FP]");
if (!fname)
{
err = gpg_error_from_syserror ();
goto leave;
}
} }
else if (opt.outfile) else if (opt.outfile)
{ {
fname = xstrdup (opt.outfile); fname = xtrystrdup (opt.outfile);
if (!fname)
{
err = gpg_error_from_syserror ();
goto leave;
}
} }
else if (pt->namelen == 8 && !memcmp (pt->name, "_CONSOLE", 8)) else if (pt->namelen == 8 && !memcmp (pt->name, "_CONSOLE", 8))
{ {
@ -106,7 +116,7 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
fname = ask_outfile_name (pt->name, pt->namelen); fname = ask_outfile_name (pt->name, pt->namelen);
if (!fname) if (!fname)
{ {
rc = gpg_error (GPG_ERR_GENERAL); /* Can't create file. */ err = gpg_error (GPG_ERR_GENERAL); /* Can't create file. */
goto leave; goto leave;
} }
} }
@ -118,17 +128,13 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
else if (opt.outfp) else if (opt.outfp)
{ {
fp = opt.outfp; fp = opt.outfp;
#ifdef HAVE_DOSISH_SYSTEM es_set_binary (fp);
setmode (fileno (fp), O_BINARY);
#endif
} }
else if (iobuf_is_pipe_filename (fname) || !*fname) else if (iobuf_is_pipe_filename (fname) || !*fname)
{ {
/* No filename or "-" given; write to stdout. */ /* No filename or "-" given; write to stdout. */
fp = stdout; fp = es_stdout;
#ifdef HAVE_DOSISH_SYSTEM es_set_binary (fp);
setmode (fileno (fp), O_BINARY);
#endif
} }
else else
{ {
@ -139,7 +145,7 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
{ {
xfree (tmp); xfree (tmp);
/* FIXME: Below used to be G10ERR_CREATE_FILE */ /* FIXME: Below used to be G10ERR_CREATE_FILE */
rc = gpg_error (GPG_ERR_GENERAL); err = gpg_error (GPG_ERR_GENERAL);
goto leave; goto leave;
} }
xfree (fname); xfree (fname);
@ -148,10 +154,10 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
} }
#ifndef __riscos__ #ifndef __riscos__
if (opt.outfp && is_secured_file (fileno (opt.outfp))) if (opt.outfp && is_secured_file (es_fileno (opt.outfp)))
{ {
rc = gpg_error (GPG_ERR_EPERM); err = gpg_error (GPG_ERR_EPERM);
log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (rc)); log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err));
goto leave; goto leave;
} }
else if (fp || nooutput) else if (fp || nooutput)
@ -159,14 +165,14 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
else if (is_secured_filename (fname)) else if (is_secured_filename (fname))
{ {
gpg_err_set_errno (EPERM); gpg_err_set_errno (EPERM);
rc = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
log_error (_("error creating `%s': %s\n"), fname, strerror (errno)); log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err));
goto leave; goto leave;
} }
else if (!(fp = fopen (fname, "wb"))) else if (!(fp = es_fopen (fname, "wb")))
{ {
rc = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
log_error (_("error creating `%s': %s\n"), fname, strerror (errno)); log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err));
goto leave; goto leave;
} }
#else /* __riscos__ */ #else /* __riscos__ */
@ -182,11 +188,15 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
; ;
else else
{ {
/* Note: riscos stuff is not expected to wrok anymore. If we
want to port it again to riscos we should do most of the suff
in estream. FIXME: Consider to remove all riscos special
cases. */
fp = fopen (fname, "wb"); fp = fopen (fname, "wb");
if (!fp) if (!fp)
{ {
log_error (_("error creating `%s': %s\n"), fname, strerror (errno)); log_error (_("error creating `%s': %s\n"), fname, gpg_strerror (err));
rc = G10ERR_CREATE_FILE; err = G10ERR_CREATE_FILE;
if (errno == 106) if (errno == 106)
log_info ("Do output file and input file have the same name?\n"); log_info ("Do output file and input file have the same name?\n");
goto leave; goto leave;
@ -210,7 +220,7 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
if (clearsig) if (clearsig)
{ {
log_error ("clearsig encountered while not expected\n"); log_error ("clearsig encountered while not expected\n");
rc = G10ERR_UNEXPECTED; err = gpg_error (GPG_ERR_UNEXPECTED);
goto leave; goto leave;
} }
@ -220,7 +230,7 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
{ {
if ((c = iobuf_get (pt->buf)) == -1) if ((c = iobuf_get (pt->buf)) == -1)
{ {
rc = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
log_error ("problem reading source (%u bytes remaining)\n", log_error ("problem reading source (%u bytes remaining)\n",
(unsigned) pt->len); (unsigned) pt->len);
goto leave; goto leave;
@ -237,17 +247,17 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
{ {
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, "exceeded --max-output limit\n"); fname, "exceeded --max-output limit\n");
rc = gpg_error (GPG_ERR_TOO_LARGE); err = gpg_error (GPG_ERR_TOO_LARGE);
goto leave; goto leave;
} }
else if (putc (c, fp) == EOF) else if (es_putc (c, fp) == EOF)
{ {
if (ferror (fp)) if (es_ferror (fp))
rc = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
else else
rc = gpg_error (GPG_ERR_EOF); err = gpg_error (GPG_ERR_EOF);
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, strerror (errno)); fname, gpg_strerror (err));
goto leave; goto leave;
} }
} }
@ -262,7 +272,7 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
len = iobuf_read (pt->buf, buffer, len); len = iobuf_read (pt->buf, buffer, len);
if (len == -1) if (len == -1)
{ {
rc = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
log_error ("problem reading source (%u bytes remaining)\n", log_error ("problem reading source (%u bytes remaining)\n",
(unsigned) pt->len); (unsigned) pt->len);
xfree (buffer); xfree (buffer);
@ -276,15 +286,15 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
{ {
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, "exceeded --max-output limit\n"); fname, "exceeded --max-output limit\n");
rc = gpg_error (GPG_ERR_TOO_LARGE); err = gpg_error (GPG_ERR_TOO_LARGE);
xfree (buffer); xfree (buffer);
goto leave; goto leave;
} }
else if (fwrite (buffer, 1, len, fp) != len) else if (es_fwrite (buffer, 1, len, fp) != len)
{ {
rc = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, strerror (errno)); fname, gpg_strerror (err));
xfree (buffer); xfree (buffer);
goto leave; goto leave;
} }
@ -312,17 +322,17 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
{ {
log_error ("Error writing to `%s': %s\n", log_error ("Error writing to `%s': %s\n",
fname, "exceeded --max-output limit\n"); fname, "exceeded --max-output limit\n");
rc = gpg_error (GPG_ERR_TOO_LARGE); err = gpg_error (GPG_ERR_TOO_LARGE);
goto leave; goto leave;
} }
else if (putc (c, fp) == EOF) else if (es_putc (c, fp) == EOF)
{ {
if (ferror (fp)) if (es_ferror (fp))
rc = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
else else
rc = gpg_error (GPG_ERR_EOF); err = gpg_error (GPG_ERR_EOF);
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, strerror (errno)); fname, gpg_strerror (err));
goto leave; goto leave;
} }
} }
@ -330,9 +340,16 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
} }
else else
{ /* binary mode */ { /* binary mode */
byte *buffer = xmalloc (32768); byte *buffer;
int eof_seen = 0; int eof_seen = 0;
buffer = xtrymalloc (32768);
if (!buffer)
{
err = gpg_error_from_syserror ();
goto leave;
}
while (!eof_seen) while (!eof_seen)
{ {
/* Why do we check for len < 32768: /* Why do we check for len < 32768:
@ -354,16 +371,15 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
{ {
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, "exceeded --max-output limit\n"); fname, "exceeded --max-output limit\n");
rc = gpg_error (GPG_ERR_TOO_LARGE); err = gpg_error (GPG_ERR_TOO_LARGE);
xfree (buffer); xfree (buffer);
goto leave; goto leave;
} }
else if (fwrite (buffer, 1, len, fp) != len) else if (es_fwrite (buffer, 1, len, fp) != len)
{ {
rc = (errno ? gpg_error_from_syserror () err = gpg_error_from_syserror ();
: gpg_error (GPG_ERR_INTERNAL));
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, strerror (errno)); fname, gpg_strerror (err));
xfree (buffer); xfree (buffer);
goto leave; goto leave;
} }
@ -385,15 +401,14 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
{ {
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, "exceeded --max-output limit\n"); fname, "exceeded --max-output limit\n");
rc = gpg_error (GPG_ERR_TOO_LARGE); err = gpg_error (GPG_ERR_TOO_LARGE);
goto leave; goto leave;
} }
else if (putc (c, fp) == EOF) else if (es_putc (c, fp) == EOF)
{ {
rc = (errno ? gpg_error_from_syserror () err = gpg_error_from_syserror ();
: gpg_error (GPG_ERR_INTERNAL));
log_error ("error writing to `%s': %s\n", log_error ("error writing to `%s': %s\n",
fname, strerror (errno)); fname, gpg_strerror (err));
goto leave; goto leave;
} }
} }
@ -434,11 +449,10 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
pt->buf = NULL; pt->buf = NULL;
} }
if (fp && fp != stdout && fp != opt.outfp && fclose (fp)) if (fp && fp != es_stdout && fp != opt.outfp && es_fclose (fp))
{ {
rc = (errno ? gpg_error_from_syserror () err = gpg_error_from_syserror ();
: gpg_error (GPG_ERR_INTERNAL)); log_error ("error closing `%s': %s\n", fname, gpg_strerror (err));
log_error ("error closing `%s': %s\n", fname, strerror (errno));
fp = NULL; fp = NULL;
goto leave; goto leave;
} }
@ -448,20 +462,21 @@ handle_plaintext (PKT_plaintext * pt, md_filter_context_t * mfx,
/* Make sure that stdout gets flushed after the plaintext has been /* Make sure that stdout gets flushed after the plaintext has been
handled. This is for extra security as we do a flush anyway handled. This is for extra security as we do a flush anyway
before checking the signature. */ before checking the signature. */
if (fflush (stdout)) if (es_fflush (es_stdout))
{ {
/* We need to check the return code to detect errors like disk /* We need to check the return code to detect errors like disk
full for short plaintexts. See bug#1207. Checking return full for short plaintexts. See bug#1207. Checking return
values is a good idea in any case. */ values is a good idea in any case. */
if (!rc) if (!err)
rc = gpg_error_from_syserror (); err = gpg_error_from_syserror ();
log_error ("error flushing `%s': %s\n", "[stdout]", strerror (errno)); log_error ("error flushing `%s': %s\n", "[stdout]",
gpg_strerror (err));
} }
if (fp && fp != stdout && fp != opt.outfp) if (fp && fp != es_stdout && fp != opt.outfp)
fclose (fp); es_fclose (fp);
xfree (fname); xfree (fname);
return rc; return err;
} }

View File

@ -1,3 +1,7 @@
2010-11-23 Werner Koch <wk@g10code.com>
* Makefile.am (gpgsm_LDADD): Add extra_bin_ldflags.
2010-10-08 Werner Koch <wk@g10code.com> 2010-10-08 Werner Koch <wk@g10code.com>
* gpgsm.c: Add option --with-keygrip. * gpgsm.c: Add option --with-keygrip.

View File

@ -59,6 +59,7 @@ gpgsm_LDADD = $(common_libs) ../common/libgpgrl.a \
$(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) \ $(LIBGCRYPT_LIBS) $(KSBA_LIBS) $(LIBASSUAN_LIBS) \
$(GPG_ERROR_LIBS) $(LIBREADLINE) $(LIBINTL) $(ZLIBS) \ $(GPG_ERROR_LIBS) $(LIBREADLINE) $(LIBINTL) $(ZLIBS) \
$(LIBICONV) $(extra_sys_libs) $(LIBICONV) $(extra_sys_libs)
gpgsm_LDFLAGS = $(extra_bin_ldflags)
# Make sure that all libs are build before we use them. This is # Make sure that all libs are build before we use them. This is
# important for things like make -j2. # important for things like make -j2.

View File

@ -1,3 +1,7 @@
2010-11-23 Werner Koch <wk@g10code.com>
* Makefile.am (gpgconf_LDFLAGS): Add extra_bin_ldflags.
2010-11-17 Marcus Brinkmann <mb@g10code.com> 2010-11-17 Marcus Brinkmann <mb@g10code.com>
* gogconf.c: Revert accidental debug output commit. * gogconf.c: Revert accidental debug output commit.

View File

@ -96,6 +96,7 @@ gpgconf_SOURCES = gpgconf.c gpgconf.h gpgconf-comp.c no-libgcrypt.c
gpgconf_LDADD = $(maybe_commonpth_libs) $(opt_libassuan_libs) \ gpgconf_LDADD = $(maybe_commonpth_libs) $(opt_libassuan_libs) \
$(LIBINTL) $(GPG_ERROR_LIBS) $(PTH_LIBS) $(NETLIBS) \ $(LIBINTL) $(GPG_ERROR_LIBS) $(PTH_LIBS) $(NETLIBS) \
$(LIBICONV) $(W32SOCKLIBS) $(LIBICONV) $(W32SOCKLIBS)
gpgconf_LDFLAGS = $(extra_bin_ldflags)
gpgparsemail_SOURCES = gpgparsemail.c rfc822parse.c rfc822parse.h gpgparsemail_SOURCES = gpgparsemail.c rfc822parse.c rfc822parse.h
gpgparsemail_LDADD = gpgparsemail_LDADD =