MCPcopy Create free account
hub / github.com/OISF/libhtp / txDiff

Function txDiff

test/fuzz/fuzz_diff.c:306–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306static int txDiff(void* rstx, htp_tx_t * ctx) {
307 if (bstrDiff(htp_tx_request_method(rstx), ctx->request_method, "methods")) {
308#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
309 abort();
310#endif
311 return 1;
312 }
313 if (bstrDiff(htp_tx_request_uri(rstx), ctx->request_uri, "uri")) {
314#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
315 abort();
316#endif
317 return 1;
318 }
319 if (bstrDiff(htp_tx_request_protocol(rstx), ctx->request_protocol, "protocol_request")) {
320#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
321 abort();
322#endif
323 return 1;
324 }
325 if (bstrDiff(htp_tx_response_protocol(rstx), ctx->response_protocol, "protocol_response")) {
326#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
327 abort();
328#endif
329 return 1;
330 }
331 if (bstrDiff(htp_tx_response_status(rstx), ctx->response_status, "status")) {
332#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
333 abort();
334#endif
335 return 1;
336 }
337
338 uint32_t nbhc = htp_table_size(ctx->request_headers);
339 uint32_t rsnbh = htp_tx_request_headers_size(rstx);
340 if (rsnbh != nbhc) {
341 printf("Assertion failure: got nbheaders c=%d versus rust=%d\n", nbhc, rsnbh);
342 fflush(stdout);
343#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
344 abort();
345#endif
346 return 1;
347 }
348
349 for (uint32_t i = 0; i < nbhc; i++) {
350 htp_header_t *h = (htp_header_t *) htp_table_get_index(ctx->request_headers, i, NULL);
351 void *rsh = htp_tx_request_header_index(rstx, (size_t) i);
352 if (bstrDiff(htp_header_name(rsh), h->name, "header-name")) {
353 printf("request header name %d is different\n", i);
354 fflush(stdout);
355#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
356 abort();
357#endif
358 return 1;
359 }
360 if (bstrDiff(htp_header_value(rsh), h->value, "header-value")) {
361 printf("request header value %d is different\n", i);
362 fflush(stdout);
363#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION

Callers 1

connDiffFunction · 0.85

Calls 3

bstrDiffFunction · 0.85
htp_table_sizeFunction · 0.85
htp_table_get_indexFunction · 0.85

Tested by

no test coverage detected