[Libreoffice] cppcheck : snprintf size is out of bounds

Norbert Thiebaud nthiebaud at gmail.com
Fri Nov 12 07:22:45 PST 2010



On Nov 12, 2010, at 7:16, Norbert Thiebaud <nthiebaud at gmail.com> wrote:

> 
> 
> On Nov 12, 2010, at 3:44, Julien <jnabet2412 at free.fr> wrote:
> 
>> Hello,
>> 
>> I'm currently running the last version of cppcheck (i updated with git this morning) and i get this error :
>> snprintf size is out of bounds
>> 
>> ex:
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:542]: (error) snprintf size is out of bounds
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:552]: (error) snprintf size is out of bounds
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:562]: (error) snprintf size is out of bounds
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:590]: (error) snprintf size is out of bounds
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:596]: (error) snprintf size is out of bounds
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:607]: (error) snprintf size is out of bounds
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:653]: (error) snprintf size is out of bounds
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:661]: (error) snprintf size is out of bounds
>> [./libs-gui/vcl/unx/source/printergfx/common_gfx.cxx:671]: (error) snprintf size is out of bounds
>> 
>> If i take the first line and i open the file, i see this :
>> void
>> PrinterGfx::DrawPolyLineBezier (sal_uInt32 nPoints, const Point* pPath, const BYTE* pFlgAry)
>> {
>>   const sal_uInt32 nBezString = 1024;
>>   sal_Char pString[nBezString];
>> 
>>   if ( nPoints > 1 && maLineColor.Is() && pPath )
>>   {
>>       PSSetColor (maLineColor);
>>       PSSetColor ();
>>       PSSetLineWidth ();
>> 
>>       snprintf(pString, nBezString, "%li %li moveto\n", pPath[0].X(), pPath[0].Y());
>> 
>> I don't understand where's the pb with snprintf, pString has a size of 1024 and snprintf takes a size of 1024.
> 
> pString has a size of 1025.
Never mind, too early in the morning, not thinking straight

> 
>> 
>> Is this a false positive to give to the cppcheck guys ?
>> 
>> Julien.
>> 
>> PS : is there a pb with my patch "[Libreoffice] [PATCH] RTL_CONSTASCII_USTRINGPARAM for calc_unoobj" ? if it's the case, don't hesitate to tell me, i'll correct it.
>> _______________________________________________
>> LibreOffice mailing list
>> LibreOffice at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/libreoffice


More information about the LibreOffice mailing list