summaryrefslogtreecommitdiffstats
path: root/assuan
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2002-06-26 14:51:15 +0200
committerWerner Koch <wk@gnupg.org>2002-06-26 14:51:15 +0200
commitf60b29f2ee3809067b2fc0ca5c3d2a079e236805 (patch)
treead9f438f87fcbf8a5602c6f992e43533ced37e71 /assuan
parent* protect-tool.c (rsa_key_check): New. (diff)
downloadgnupg2-f60b29f2ee3809067b2fc0ca5c3d2a079e236805.tar.xz
gnupg2-f60b29f2ee3809067b2fc0ca5c3d2a079e236805.zip
* assuan-buffer.c (assuan_write_line): Make sure we never
accidently print an extra LF.
Diffstat (limited to 'assuan')
-rw-r--r--assuan/ChangeLog5
-rw-r--r--assuan/assuan-buffer.c18
2 files changed, 18 insertions, 5 deletions
diff --git a/assuan/ChangeLog b/assuan/ChangeLog
index bb74b7cda..8b9bd3f55 100644
--- a/assuan/ChangeLog
+++ b/assuan/ChangeLog
@@ -1,3 +1,8 @@
+2002-06-26 Werner Koch <wk@gnupg.org>
+
+ * assuan-buffer.c (assuan_write_line): Make sure we never
+ accidently print an extra LF.
+
2002-05-23 Werner Koch <wk@gnupg.org>
* assuan-util.c (assuan_set_io_func): New.
diff --git a/assuan/assuan-buffer.c b/assuan/assuan-buffer.c
index da6b201e4..4509f74eb 100644
--- a/assuan/assuan-buffer.c
+++ b/assuan/assuan-buffer.c
@@ -241,23 +241,31 @@ AssuanError
assuan_write_line (ASSUAN_CONTEXT ctx, const char *line )
{
int rc;
-
+ size_t len;
+ const char *s;
+
if (!ctx)
return ASSUAN_Invalid_Value;
- /* fixme: we should do some kind of line buffering */
+ /* Make sure that we never take a LF from the user - this might
+ violate the protocol. */
+ s = strchr (line, '\n');
+ len = s? (s-line) : strlen (line);
+
+ /* fixme: we should do some kind of line buffering. */
if (ctx->log_fp)
{
fprintf (ctx->log_fp, "%s[%p] -> ", my_log_prefix (), ctx);
+ if (s)
+ fputs ("[supplied line contained a LF]", ctx->log_fp);
if (ctx->confidential)
fputs ("[Confidential data not shown]", ctx->log_fp);
else
- _assuan_log_print_buffer (ctx->log_fp,
- line, strlen (line));
+ _assuan_log_print_buffer (ctx->log_fp, line, len);
putc ('\n', ctx->log_fp);
}
- rc = writen (ctx->outbound.fd, line, strlen(line));
+ rc = writen (ctx->outbound.fd, line, len);
if (rc)
rc = ASSUAN_Write_Error;
if (!rc)