break;
case LOG_FMT_STATUS: // %ST
- ret = ltoa_o(txn->status, tmplog, dst + maxsize - tmplog);
+ ret = ltoa_o(txn ? txn->status : 0, tmplog, dst + maxsize - tmplog);
if (ret == NULL)
goto out;
tmplog = ret;
break;
case LOG_FMT_CCLIENT: // %CC
- src = txn->cli_cookie;
+ src = txn ? txn->cli_cookie : NULL;
ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
if (ret == NULL)
goto out;
break;
case LOG_FMT_CSERVER: // %CS
- src = txn->srv_cookie;
+ src = txn ? txn->srv_cookie : NULL;
ret = lf_text(tmplog, src, dst + maxsize - tmplog, tmp);
if (ret == NULL)
goto out;
case LOG_FMT_TERMSTATE_CK: // %tsc, same as TS with cookie state (for mode HTTP)
LOGCHAR(sess_term_cond[(s->flags & SF_ERR_MASK) >> SF_ERR_SHIFT]);
LOGCHAR(sess_fin_state[(s->flags & SF_FINST_MASK) >> SF_FINST_SHIFT]);
- LOGCHAR((be->ck_opts & PR_CK_ANY) ? sess_cookie[(txn->flags & TX_CK_MASK) >> TX_CK_SHIFT] : '-');
- LOGCHAR((be->ck_opts & PR_CK_ANY) ? sess_set_cookie[(txn->flags & TX_SCK_MASK) >> TX_SCK_SHIFT] : '-');
+ LOGCHAR((txn && (be->ck_opts & PR_CK_ANY)) ? sess_cookie[(txn->flags & TX_CK_MASK) >> TX_CK_SHIFT] : '-');
+ LOGCHAR((txn && (be->ck_opts & PR_CK_ANY)) ? sess_set_cookie[(txn->flags & TX_SCK_MASK) >> TX_SCK_SHIFT] : '-');
last_isspace = 0;
break;
/* Request */
if (tmp->options & LOG_OPT_QUOTE)
LOGCHAR('"');
- uri = txn->uri ? txn->uri : "<BADREQ>";
+ uri = txn && txn->uri ? txn->uri : "<BADREQ>";
ret = lf_encode_string(tmplog, dst + maxsize,
'#', url_encode_map, uri, tmp);
if (ret == NULL || *ret != '\0')
break;
case LOG_FMT_HTTP_PATH: // %HP
- uri = txn->uri ? txn->uri : "<BADREQ>";
+ uri = txn && txn->uri ? txn->uri : "<BADREQ>";
if (tmp->options & LOG_OPT_QUOTE)
LOGCHAR('"');
while (spc < end && *spc != '?' && !HTTP_IS_SPHT(*spc))
spc++;
- if (!txn->uri || nspaces == 0) {
+ if (!txn || txn->uri || nspaces == 0) {
chunk.str = "<BADREQ>";
chunk.len = strlen("<BADREQ>");
} else {
if (tmp->options & LOG_OPT_QUOTE)
LOGCHAR('"');
- if (!txn->uri) {
+ if (!txn || !txn->uri) {
chunk.str = "<BADREQ>";
chunk.len = strlen("<BADREQ>");
} else {
break;
case LOG_FMT_HTTP_URI: // %HU
- uri = txn->uri ? txn->uri : "<BADREQ>";
+ uri = txn && txn->uri ? txn->uri : "<BADREQ>";
if (tmp->options & LOG_OPT_QUOTE)
LOGCHAR('"');
while (spc < end && !HTTP_IS_SPHT(*spc))
spc++;
- if (!txn->uri || nspaces == 0) {
+ if (!txn || !txn->uri || nspaces == 0) {
chunk.str = "<BADREQ>";
chunk.len = strlen("<BADREQ>");
} else {
break;
case LOG_FMT_HTTP_METHOD: // %HM
- uri = txn->uri ? txn->uri : "<BADREQ>";
+ uri = txn && txn->uri ? txn->uri : "<BADREQ>";
if (tmp->options & LOG_OPT_QUOTE)
LOGCHAR('"');
break;
case LOG_FMT_HTTP_VERSION: // %HV
- uri = txn->uri ? txn->uri : "<BADREQ>";
+ uri = txn && txn->uri ? txn->uri : "<BADREQ>";
if (tmp->options & LOG_OPT_QUOTE)
LOGCHAR('"');
while (uri < end && HTTP_IS_SPHT(*uri))
uri++;
- if (!txn->uri || nspaces == 0) {
+ if (!txn || !txn->uri || nspaces == 0) {
chunk.str = "<BADREQ>";
chunk.len = strlen("<BADREQ>");
} else if (uri == end) {