gnutls-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnutls-cli: handle binary data from stdin


From: Vitaly Mayatskikh
Subject: gnutls-cli: handle binary data from stdin
Date: Mon, 25 Jan 2010 16:00:23 +0100
User-agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/23.1 Mule/6.0 (HANACHIRUSATO)

Hello!

gnutls-cli is used as TLS wrapper in several MUAs (like Gnus and
Wanderlust) to access secured IMAP mail servers. IMAP proto has
extension RFC4978 for traffic compression with deflate
method. However, gnutls-cli is pure text-oriented client, so it can't
handle binary data from stdin correctly.

This trivial patch fixes the problem.

P.s.: Please, keep me in Cc, I'm not subscribed to the list.

--- src/cli.c.orig      2009-06-02 20:59:32.000000000 +0200
+++ src/cli.c   2010-01-25 15:52:59.504321067 +0100
@@ -558,6 +558,7 @@ main (int argc, char **argv)
   struct timeval tv;
   int user_term = 0, retval = 0;
   socket_st hd;
+  int bytes;
 
   set_program_name (argv[0]);
 
@@ -749,7 +750,7 @@ after_handshake:
 
       if (FD_ISSET (fileno (stdin), &rset))
        {
-         if (fgets (buffer, MAX_BUF, stdin) == NULL)
+         if ((bytes = read (fileno(stdin), buffer, MAX_BUF)) < 0)
            {
              if (hd.secure == 0)
                {
@@ -778,11 +779,13 @@ after_handshake:
          if (crlf != 0)
            {
              char *b = strchr (buffer, '\n');
-             if (b != NULL)
+             if (b != NULL) {
                strcpy (b, "\r\n");
+               bytes++;
+             }
            }
 
-         ret = socket_send (&hd, buffer, strlen (buffer));
+         ret = socket_send (&hd, buffer, bytes);
 
          if (ret > 0)
            {

-- 
wbr, Vitaly




reply via email to

[Prev in Thread] Current Thread [Next in Thread]