[Pkg-gnupg-commit] [libassuan] 49/437: * assuan-buffer.c (assuan_write_line): Make sure we never accidently print an extra LF.

Eric Dorland eric at moszumanska.debian.org
Fri May 22 05:33:22 UTC 2015


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libassuan.

commit f874380c2f206bb2150798106e2b348723fe9451
Author: Werner Koch <wk at gnupg.org>
Date:   Wed Jun 26 12:51:15 2002 +0000

    * assuan-buffer.c (assuan_write_line): Make sure we never
    accidently print an extra LF.
---
 src/ChangeLog       |  5 +++++
 src/assuan-buffer.c | 18 +++++++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/ChangeLog b/src/ChangeLog
index bb74b7c..8b9bd3f 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2002-06-26  Werner Koch  <wk at gnupg.org>
+
+	* assuan-buffer.c (assuan_write_line): Make sure we never
+	accidently print an extra LF.
+
 2002-05-23  Werner Koch  <wk at gnupg.org>
 
 	* assuan-util.c (assuan_set_io_func): New.
diff --git a/src/assuan-buffer.c b/src/assuan-buffer.c
index da6b201..4509f74 100644
--- a/src/assuan-buffer.c
+++ b/src/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)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/libassuan.git



More information about the Pkg-gnupg-commit mailing list