Skip to content

Commit 1acb5ca

Browse files
committed
port: convert to safe path functions
1 parent 8125286 commit 1acb5ca

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

port/cpl_findfile.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ const char *CPLDefaultFindFile(const char *pszClass, const char *pszBasename)
139139

140140
for (int i = nLocations - 1; i >= 0; i--)
141141
{
142-
const char *pszResult = CPLFormFilename(
142+
const std::string osResult = CPLFormFilenameSafe(
143143
pTLSData->papszFinderLocations[i], pszBasename, nullptr);
144144

145145
VSIStatBufL sStat;
146-
if (VSIStatL(pszResult, &sStat) == 0)
147-
return pszResult;
146+
if (VSIStatL(osResult.c_str(), &sStat) == 0)
147+
return CPLSPrintf("%s", osResult.c_str());
148148
}
149149

150150
if (EQUAL(pszClass, "gdal") && !CPLGetConfigOption("GDAL_DATA", nullptr))

port/cpl_odbc.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,8 @@ bool CPLODBCDriverInstaller::FindMdbToolsDriverLib(CPLString &osDriverFile)
167167
if (VSIStat(pszDrvCfg, &sStatBuf) == 0 && VSI_ISDIR(sStatBuf.st_mode))
168168
{
169169
// Find default library in custom directory
170-
const char *pszDriverFile =
171-
CPLFormFilename(pszDrvCfg, "libmdbodbc.so", nullptr);
172-
CPLAssert(nullptr != pszDriverFile);
173-
174-
strLibPath = pszDriverFile;
170+
strLibPath =
171+
CPLFormFilenameSafe(pszDrvCfg, "libmdbodbc.so", nullptr);
175172
}
176173

177174
if (LibraryExists(strLibPath.c_str()))
@@ -216,14 +213,12 @@ bool CPLODBCDriverInstaller::FindMdbToolsDriverLib(CPLString &osDriverFile)
216213
{
217214
for (const char *pszLibName : apszLibNames)
218215
{
219-
const char *pszDriverFile =
220-
CPLFormFilename(pszPath, pszLibName, nullptr);
221-
CPLAssert(nullptr != pszDriverFile);
222-
223-
if (LibraryExists(pszDriverFile))
216+
const std::string osDriverFileAttempt =
217+
CPLFormFilenameSafe(pszPath, pszLibName, nullptr);
218+
if (LibraryExists(osDriverFileAttempt.c_str()))
224219
{
225220
// Save default driver path
226-
osDriverFile = pszDriverFile;
221+
osDriverFile = osDriverFileAttempt;
227222
return true;
228223
}
229224
}

port/cpl_vsil_s3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ VSIVirtualHandle *VSICurlFilesystemHandlerBaseWritable::Open(
17871787
return nullptr;
17881788
}
17891789

1790-
const std::string osTmpFilename(CPLGenerateTempFilename(nullptr));
1790+
const std::string osTmpFilename(CPLGenerateTempFilenameSafe(nullptr));
17911791
if (strchr(pszAccess, 'r'))
17921792
{
17931793
auto poExistingFile =

0 commit comments

Comments
 (0)