diff --git a/base64.h b/base64.h index 0dc9ef0..01bcda5 100644 --- a/base64.h +++ b/base64.h @@ -40,7 +40,7 @@ int base64_decode(uint8_t *out, const char *in, int out_size); * * @param out buffer for encoded data * @param out_size size in bytes of the output buffer, must be at - * least AV_BASE64_SIZE(in_size) + * least BASE64_SIZE(in_size) * @param in_size size in bytes of the 'in' buffer * @return 'out' or NULL in case of error */ diff --git a/http-auth.c b/http-auth.c index 4cb1e56..5631a11 100644 --- a/http-auth.c +++ b/http-auth.c @@ -162,7 +162,8 @@ static int extract_param(const char **source, param_token *name, param_token *va } -char* digest_authentication_encode(const char *line, const char *user, const char *passwd, const char *method, const char *path, int count, const char *cnonce) +char* digest_authentication_encode(const char *line, const char *user, const char *passwd, + const char *method, const char *path, int count, const char *cnonce) { char *realm = NULL, *opaque = NULL, *nonce = NULL, *qop = NULL; char nc[9]; @@ -175,14 +176,22 @@ char* digest_authentication_encode(const char *line, const char *user, const cha int namelen = name.e - name.b; int valuelen = value.e - value.b; - if (strncmp_nocase(name.b, "realm" , namelen) == 0) + if (strncmp_nocase(name.b, "realm" , namelen) == 0) { strncpy(realm = (char *)malloc(valuelen + 1), value.b, valuelen); - if (strncmp_nocase(name.b, "opaque", namelen) == 0) + realm[valuelen] = '\0'; + } + if (strncmp_nocase(name.b, "opaque", namelen) == 0) { strncpy(opaque = (char *)malloc(valuelen + 1), value.b, valuelen); - if (strncmp_nocase(name.b, "nonce" , namelen) == 0) + opaque[valuelen] = '\0'; + } + if (strncmp_nocase(name.b, "nonce" , namelen) == 0) { strncpy(nonce = (char *)malloc(valuelen + 1), value.b, valuelen); - if (strncmp_nocase(name.b, "qop" , namelen) == 0) + nonce[valuelen] = '\0'; + } + if (strncmp_nocase(name.b, "qop" , namelen) == 0) { strncpy(qop = (char *)malloc(valuelen + 1), value.b, valuelen); + qop[valuelen] = '\0'; + } } if (!realm || !nonce || !user || !passwd || !path || !method) { diff --git a/http-auth.h b/http-auth.h index bf8cc94..57f980a 100644 --- a/http-auth.h +++ b/http-auth.h @@ -19,6 +19,7 @@ char* basic_authentication_encode(const char *user, const char *passwd); * only md5 method is available, see RFC 2617 for detail. * */ -char* digest_authentication_encode(const char *line, const char *user, const char *passwd, const char *method, const char *path, int count, const char *cnonce); +char* digest_authentication_encode(const char *line, const char *user, const char *passwd, + const char *method, const char *path, int count, const char *cnonce); #endif /* HTTP_AUTH_H */