#endif
#if !defined(CURL_DISABLE_CRYPTO_AUTH)
-/*
- * Returns 0 on success and then the buffers are filled in fine.
- *
- * Non-zero means failure to parse.
- */
-int Curl_sasl_digest_get_pair(const char *str, char *value, char *content,
- const char **endptr)
+bool Curl_sasl_digest_get_pair(const char *str, char *value, char *content,
+ const char **endptr)
{
int c;
bool starts_with_quote = FALSE;
if('=' != *str++)
/* eek, no match */
- return 1;
+ return FALSE;
if('\"' == *str) {
/* this starts with a quote so it must end with one as well! */
continue;
}
break;
+
case ',':
if(!starts_with_quote) {
/* this signals the end of the content if we didn't get a starting
continue;
}
break;
+
case '\r':
case '\n':
/* end of string */
c = 0;
continue;
+
case '\"':
if(!escape && starts_with_quote) {
/* end of string */
}
break;
}
+
escape = FALSE;
*content++ = *str;
}
- *content = 0;
+ *content = 0;
*endptr = str;
- return 0; /* all is fine! */
+ return TRUE;
}
#endif
chlg++;
/* Extract a value=content pair */
- if(!Curl_sasl_digest_get_pair(chlg, value, content, &chlg)) {
+ if(Curl_sasl_digest_get_pair(chlg, value, content, &chlg)) {
if(Curl_raw_equal(value, "nonce")) {
free(digest->nonce);
digest->nonce = strdup(content);
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2012 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
#ifndef CURL_DISABLE_CRYPTO_AUTH
/* This is used to extract the realm from a challenge message */
-int Curl_sasl_digest_get_pair(const char *str, char *value, char *content,
- const char **endptr);
+bool Curl_sasl_digest_get_pair(const char *str, char *value, char *content,
+ const char **endptr);
/* This is used to generate a base64 encoded DIGEST-MD5 response message */
CURLcode Curl_sasl_create_digest_md5_message(struct SessionHandle *data,
chlg++;
/* Extract a value=content pair */
- if(!Curl_sasl_digest_get_pair(chlg, value, content, &chlg)) {
+ if(Curl_sasl_digest_get_pair(chlg, value, content, &chlg)) {
if(Curl_raw_equal(value, "realm")) {
/* Setup identity's domain and length */