help-gsasl
[Top][All Lists]
Advanced

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

[PATCH] Fix SASL operations through TLS


From: Enrico Scholz
Subject: [PATCH] Fix SASL operations through TLS
Date: Sat, 21 Jun 2008 21:33:34 +0200

SASL operations through TLS do not work as the custom 'writeln()'
operation would skip the gnutls_record_send() call unconditionally
('len' is initialized to 0 and won't be modified).

This patch initializes 'len' with the length of the string and
reuses this value in the following send/write calls.

Signed-off-by: Enrico Scholz <address@hidden>
---
 src/gsasl.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/gsasl.c b/src/gsasl.c
index c0a2620..619964c 100644
--- a/src/gsasl.c
+++ b/src/gsasl.c
@@ -45,7 +45,7 @@ writeln (const char *str)
 
   if (sockfd)
     {
-      ssize_t len = 0;
+      ssize_t len = strlen (str);
 
 #ifdef HAVE_LIBGNUTLS
       if (using_tls)
@@ -53,13 +53,13 @@ writeln (const char *str)
          /* GnuTLS < 1.2.9 cannot handle data != NULL && count == 0,
             it will return an error. */
          if (len > 0)
-           len = gnutls_record_send (session, str, strlen (str));
+           len = gnutls_record_send (session, str, len);
          else
            len = 0;
        }
       else
 #endif
-       len = write (sockfd, str, strlen (str));
+       len = write (sockfd, str, len);
       if (len != strlen (str))
        return 0;
 
-- 
1.5.5.1





reply via email to

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