Permalink
Browse files

simplehttp_log: be paranoid about input_buffer

check and log any possible nulls for or in the input_buffer
  • Loading branch information...
1 parent d9bd5e0 commit ef3ca33edb8e12073282ef43fccb2ce2f00306aa Pierce Lopez committed Nov 9, 2012
Showing with 7 additions and 3 deletions.
  1. +7 −3 simplehttp/log.c
View
@@ -65,9 +65,13 @@ void simplehttp_log(const char *host, struct evhttp_request *req, uint64_t req_t
fprintf(stdout, "[%c %s %s] %d %s %s%s", code, datetime_buf, id, response_code, method, host, uri);
- if (display_post && (type == EVHTTP_REQ_POST) && EVBUFFER_DATA(req->input_buffer)) {
- fprintf(stdout, "?");
- fwrite(EVBUFFER_DATA(req->input_buffer), EVBUFFER_LENGTH(req->input_buffer), 1, stdout);
+ if (display_post && (type == EVHTTP_REQ_POST)) {
+ if (req->input_buffer == NULL || EVBUFFER_DATA(req->input_buffer) == NULL) {
+ fprintf(stdout, "<ERROR req->input_buffer=%p, EVBUFFER_DATA=%p>", req->input_buffer, /* must be */ NULL);
+ } else {
+ fprintf(stdout, "?");
+ fwrite(EVBUFFER_DATA(req->input_buffer), EVBUFFER_LENGTH(req->input_buffer), 1, stdout);
+ }
}
fprintf(stdout, " %.3fms\n", req_time / 1000.0);

0 comments on commit ef3ca33

Please sign in to comment.