MINOR: http: Use a trash chunk to store decoded string of the HTTP auth header
This string is used in sample fetches so it is safe to use a preallocated trash chunk instead of a buffer dynamically allocated during HAProxy startup.
This commit is contained in:
parent
ca20d02ea8
commit
6988f678cd
|
@ -95,7 +95,6 @@ extern const int http_err_codes[HTTP_ERR_SIZE];
|
|||
extern struct chunk http_err_chunks[HTTP_ERR_SIZE];
|
||||
extern const char *HTTP_302;
|
||||
extern const char *HTTP_303;
|
||||
extern char *get_http_auth_buff;
|
||||
|
||||
int process_cli(struct stream *s);
|
||||
int process_srv_data(struct stream *s);
|
||||
|
|
|
@ -1718,7 +1718,6 @@ static void init(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
get_http_auth_buff = calloc(1, global.tune.bufsize);
|
||||
|
||||
fdinfo = calloc(1, sizeof(struct fdinfo) * (global.maxsock));
|
||||
fdtab = calloc(1, sizeof(struct fdtab) * (global.maxsock));
|
||||
|
@ -2122,7 +2121,6 @@ void deinit(void)
|
|||
free(fdinfo); fdinfo = NULL;
|
||||
free(fdtab); fdtab = NULL;
|
||||
free(oldpids); oldpids = NULL;
|
||||
free(get_http_auth_buff); get_http_auth_buff = NULL;
|
||||
free(global_listener_queue_task); global_listener_queue_task = NULL;
|
||||
|
||||
list_for_each_entry_safe(log, logb, &global.logsrvs, list) {
|
||||
|
|
|
@ -1663,11 +1663,6 @@ const char *http_parse_reqline(struct http_msg *msg,
|
|||
* have the credentials overwritten by another stream in parallel.
|
||||
*/
|
||||
|
||||
/* This bufffer is initialized in the file 'src/haproxy.c'. This length is
|
||||
* set according to global.tune.bufsize.
|
||||
*/
|
||||
char *get_http_auth_buff;
|
||||
|
||||
int
|
||||
get_http_auth(struct stream *s)
|
||||
{
|
||||
|
@ -1713,22 +1708,23 @@ get_http_auth(struct stream *s)
|
|||
chunk_initlen(&txn->auth.method_data, p + 1, 0, ctx.vlen - len - 1);
|
||||
|
||||
if (!strncasecmp("Basic", auth_method.str, auth_method.len)) {
|
||||
struct chunk *http_auth = get_trash_chunk();
|
||||
|
||||
len = base64dec(txn->auth.method_data.str, txn->auth.method_data.len,
|
||||
get_http_auth_buff, global.tune.bufsize - 1);
|
||||
http_auth->str, global.tune.bufsize - 1);
|
||||
|
||||
if (len < 0)
|
||||
return 0;
|
||||
|
||||
|
||||
get_http_auth_buff[len] = '\0';
|
||||
http_auth->str[len] = '\0';
|
||||
|
||||
p = strchr(get_http_auth_buff, ':');
|
||||
p = strchr(http_auth->str, ':');
|
||||
|
||||
if (!p)
|
||||
return 0;
|
||||
|
||||
txn->auth.user = get_http_auth_buff;
|
||||
txn->auth.user = http_auth->str;
|
||||
*p = '\0';
|
||||
txn->auth.pass = p+1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue