Zero padded the returned and logged HTTP status code, and fixed possible

buffer overrun in $status handling.
This commit is contained in:
Ruslan Ermilov 2012-05-16 13:27:04 +00:00
parent befc111d4f
commit 1b4397443f
2 changed files with 3 additions and 3 deletions

View File

@ -205,7 +205,7 @@ static ngx_http_log_var_t ngx_http_log_vars[] = {
{ ngx_string("msec"), NGX_TIME_T_LEN + 4, ngx_http_log_msec },
{ ngx_string("request_time"), NGX_TIME_T_LEN + 4,
ngx_http_log_request_time },
{ ngx_string("status"), 3, ngx_http_log_status },
{ ngx_string("status"), NGX_INT_T_LEN, ngx_http_log_status },
{ ngx_string("bytes_sent"), NGX_OFF_T_LEN, ngx_http_log_bytes_sent },
{ ngx_string("body_bytes_sent"), NGX_OFF_T_LEN,
ngx_http_log_body_bytes_sent },
@ -593,7 +593,7 @@ ngx_http_log_status(ngx_http_request_t *r, u_char *buf, ngx_http_log_op_t *op)
status = 0;
}
return ngx_sprintf(buf, "%ui", status);
return ngx_sprintf(buf, "%03ui", status);
}

View File

@ -445,7 +445,7 @@ ngx_http_header_filter(ngx_http_request_t *r)
b->last = ngx_copy(b->last, status_line->data, status_line->len);
} else {
b->last = ngx_sprintf(b->last, "%ui", status);
b->last = ngx_sprintf(b->last, "%03ui", status);
}
*b->last++ = CR; *b->last++ = LF;