mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-04-19 07:37:12 +00:00
Coverity: tackled a few CIDs (#470)
This commit is contained in:
@@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "StdAfx.h"
|
||||
|
||||
#include "Applewin.h"
|
||||
#include "Frame.h" // g_hFrameWindow
|
||||
#include "Memory.h"
|
||||
#include "ParallelPrinter.h"
|
||||
#include "Registry.h"
|
||||
@@ -234,14 +235,26 @@ char* Printer_GetFilename()
|
||||
|
||||
void Printer_SetFilename(char* prtFilename)
|
||||
{
|
||||
if(*prtFilename)
|
||||
if (*prtFilename)
|
||||
{
|
||||
strcpy(g_szPrintFilename, (const char *) prtFilename);
|
||||
}
|
||||
else //No registry entry is available
|
||||
{
|
||||
_tcsncpy(g_szPrintFilename, g_sProgramDir, MAX_PATH);
|
||||
g_szPrintFilename[MAX_PATH - 1] = 0;
|
||||
_tcsncat(g_szPrintFilename, _T(DEFAULT_PRINT_FILENAME), MAX_PATH);
|
||||
RegSaveString(TEXT("Configuration"),REGVALUE_PRINTER_FILENAME,1,g_szPrintFilename);
|
||||
|
||||
// NB. _tcsncat_s() terminates program if buffer is too small! So continue to use manual buffer check & _tcsncat()
|
||||
|
||||
int nLen = sizeof(g_szPrintFilename) - strlen(g_szPrintFilename) - (sizeof(DEFAULT_PRINT_FILENAME)-1) - 1;
|
||||
if (nLen < 0)
|
||||
{
|
||||
MessageBox(g_hFrameWindow, "Printer - SetFilename(): folder too deep", "Warning", MB_ICONWARNING | MB_OK);
|
||||
return;
|
||||
}
|
||||
|
||||
_tcsncat(g_szPrintFilename, DEFAULT_PRINT_FILENAME, sizeof(DEFAULT_PRINT_FILENAME)-1);
|
||||
RegSaveString(REG_CONFIG, REGVALUE_PRINTER_FILENAME, 1, g_szPrintFilename);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user