mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +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:
parent
10b08aa2bb
commit
a0f8b40d5a
2 changed files with 10 additions and 4 deletions
|
@ -36,10 +36,15 @@
|
||||||
#define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
|
#define C_ASSERT(expr) extern char (*c_assert(void)) [(expr) ? 1 : -1]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef _countof
|
||||||
|
#define _countof(_Array) (sizeof(_Array) / sizeof(_Array[0]))
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define DIR_SEPARATOR_CHAR '\\'
|
#define DIR_SEPARATOR_CHAR '\\'
|
||||||
#define DIR_SEPARATOR_STRING "\\"
|
#define DIR_SEPARATOR_STRING "\\"
|
||||||
|
|
||||||
|
#define snprintf _snprintf
|
||||||
#define strcasecmp _stricmp
|
#define strcasecmp _stricmp
|
||||||
#define strdup _strdup
|
#define strdup _strdup
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1031,7 +1031,7 @@ ULONG CDFParser::PerformFileCopy()
|
||||||
char ch;
|
char ch;
|
||||||
char SrcName[PATH_MAX];
|
char SrcName[PATH_MAX];
|
||||||
char DstName[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 Options[128];
|
||||||
char BaseFilename[PATH_MAX];
|
char BaseFilename[PATH_MAX];
|
||||||
|
|
||||||
|
@ -1076,7 +1076,7 @@ ULONG CDFParser::PerformFileCopy()
|
||||||
}
|
}
|
||||||
|
|
||||||
// options (it may be empty)
|
// options (it may be empty)
|
||||||
SkipSpaces ();
|
SkipSpaces();
|
||||||
|
|
||||||
if (CurrentToken != TokenEnd)
|
if (CurrentToken != TokenEnd)
|
||||||
{
|
{
|
||||||
|
@ -1133,12 +1133,13 @@ ULONG CDFParser::PerformFileCopy()
|
||||||
switch (Status)
|
switch (Status)
|
||||||
{
|
{
|
||||||
case CAB_STATUS_SUCCESS:
|
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);
|
WriteInfLine(InfLine);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAB_STATUS_CANNOT_OPEN:
|
case CAB_STATUS_CANNOT_OPEN:
|
||||||
if (strstr(Options,"optional"))
|
if (strstr(Options, "optional"))
|
||||||
{
|
{
|
||||||
Status = CAB_STATUS_SUCCESS;
|
Status = CAB_STATUS_SUCCESS;
|
||||||
printf("Optional file skipped (does not exist): %s.\n", SrcName);
|
printf("Optional file skipped (does not exist): %s.\n", SrcName);
|
||||||
|
|
Loading…
Reference in a new issue