diff -r c62ea2a2133b -r f4a34b0869c7 src/server/daemon/httprequest.c --- a/src/server/daemon/httprequest.c Sat May 07 15:07:01 2022 +0200 +++ b/src/server/daemon/httprequest.c Sun May 08 10:33:41 2022 +0200 @@ -375,26 +375,26 @@ // check for request body and prepare input buffer char *ctlen_str = pblock_findkeyval(pb_key_content_length, rq->rq.headers); if(ctlen_str) { - int ctlen = atoi(ctlen_str); // TODO: use other func - - //printf("request body length: %d\n", ctlen); + int64_t ctlen; + if(util_strtoint(ctlen_str, &ctlen)) { + netbuf *nb = sn->netbuf; + HttpStream *net_io = (HttpStream*)sn->sn.csd; - netbuf *nb = sn->netbuf; - HttpStream *net_io = (HttpStream*)sn->sn.csd; + // how many bytes are already read and in the buffer + int cur_input_available = nb->cursize - nb->pos; - // how many bytes are already read and in the buffer - int cur_input_available = nb->cursize - nb->pos; - - if(cur_input_available >= ctlen) { - // we have the whole request body in the buffer and - // maybe even more - // no more read from the socket is necessary to get the body, - // therefore disable it - net_io->max_read = 0; - } else { - // read still required to get the complete request body - net_io->max_read = ctlen - cur_input_available; - } + if(cur_input_available >= ctlen) { + // we have the whole request body in the buffer and + // maybe even more + // no more read from the socket is necessary to get the body, + // therefore disable it + net_io->max_read = 0; + } else { + // read still required to get the complete request body + net_io->max_read = ctlen - cur_input_available; + } + //printf("request body length: %d\n", ctlen); + } // else: should we abort? } char *transfer_encoding = pblock_findkeyval(pb_key_transfer_encoding, rq->rq.headers); if(transfer_encoding) { @@ -878,10 +878,8 @@ if(ret != REQ_NOACTION) { if(ret == REQ_PROCEED) { - /* - * flush buffer and add termination if chunked encoding - * is enabled - */ + // flush buffer and add termination if chunked encoding + // is enabled net_finish(sn->sn.csd); } else if(ret == REQ_PROCESSING) { // save nsapi context @@ -917,11 +915,18 @@ if(ret == REQ_NOACTION) { directive *d = dt->dirs[j]; - // check status code parameter + // check status code parameter + // Error SAFs can specify, for which status code they should + // be executed char *status = pblock_findkeyval(pb_key_type, d->param); if(status) { - int statuscode = atoi(status); - if(statuscode != rq->rq.status_num) { + int64_t statuscode = -1; + if(!util_strtoint(status, &statuscode)) { + log_ereport( + LOG_WARN, + "nsapi_error: directive '%s' ignored: invalid type parameter: integer status code expected", + d->func->name); + } else if(statuscode != rq->rq.status_num) { continue; } } @@ -937,10 +942,8 @@ } if(ret != REQ_NOACTION) { if(ret == REQ_PROCEED) { - /* - * flush buffer and add termination if chunked encoding - * is enabled - */ + // flush buffer and add termination if chunked encoding + // is enabled net_finish(sn->sn.csd); } else if(ret == REQ_PROCESSING) { // save nsapi context