0
0
mirror of https://github.com/darkk/redsocks.git synced 2025-08-25 11:15:30 +00:00

minor fixes

This commit is contained in:
Bin Jin 2010-11-14 22:35:22 +08:00
parent 35a8f066ec
commit c83e3b5fb2
3 changed files with 17 additions and 7 deletions

View File

@ -40,7 +40,7 @@ int base64_decode(uint8_t *out, const char *in, int out_size);
* *
* @param out buffer for encoded data * @param out buffer for encoded data
* @param out_size size in bytes of the output buffer, must be at * @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 * @param in_size size in bytes of the 'in' buffer
* @return 'out' or NULL in case of error * @return 'out' or NULL in case of error
*/ */

View File

@ -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 *realm = NULL, *opaque = NULL, *nonce = NULL, *qop = NULL;
char nc[9]; 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 namelen = name.e - name.b;
int valuelen = value.e - value.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); 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); 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); 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); strncpy(qop = (char *)malloc(valuelen + 1), value.b, valuelen);
qop[valuelen] = '\0';
}
} }
if (!realm || !nonce || !user || !passwd || !path || !method) { if (!realm || !nonce || !user || !passwd || !path || !method) {

View File

@ -19,6 +19,7 @@ char* basic_authentication_encode(const char *user, const char *passwd);
* only md5 method is available, see RFC 2617 for detail. * 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 */ #endif /* HTTP_AUTH_H */