Site icon Embarcadero RAD Studio, Delphi, & C++Builder Blogs

Buffer Overflow in the C/C++ RTL

We recently identified a potential buffer overflow in the C/C++ runtime library (RTL). Although this is an issue that was introduced to the code in 1997 with no exploitation since its introduction, we are publishing a notification and a fix for safety and openness, out of an abundance of caution.

Issue information:

Recommended mitigation

Check if your source code uses any of these methods, and if so rebuild the RTL with the below patch applied, or if you use a version without source available or don’t want to / cannot rebuild the RTL, simply pass the method a pre-allocated buffer or replace usage of the method with the Windows API GetCurrentDirectory.

Patch

A patch, with the key lines highlighted (first a comment and second the affected line of code) is:
[crayon-66e86f92cacef938867431/]
Apply this to your copy of getdcwd.c, and rebuild the RTL following the instructions in the RTL source directory. For RAD Studio 12.1, you can download a prebuilt version of the RTL on my.embarcadero.com named “C++Builder and RAD Studio 12.1 C++ RTL Replacement”. If you have any issues, we recommend contacting Support.

Affected versions

The issue affects C++Builder 12.1 and earlier, including the Community Edition and Free Compiler. Future versions of C++Builder and RAD Studio will no longer have this issue.

Exit mobile version