mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[CABMAN] Fix GCC13 buffer format overflow warning (#7408)
CORE-19724
sdk/tools/cabman/dfp.cxx:1136:36: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
1136 | sprintf(InfLine, "%s=%s", GetFileName(SrcName).c_str(), DstName);
| ^
sdk/tools/cabman/dfp.cxx:1136:20: note: 'sprintf' output 2 or more bytes (assuming 4097) into a destination of size 4096
This commit is contained in:
@@ -36,10 +36,15 @@
|
||||
#define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
|
||||
#endif
|
||||
|
||||
#ifndef _countof
|
||||
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#define DIR_SEPARATOR_CHAR '\\'
|
||||
#define DIR_SEPARATOR_STRING "\\"
|
||||
|
||||
#define snprintf _snprintf
|
||||
#define strcasecmp _stricmp
|
||||
#define strdup _strdup
|
||||
#else
|
||||
|
||||
@@ -1031,7 +1031,7 @@ ULONG CDFParser::PerformFileCopy()
|
||||
char ch;
|
||||
char SrcName[PATH_MAX];
|
||||
char DstName[PATH_MAX];
|
||||
char InfLine[PATH_MAX];
|
||||
char InfLine[PATH_MAX*2+1]; // To hold: GetFileName(SrcName) "=" DstName
|
||||
char Options[128];
|
||||
char BaseFilename[PATH_MAX];
|
||||
|
||||
@@ -1076,7 +1076,7 @@ ULONG CDFParser::PerformFileCopy()
|
||||
}
|
||||
|
||||
// options (it may be empty)
|
||||
SkipSpaces ();
|
||||
SkipSpaces();
|
||||
|
||||
if (CurrentToken != TokenEnd)
|
||||
{
|
||||
@@ -1133,12 +1133,13 @@ ULONG CDFParser::PerformFileCopy()
|
||||
switch (Status)
|
||||
{
|
||||
case CAB_STATUS_SUCCESS:
|
||||
sprintf(InfLine, "%s=%s", GetFileName(SrcName).c_str(), DstName);
|
||||
snprintf(InfLine, _countof(InfLine) - 1,
|
||||
"%s=%s", GetFileName(SrcName).c_str(), DstName);
|
||||
WriteInfLine(InfLine);
|
||||
break;
|
||||
|
||||
case CAB_STATUS_CANNOT_OPEN:
|
||||
if (strstr(Options,"optional"))
|
||||
if (strstr(Options, "optional"))
|
||||
{
|
||||
Status = CAB_STATUS_SUCCESS;
|
||||
printf("Optional file skipped (does not exist): %s.\n", SrcName);
|
||||
|
||||
Reference in New Issue
Block a user