67 lines
2.4 KiB
Plaintext
67 lines
2.4 KiB
Plaintext
$OpenBSD: patch-Source_cmSystemTools_cxx,v 1.5 2007/08/25 08:35:20 espie Exp $
|
|
--- Source/cmSystemTools.cxx.orig Mon Jul 16 23:12:31 2007
|
|
+++ Source/cmSystemTools.cxx Sun Aug 12 16:02:02 2007
|
|
@@ -1364,12 +1364,18 @@ class cmDeletingCharVector : public std::vector<char*>
|
|
}
|
|
};
|
|
|
|
+char* cmSystemTools::dupstring(const char* src)
|
|
+{
|
|
+ size_t sz = strlen(src)+1;
|
|
+ char* dest = new char[sz];
|
|
+ strlcpy(dest, src, sz);
|
|
+ return dest;
|
|
+}
|
|
|
|
bool cmSystemTools::PutEnv(const char* value)
|
|
{
|
|
static cmDeletingCharVector localEnvironment;
|
|
- char* envVar = new char[strlen(value)+1];
|
|
- strcpy(envVar, value);
|
|
+ char* envVar = dupstring(value);
|
|
int ret = putenv(envVar);
|
|
// save the pointer in the static vector so that it can
|
|
// be deleted on exit
|
|
@@ -1428,7 +1434,7 @@ std::string cmSystemTools::MakeXMLSafe(const char* str
|
|
&& ch != '\r' )
|
|
{
|
|
char buffer[33];
|
|
- sprintf(buffer, "<%d>", static_cast<int>(ch));
|
|
+ snprintf(buffer, sizeof buffer, "<%d>", static_cast<int>(ch));
|
|
//sprintf(buffer, "&#x%0x;", (unsigned int)ch);
|
|
result.insert(result.end(), buffer, buffer+strlen(buffer));
|
|
}
|
|
@@ -1579,9 +1585,8 @@ bool cmSystemTools::CreateTar(const char* outFileName,
|
|
};
|
|
|
|
// Ok, this libtar is not const safe. for now use auto_ptr hack
|
|
- char* realName = new char[ strlen(outFileName) + 1 ];
|
|
+ char* realName = dupstring(outFileName);
|
|
std::auto_ptr<char> realNamePtr(realName);
|
|
- strcpy(realName, outFileName);
|
|
if (tar_open(&t, realName,
|
|
(gzip? &gztype : NULL),
|
|
O_WRONLY | O_CREAT, 0644,
|
|
@@ -1651,9 +1656,8 @@ bool cmSystemTools::ExtractTar(const char* outFileName
|
|
};
|
|
|
|
// Ok, this libtar is not const safe. for now use auto_ptr hack
|
|
- char* realName = new char[ strlen(outFileName) + 1 ];
|
|
+ char* realName = dupstring(outFileName);
|
|
std::auto_ptr<char> realNamePtr(realName);
|
|
- strcpy(realName, outFileName);
|
|
if (tar_open(&t, realName,
|
|
(gzip? &gztype : NULL),
|
|
O_RDONLY
|
|
@@ -1705,9 +1709,8 @@ bool cmSystemTools::ListTar(const char* outFileName,
|
|
};
|
|
|
|
// Ok, this libtar is not const safe. for now use auto_ptr hack
|
|
- char* realName = new char[ strlen(outFileName) + 1 ];
|
|
+ char* realName = dupstring(outFileName);
|
|
std::auto_ptr<char> realNamePtr(realName);
|
|
- strcpy(realName, outFileName);
|
|
if (tar_open(&t, realName,
|
|
(gzip? &gztype : NULL),
|
|
O_RDONLY
|