The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,740 other followers

Archive for August 19th, 2014

GitHub System Status

Posted by jpluimers on 2014/08/19

Any site should haveĀ a stat system like this:Ā GitHub System Status.

Posted in Development, DVCS - Distributed Version Control, git, Power User, Software Development, Source Code Management, Subversion/SVN | Leave a Comment »

Tom Lehrer – New Math Animated – YouTube

Posted by jpluimers on 2014/08/19

via:Ā Tom Lehrer – New Math Animated – YouTube.

Base 8 is like base 10 when you miss two fingers…

Posted in Comics | Leave a Comment »

Delphi and C++ Builder VCL Library Buffer Overflow

Posted by jpluimers on 2014/08/19

Since this did not make it to DelphiFeeds yet: I’ve seen the functionĀ PaletteFromDIBColorTable in Graphics.pasĀ go back as far at least until Delphi 2006, and references on the web as far back as Delphi 4.

So: this bug is old, but as it is a security one, make sure you patch soon.

For Delphi XE6, downloadĀ 29913 BMP Buffer Overflow hotfix – Delphi, C++Builder, RAD Studio XE6.

For older Delphi versions, read this piece that was adapted from the EDN article Delphi and C++ Builder VCL Library Buffer Overflow:

For users of prior versions of Delphi and C++Builder: these steps should be followed to modify the VCL source code and add it to your application.

For each application:

  1. Add the modifiedĀ Edit Vcl.Graphics.pas or Graphics.pas or Borland.Vcl.Graphics.pasĀ to your project
  2. For C++Builder: Under Project | Options | Packages | Runtime Packages, set ā€œLink with runtime packagesā€ to false
  3. Rebuild your application

Once for the native VCL and .NET VCL:

  • Note: Variable names and scoping might be slightly different depending on your product version.
  1. Edit Vcl.Graphics.pas or Graphics.pas or Borland.Vcl.Graphics.pas
  2. Locate the function PaletteFromDIBColorTable.
  3. Add the following code just before the line assigning a value to Pal.palNumEntries when the DIBHandle = 0
    if ColorCount > 256 then 
      InvalidGraphic{$IFNDEF CLR}@{$ENDIF}SInvalidBitmap;;

–jeroen

via Delphi and C++ Builder VCL Library Buffer Overflow.

Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Development, Software Development | Tagged: , , , | 5 Comments »

Delphi: (ab?)using managed types to help guarantee initialisation of stack record (via: Stack Overflow)

Posted by jpluimers on 2014/08/19

I mentioned DelphiĀ managed typesĀ is inĀ Delphi ā€œVariant Recordsā€, a few notesĀ indicating they are special.

Managed by the RTL, you can use them to your advantage when you have record types that – when on the stack – are only partially initialized by the RTL: only the managed types are initialized.

Given there is still no support to support “Initialize” and “Finalize” operators (vote for it onĀ [WayBack] QualityCentral) the best you can do was mentioned byĀ LU RDĀ (an alias a very smart Swedish guyĀ Leif UnĆ©us):

Add a dummy string member into your record. Since a string is a managed type it will be initialized to an empty string when the record comes in scope.

So when calling your Clear method, test if the dummy string is empty first. Set the string to a value when appropriate to the use logic to mark the record as initialized.

It reminded me of a managed types idea that former Delphi compiler engineer Barry Kelly once posed to me when I was struggling with the initialization state of nullable records: I wanted the default to be NULL, so I added an extra field managed field “IsInitialized” and the “IsNull” property would negate that field.

Use the Delphi compiler to your advantage (:

–jeroen

via:Ā delphi – Guarantee initialisation of stack record – Stack Overflow.

Posted in Delphi, Delphi XE2, Delphi XE3, Delphi XE4, Development, QC, Software Development | Leave a Comment »

 
%d bloggers like this: