View Issue Details

IDProjectCategoryView StatusLast Update
0037448FPCPackagespublic2020-08-02 17:19
ReporterTaufik Rahmad Hidayanto Assigned ToSven Barth  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformWindowsOSWindows 
Fixed in Version3.3.1 
Summary0037448: custHTTPSys Invalid Length Http reason string, know header length and unknown header length
Descriptionresp.ReasonLength not yet set, this will make httpsys send empty response string (only send Status Code)

the +1 in the following code make additional null terminated string in http header name and http header value
resp.Headers.KnownHeaders[Ord(headerid)].RawValueLength := Length(headerval) + 1;
unknownheadersarr[i].NameLength := Length(headerstr) + 1;
unknownheadersarr[i].RawValueLength := Length(headerval) + 1;

example output http header:
Content-Type: text/html[null][CRLF]
Status[null]: 200 OK[null][CRLF]
Steps To Reproducefix http reason string length
if CodeText <> '' then
  begin
    resp.pReason := PChar(CodeText);
    resp.ReasonLength := Length(CodeText);
  end;

fix http know header value length:
resp.Headers.KnownHeaders[Ord(headerid)].RawValueLength := Length(headerval);

fix http unknown header name length:
unknownheadersarr[i].NameLength := Length(headerstr);

fix http unknown header value length:
unknownheadersarr[i].RawValueLength := Length(headerval);
Additional Informationcheck file diff
TagsNo tags attached.
Fixed in Revision45991
FPCOldBugId
FPCTarget-
Attached Files

Activities

Taufik Rahmad Hidayanto

2020-07-30 03:16

reporter  

filedifference.diff (1,941 bytes)   
***************
*** 250,259 ****
    resp.Version := fRequestVersion;
    resp.StatusCode := Code;
    if CodeText <> '' then
-   begin
      resp.pReason := PChar(CodeText);
-     resp.ReasonLength := Length(CodeText); // fixed
-   end;
  
    flags := 0;
    if (Assigned(ContentStream) and (ContentStream.Size > 0)) or (Contents.Count > 0) then
--- 250,256 ----
***************
*** 294,300 ****
  
        headerstrs.Add(headerval);
  
!       resp.Headers.KnownHeaders[Ord(headerid)].RawValueLength := Length(headerval); // fixed
        resp.Headers.KnownHeaders[Ord(headerid)].pRawValue := PAnsiChar(headerstrs[headerstrs.Count - 1]);
      end;
  
--- 291,297 ----
  
        headerstrs.Add(headerval);
  
!       resp.Headers.KnownHeaders[Ord(headerid)].RawValueLength := Length(headerval) + 1;
        resp.Headers.KnownHeaders[Ord(headerid)].pRawValue := PAnsiChar(headerstrs[headerstrs.Count - 1]);
      end;
  
***************
*** 304,314 ****
        headerval := unknownheaders.ValueFromIndex[i];
  
        headerstrs.Add(headerstr);
!       unknownheadersarr[i].NameLength := Length(headerstr); // fixed
        unknownheadersarr[i].pName := PAnsiChar(headerstrs[headerstrs.Count - 1]);
  
        headerstrs.Add(headerval);
!       unknownheadersarr[i].RawValueLength := Length(headerval); // fixed
        unknownheadersarr[i].pRawValue := PAnsiChar(headerstrs[headerstrs.Count - 1]);
      end;
  
--- 301,311 ----
        headerval := unknownheaders.ValueFromIndex[i];
  
        headerstrs.Add(headerstr);
!       unknownheadersarr[i].NameLength := Length(headerstr) + 1;
        unknownheadersarr[i].pName := PAnsiChar(headerstrs[headerstrs.Count - 1]);
  
        headerstrs.Add(headerval);
!       unknownheadersarr[i].RawValueLength := Length(headerval) + 1;
        unknownheadersarr[i].pRawValue := PAnsiChar(headerstrs[headerstrs.Count - 1]);
      end;
  
filedifference.diff (1,941 bytes)   

Sven Barth

2020-08-02 17:19

manager   ~0124508

Thank you for the fixes. Please test and close if okay.

Issue History

Date Modified Username Field Change
2020-07-30 03:16 Taufik Rahmad Hidayanto New Issue
2020-07-30 03:16 Taufik Rahmad Hidayanto File Added: filedifference.diff
2020-08-02 16:44 Sven Barth Assigned To => Sven Barth
2020-08-02 16:44 Sven Barth Status new => assigned
2020-08-02 17:19 Sven Barth Status assigned => resolved
2020-08-02 17:19 Sven Barth Resolution open => fixed
2020-08-02 17:19 Sven Barth Fixed in Version => 3.3.1
2020-08-02 17:19 Sven Barth Fixed in Revision => 45991
2020-08-02 17:19 Sven Barth FPCTarget => -
2020-08-02 17:19 Sven Barth Note Added: 0124508