Fixed use of strncpy in xstrcpy()
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
//*** For the Windows SDK _tempnam function ***//
|
//*** For the Windows SDK _tempnam function ***//
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
//#else
|
||||||
|
//#include <unistd.h >
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
@@ -853,8 +855,8 @@ void adjustpattern(int *pat, int index)
|
|||||||
**----------------------------------------------------------------
|
**----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (*pat == index) *pat = 0;
|
if (*pat == index) *pat = 0;
|
||||||
else if (*pat > index) (*pat)--;
|
else if (*pat > index) (*pat)--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void adjustpatterns(Network *network, int index)
|
void adjustpatterns(Network *network, int index)
|
||||||
@@ -1092,6 +1094,13 @@ void getTmpName(char *fname)
|
|||||||
// --- for non-Windows systems:
|
// --- for non-Windows systems:
|
||||||
#else
|
#else
|
||||||
// --- use system function mkstemp() to create a temporary file name
|
// --- use system function mkstemp() to create a temporary file name
|
||||||
|
/*
|
||||||
|
int f = -1;
|
||||||
|
strcpy(fname, "enXXXXXX");
|
||||||
|
f = mkstemp(fname);
|
||||||
|
close(f);
|
||||||
|
remove(fname);
|
||||||
|
*/
|
||||||
strcpy(fname, "enXXXXXX");
|
strcpy(fname, "enXXXXXX");
|
||||||
FILE *f = fdopen(mkstemp(fname), "r");
|
FILE *f = fdopen(mkstemp(fname), "r");
|
||||||
if (f == NULL) strcpy(fname, "");
|
if (f == NULL) strcpy(fname, "");
|
||||||
@@ -1136,7 +1145,7 @@ char *xstrcpy(char **s1, const char *s2, const size_t n)
|
|||||||
if (n2 > n1) *s1 = realloc(*s1, (n2 + 1) * sizeof(char));
|
if (n2 > n1) *s1 = realloc(*s1, (n2 + 1) * sizeof(char));
|
||||||
|
|
||||||
// Copy the source string into the destination string
|
// Copy the source string into the destination string
|
||||||
strncpy(*s1, s2, n2);
|
strncpy(*s1, s2, n2+1);
|
||||||
return *s1;
|
return *s1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user