ContentData field size in FCGI_ContentRecord of fastcgi unit

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

ContentData field size in FCGI_ContentRecord of fastcgi unit

Free Pascal - General mailing list
From fastcgi.pp



In line 510

FCGI_ContentRecord = record
    header : FCGI_Header;
    ContentData : array[0..1023] of byte;
end;

Field ContentData is 1024 bytes. Actual ContentData length is related to field ContentLength of FCGI_Header. ContentLength is declared as word type to conform with FastCGI specification. So maximum ContentLength is 65536 bytes.

According  to FastCGI specification,


"contentData: Between 0 and 65535 bytes of data, interpreted according to the record type."

Why fastcgi.pp declared it as array[0..1023] of byte instead of array[0.. 65535] of byte ?




_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: ContentData field size in FCGI_ContentRecord of fastcgi unit

Michael Van Canneyt


On Sat, 18 May 2019, Zamrony P. Juhara via fpc-pascal wrote:

>> From fastcgi.pp
>
> https://github.com/graemeg/freepascal/blob/master/packages/fastcgi/src/fastcgi.pp
>
> In line 510
> FCGI_ContentRecord = record
>     header : FCGI_Header;
>     ContentData : array[0..1023] of byte;
> end;
> Field ContentData is 1024 bytes. Actual ContentData length is related to field ContentLength of FCGI_Header. ContentLength is declared as word type to conform with FastCGI specification. So maximum ContentLength is 65536 bytes.
>
> According  to FastCGI specification,
>
> http://www.mit.edu/~yandros/doc/specs/fcgi-spec.html
> "contentData: Between 0 and 65535 bytes of data, interpreted according to the record type."
>
> Why fastcgi.pp declared it as array[0..1023] of byte instead of array[0.. 65535] of byte ?
This unit is a translation of a library. Most likely, that was exactly the
value specified in the original header files.

I would not recommend using this unit.
It is most likely outdated, and I would not even know what library it supports.
I will ask on the core group what to do, I think it is better to remove it.

Free Pascal supports fastcgi natively using the custfcgi or fpfcgi units.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: ContentData field size in FCGI_ContentRecor

Free Pascal - General mailing list
custfcgi.pp and fpfcgi.pp both directly /indirectly depends on fastcgi unit.

Zamrony P. Juhara

On Sat, May 18, 2019 at 16:54, Michael Van Canneyt


On Sat, 18 May 2019, Zamrony P. Juhara via fpc-pascal wrote:

>> From fastcgi.pp
>
> https://github.com/graemeg/freepascal/blob/master/packages/fastcgi/src/fastcgi.pp
>
> In line 510
> FCGI_ContentRecord = record
>     header : FCGI_Header;
>     ContentData : array[0..1023] of byte;
> end;
> Field ContentData is 1024 bytes. Actual ContentData length is related to field ContentLength of FCGI_Header. ContentLength is declared as word type to conform with FastCGI specification. So maximum ContentLength is 65536 bytes.
>
> According  to FastCGI specification,
>
> http://www.mit.edu/~yandros/doc/specs/fcgi-spec.html
> "contentData: Between 0 and 65535 bytes of data, interpreted according to the record type."
>
> Why fastcgi.pp declared it as array[0..1023] of byte instead of array[0.. 65535] of byte ?

This unit is a translation of a library. Most likely, that was exactly the
value specified in the original header files.

I would not recommend using this unit.
It is most likely outdated, and I would not even know what library it supports.
I will ask on the core group what to do, I think it is better to remove it.

Free Pascal supports fastcgi natively using the custfcgi or fpfcgi units.

Michael.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Untitled (230 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: ContentData field size in FCGI_ContentRecor

Michael Van Canneyt


On Sat, 18 May 2019, Zamrony P. Juhara via fpc-pascal wrote:

> custfcgi.pp and fpfcgi.pp both directly /indirectly depends on fastcgi unit.

AFAIK this dependency can be removed, if it exists.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: ContentData field size in FCGI_ContentRecor

Free Pascal - General mailing list
I do not think so, because custfpcgi.pp is using many const and types declared in fastcgi.pp. removing it will cause rewrite in many parts of custfcgi units

Zamrony P. Juhara

On Sat, May 18, 2019 at 17:36, Michael Van Canneyt


On Sat, 18 May 2019, Zamrony P. Juhara via fpc-pascal wrote:

> custfcgi.pp and fpfcgi.pp both directly /indirectly depends on fastcgi unit.

AFAIK this dependency can be removed, if it exists.


Michael.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: ContentData field size in FCGI_ContentRecor

Michael Van Canneyt


On Sat, 18 May 2019, Zamrony P. Juhara via fpc-pascal wrote:

> I do not think so, because custfpcgi.pp is using many const and types declared in fastcgi.pp. removing it will cause rewrite in many parts of custfcgi units

You are right.

I should not try to answer questions based on memory alone :(

I did some digging and here is the long explanation:

The record definition is a formal record definition.
The buffer was defined as 1024 bytes (1K), but this is completely arbitrary.
It could have been [0..0], or [0..MaxInt].
Probably [0..0] would have been better.
I will change it to that.

In practice a FCGI_ContentRecord is never used. A PFCGI_ContentRecord
(pointer to) is used to typecast an array of byte and extract the
necessary header fields from the array.

It's a little like the typinfo structures: they describe memory layouts, but
some structures are just formal, for example

TVmtFieldTable =   record
         Count: Word;
         ClassTab: PVmtFieldClassTab;
         { should be array[Word] of TFieldInfo;  but
           Elements have variant size! force at least proper alignment }
         Fields: array[0..0] of TVmtFieldEntry;
       end;

The FCGI_ContentRecord definition should be seen in the same light: a formal
definition.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal