Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer overrun in procedure ReadLn in unit QLexLib #6

Open
GoogleCodeExporter opened this issue May 27, 2015 · 1 comment
Open

Buffer overrun in procedure ReadLn in unit QLexLib #6

GoogleCodeExporter opened this issue May 27, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

Subprocedure CheckBuffer in procedure ReadLn (unit QLexLib) doesn't take into 
account SizeOf(Char) when checking buffer size and allocating buffer. Existing 
procedure should be changed to

  procedure CheckBuffer;
  begin
    repeat
      //we need to take into account size of char - we are increasing
      //position in stream by SizeOf(char) and not by a byte
      if (i * SizeOf(Char)) >= (BufSize - SizeOf(Char)) then
      //(- SizeOf(Char) is needed if BufSize is odd number and
      //GetMem works in chunks of 1 byte
      begin
        BufSize := max (BufSize * 2, 256);
        ReallocMem (Buf, BufSize);
      end;
    until (i * SizeOf(Char)) < (BufSize - SizeOf(Char));
  end;

Original issue reported on code.google.com by greg....@gmail.com on 27 Jul 2010 at 10:48

@GoogleCodeExporter
Copy link
Author

This helped me. Thanks Greg. I had this same exact problem. Your code fix 
worked like a champ!
Regards,
Tony Marelich

Original comment by tmarel...@gmail.com on 12 Oct 2010 at 5:48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant