On Wednesday 30 October 2013 16:14:54 Kamil Dudka wrote:
> On Wednesday 30 October 2013 09:58:36 Daniel Stenberg wrote:
> > On Wed, 30 Oct 2013, Steve Holme wrote:
> > > I've just pushed commit e17c1b25bc33eb.
> > >
> > > I will an eye out on the auto builds to see if anything is flagged but
> > > any comments or feedback is much appreciated.
> >
> > It immediately made test 67 fail for me. It seems our NTLM code is
> > passing in the basee64 string _with_ the trailing CRLF at the end (sent
> > to the Curl_ntlm_decode_type2_message() function) so the length isn't an
> > even 4 bytes. In the test case the string is in fact 218 bytes as the
> > last two aren't part of the base64...
> 
> The following patch fixes the problem for me.

Oops, my previous patch did not handle the CR character, so NTLM was still 
broken.  The attached patch should fix it!

> Kamil
From a9e12201d1af9ea00940f843346755a75d3962ab Mon Sep 17 00:00:00 2001
From: Kamil Dudka <[email protected]>
Date: Wed, 30 Oct 2013 16:04:24 +0100
Subject: [PATCH] base64: do not fail on trailing CR/LF characters

This fixes numerous failing test cases since e17c1b25.
---
 lib/base64.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/lib/base64.c b/lib/base64.c
index 93b8be2..9352481 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -90,17 +90,24 @@ CURLcode Curl_base64_decode(const char *src,
   unsigned char lastQuantum[3];
   size_t rawlen = 0;
   unsigned char *newstr;
+  unsigned char c;
 
   *outptr = NULL;
   *outlen = 0;
   srcLen = strlen(src);
 
+  /* do not count the trailing CR-LF characters into srcLen */
+  if(srcLen && (src[srcLen - 1] == '\n'))
+    --srcLen;
+  if(srcLen && (src[srcLen - 1] == '\r'))
+    --srcLen;
+
   /* Check the length of the input string is valid */
   if(!srcLen || srcLen % 4)
     return CURLE_BAD_CONTENT_ENCODING;
 
   /* Find the position of any = padding characters */
-  while((src[length] != '=') && src[length])
+  while((c = src[length]) && (c != '=') && (c != '\r') && (c != '\n'))
     length++;
 
   /* A maximum of two = padding characters is allowed */
-- 
1.7.1

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to