Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
curl_sasl: Minor code policing following recent commits
  • Loading branch information
captain-caveman2k committed Jan 22, 2015
1 parent 731e6a6 commit c260c9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions lib/curl_sasl.c
Expand Up @@ -54,7 +54,7 @@

/* Supported mechanisms */
const struct {
const char * name; /* Name */
const char *name; /* Name */
size_t len; /* Name length */
unsigned int bit; /* Flag bit */
} mechtable[] = {
Expand Down Expand Up @@ -92,7 +92,6 @@ const struct {
return result; \
}


/*
* Return 0 on success and then the buffers are filled in fine.
*
Expand Down Expand Up @@ -1212,8 +1211,7 @@ void Curl_sasl_cleanup(struct connectdata *conn, unsigned int authused)
*
* Return the SASL mechanism token or 0 if no match.
*/
unsigned int
Curl_sasl_decode_mech(const char *ptr, size_t maxlen, size_t *len)
unsigned int Curl_sasl_decode_mech(const char *ptr, size_t maxlen, size_t *len)
{
unsigned int i;
char c;
Expand All @@ -1223,8 +1221,10 @@ Curl_sasl_decode_mech(const char *ptr, size_t maxlen, size_t *len)
!memcmp(ptr, mechtable[i].name, mechtable[i].len)) {
if(len)
*len = mechtable[i].len;

if(maxlen == mechtable[i].len)
return mechtable[i].bit;

c = ptr[mechtable[i].len];
if(!ISUPPER(c) && !ISDIGIT(c) && c != '-' && c != '_')
return mechtable[i].bit;
Expand All @@ -1244,7 +1244,7 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,
{
CURLcode result = CURLE_OK;
unsigned int mechbit;
size_t llen;
size_t mechlen;

if(!len)
return CURLE_URL_MALFORMAT;
Expand All @@ -1256,8 +1256,8 @@ CURLcode Curl_sasl_parse_url_auth_option(struct SASL *sasl,

if(strnequal(value, "*", len))
sasl->prefmech = SASL_AUTH_ANY;
else if((mechbit = Curl_sasl_decode_mech(value, len, &llen)) &&
llen == len)
else if((mechbit = Curl_sasl_decode_mech(value, len, &mechlen)) &&
mechlen == len)
sasl->prefmech |= mechbit;
else
result = CURLE_URL_MALFORMAT;
Expand Down Expand Up @@ -1434,6 +1434,7 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
}

Curl_safefree(resp);

return result;
}

Expand All @@ -1443,7 +1444,7 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,
* Continue an SASL authentication.
*/
CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
int code, saslprogress *progress)
int code, saslprogress *progress)
{
CURLcode result = CURLE_OK;
struct SessionHandle *data = conn->data;
Expand Down Expand Up @@ -1602,6 +1603,8 @@ CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
}

Curl_safefree(resp);

state(sasl, conn, newstate);

return result;
}
2 changes: 1 addition & 1 deletion lib/curl_sasl.h
Expand Up @@ -234,6 +234,6 @@ CURLcode Curl_sasl_start(struct SASL *sasl, struct connectdata *conn,

/* Continue an SASL authentication */
CURLcode Curl_sasl_continue(struct SASL *sasl, struct connectdata *conn,
int code, saslprogress *progress);
int code, saslprogress *progress);

#endif /* HEADER_CURL_SASL_H */

0 comments on commit c260c9f

Please sign in to comment.