mirror of
https://github.com/curl/curl.git
synced 2026-07-28 21:23:06 +03:00
digest: escape control codes too
Since the username is decoded when used and control codes are accepted in HTTP usernames in general, the username encoding for the Digest auth needs to percent encode such bytes. Verified by test 3221 Reported-by: Trail of Bits Closes #21915
This commit is contained in:
parent
04afd16076
commit
a2b943b115
3 changed files with 81 additions and 1 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#include "curl_sha512_256.h"
|
||||
#include "curlx/strparse.h"
|
||||
#include "rand.h"
|
||||
#include "escape.h"
|
||||
|
||||
#ifndef USE_WINDOWS_SSPI
|
||||
#define SESSION_ALGO 1 /* for algos with this bit set */
|
||||
|
|
@ -163,6 +164,11 @@ static char *auth_digest_string_quoted(const char *s)
|
|||
if(!result)
|
||||
result = curlx_dyn_addn(&out, s, 1);
|
||||
}
|
||||
else if((*s < ' ') || (*s > 0x7e)) {
|
||||
unsigned char buf[3] = { '%' };
|
||||
Curl_hexbyte(&buf[1], (unsigned char)*s);
|
||||
result = curlx_dyn_addn(&out, buf, 3);
|
||||
}
|
||||
else
|
||||
result = curlx_dyn_addn(&out, s, 1);
|
||||
if(result)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue