Skip to content

TRequest.Content contains invalid data after commits 1f74ca0d of httpdefs.pp

Summary

I had to recompile an old FastCGI module to fix a minor bug. I installed the current release of FPC. The module now has an issue with TRequest.Content data. Now the returned data looks to be read starting from one byte BEFORE the actual content, and the last byte is missing, as if the offset of the actual data is computed incorrectly, while the content lenght is correct.

System Information

  • Operating system: CentOS 7.9.2009 (fully updated to date), Apache 2.4, mod_fcgid - but observed under Ubuntu 20 LTS as well.
  • Processor architecture: x86-64
  • Compiler version: 3.3.1
  • Device: Computer

Steps to reproduce

Build a FastCGI application with Apache 2.4 and mod_fcgid, send for example a JSON-encoded content, the content starts with byte $00 and the last brace is missing. Recompiling with an old build machine created in 2019 the Request content is correct - need to check the FPC version there. It looks changes in commit 1f74ca0d triggered this issue.

Example Project

See the attached test_request.zip file. It contains: An example FastCGI problem showing the issue - it returns the Request content in the Response content An Apache 2.4 configuration file for the FastCGI module A Python 3 script to show the issues, sending a JSON payload and printing the response content.

What is the current bug behavior?

The TRequest content is not valid, for example sending a JSON encoded content the fist byte is $00 and the last brace is missing, as if the buffer is read starting from a byte before the actual content.

What is the expected (correct) behavior?

The content is the correct content passed to the web request

Relevant logs and/or screenshots

N/A

Possible fixes

Line 2773 (or around) of httpdefs.pp, change:

Move(Buf, FStreamingContent[CL + 1], Size)

to:

Move(Buf, FStreamingContent[CL], Size)

test_request.zip

Edited by Kent Morwath
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information