From 8e586f5810bc486ac1990d92e050cf01912ee573 Mon Sep 17 00:00:00 2001 From: Oliver Kurth Date: Thu, 23 Sep 2021 22:15:56 +0000 Subject: [PATCH] replace path building with TDNFAllocateStringPrintf() with TDNFJoin() --- client/api.c | 41 ++++++------ client/config.c | 5 +- client/gpgcheck.c | 15 ++--- client/init.c | 15 ++--- client/plugins.c | 8 +-- client/remoterepo.c | 40 +++++------- client/repo.c | 147 +++++++++++++++++++++++--------------------- client/repolist.c | 8 +-- client/repoutils.c | 33 +++++----- client/utils.c | 8 +-- solv/tdnfrepo.c | 6 +- 11 files changed, 164 insertions(+), 162 deletions(-) diff --git a/client/api.c b/client/api.c index 7444c686..ef25d09a 100644 --- a/client/api.c +++ b/client/api.c @@ -301,11 +301,11 @@ TDNFCheckLocalPackages( { continue; } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszRPMPath, - "%s/%s", pszLocalPath, - pEnt->d_name); + pEnt->d_name, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwPkgAdded = repo_add_rpm( @@ -660,9 +660,10 @@ TDNFOpenHandle( { int nIsDir = 0; - dwError = TDNFAllocateStringPrintf(&pszCacheDir, "%s/%s", - pTdnf->pArgs->pszInstallRoot, - pTdnf->pConf->pszCacheDir); + dwError = TDNFJoinPath(&pszCacheDir, + pTdnf->pArgs->pszInstallRoot, + pTdnf->pConf->pszCacheDir, + NULL); BAIL_ON_TDNF_ERROR(dwError); TDNF_SAFE_FREE_MEMORY(pTdnf->pConf->pszCacheDir); @@ -671,9 +672,10 @@ TDNFOpenHandle( if (!nHasOptReposdir) { - dwError = TDNFAllocateStringPrintf(&pszRepoDir, "%s/%s", - pTdnf->pArgs->pszInstallRoot, - pTdnf->pConf->pszRepoDir); + dwError = TDNFJoinPath(&pszRepoDir, + pTdnf->pArgs->pszInstallRoot, + pTdnf->pConf->pszRepoDir, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFIsDir(pszRepoDir, &nIsDir); @@ -1171,9 +1173,10 @@ TDNFRepoSync( { if (!pReposyncArgs->nNoRepoPath) { - dwError = TDNFAllocateStringPrintf(&pszDir, "%s/%s", - strcmp(pszRootPath, "/") ? pszRootPath : "", - pPkgInfo->pszRepoName); + dwError = TDNFJoinPath(&pszDir, + strcmp(pszRootPath, "/") ? pszRootPath : "", + pPkgInfo->pszRepoName, + NULL); BAIL_ON_TDNF_ERROR(dwError); } else @@ -1257,9 +1260,10 @@ TDNFRepoSync( } /* no need to check nNoRepoPath since we wouldn't get here */ - dwError = TDNFAllocateStringPrintf(&pszRepoDir, "%s/%s", - strcmp(pszRootPath, "/") ? pszRootPath : "", - pRepo->pszId); + dwError = TDNFJoinPath(&pszRepoDir, + strcmp(pszRootPath, "/") ? pszRootPath : "", + pRepo->pszId, + NULL); BAIL_ON_TDNF_ERROR(dwError); ret = nftw(pszRepoDir, _rm_rpms, 10, FTW_DEPTH|FTW_PHYS); @@ -1291,9 +1295,10 @@ TDNFRepoSync( const char *pszBasePath = pReposyncArgs->pszMetaDataPath ? pReposyncArgs->pszMetaDataPath : pszRootPath; - dwError = TDNFAllocateStringPrintf(&pszRepoDir, "%s/%s", - strcmp(pszBasePath, "/") ? pszBasePath : "", - pRepo->pszId); + dwError = TDNFJoinPath(&pszRepoDir, + strcmp(pszBasePath, "/") ? pszBasePath : "", + pRepo->pszId, + NULL); BAIL_ON_TDNF_ERROR(dwError); } else diff --git a/client/config.c b/client/config.c index 6262693f..607d4b6b 100644 --- a/client/config.c +++ b/client/config.c @@ -149,7 +149,7 @@ TDNFReadConfig( dwError = TDNFAllocateString(pszConfFile, &pszConfFileCopy); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszMinVersionsDir, "%s/minversions.d", dirname(pszConfFileCopy)); + dwError = TDNFJoinPath(&pszMinVersionsDir, dirname(pszConfFileCopy), "minversions.d", NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFReadMinVersionsFiles(pszMinVersionsDir, &pConf->ppszMinVersions); @@ -519,7 +519,8 @@ TDNFReadMinVersionsFiles( { continue; } - dwError = TDNFAllocateStringPrintf(&pszFile, "%s/%s", pszDir, pEnt->d_name); + dwError = TDNFAllocateStringPrintf(&pszFile, pszDir, pEnt->d_name); + dwError = TDNFJoinPath(&pszFile, pszDir, pEnt->d_name, NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFReadFileToStringArray(pszFile, &pppszArrayList[i]); diff --git a/client/gpgcheck.c b/client/gpgcheck.c index c7b41c42..fcb6b2c4 100644 --- a/client/gpgcheck.c +++ b/client/gpgcheck.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -580,22 +580,23 @@ TDNFFetchRemoteGPGKey( } BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszTopKeyCacheDir, - "%s/%s/keys", pTdnf->pConf->pszCacheDir, - pszRepoName); + pszRepoName, + "keys", + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFNormalizePath(pszTopKeyCacheDir, &pszRealTopKeyCacheDir); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszFilePath, - "%s/%s", pszRealTopKeyCacheDir, - pszKeyLocation); + pszKeyLocation, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFNormalizePath( diff --git a/client/init.c b/client/init.c index 71576144..871dae7f 100644 --- a/client/init.c +++ b/client/init.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -75,9 +75,10 @@ TDNFCloneCmdArgs( int nExists = 0; /* prepend installroot to tdnf.conf location */ - dwError = TDNFAllocateStringPrintf(&pszConfFileInstallRoot, "%s/%s", - pCmdArgsIn->pszInstallRoot, - TDNF_CONF_FILE); + dwError = TDNFJoinPath(&pszConfFileInstallRoot, + pCmdArgsIn->pszInstallRoot, + TDNF_CONF_FILE, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFIsFileOrSymlink(pszConfFileInstallRoot, &nExists); @@ -290,11 +291,11 @@ TDNFRefreshSack( //Check if expired since last sync per metadata_expire if(pRepo->lMetadataExpire >= 0) { - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszRepoCacheDir, - "%s/%s", pTdnf->pConf->pszCacheDir, - pRepo->pszId); + pRepo->pszId, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFShouldSyncMetadata( diff --git a/client/plugins.c b/client/plugins.c index 554b1e11..b7aaa7a7 100644 --- a/client/plugins.c +++ b/client/plugins.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2020-2021 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -314,11 +314,11 @@ _TDNFLoadPluginConfigs( continue; } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszPluginConfig, - "%s/%s", pConf->pszConfPath, - pEnt->d_name); + pEnt->d_name, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = _TDNFLoadPluginConfig(pszPluginConfig, &pPlugin); diff --git a/client/remoterepo.c b/client/remoterepo.c index 0797242d..22c870ed 100644 --- a/client/remoterepo.c +++ b/client/remoterepo.c @@ -890,10 +890,7 @@ TDNFCreatePackageUrl( BAIL_ON_TDNF_ERROR(dwError); if (pszBaseUrl) { - dwError = TDNFAllocateStringPrintf(&pszPackageUrl, - "%s/%s", - pszBaseUrl, - pszPackageLocation); + dwError = TDNFJoinPath(&pszPackageUrl, pszBaseUrl, pszPackageLocation, NULL); BAIL_ON_TDNF_ERROR(dwError); } else @@ -944,10 +941,10 @@ TDNFDownloadPackage( &pszCopyOfPackageLocation); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszPackageFile, - "%s/%s", - pszRpmCacheDir, - basename(pszCopyOfPackageLocation)); + dwError = TDNFJoinPath(&pszPackageFile, + pszRpmCacheDir, + basename(pszCopyOfPackageLocation), + NULL); BAIL_ON_TDNF_ERROR(dwError); /* don't download if file is already there. Older versions may have left @@ -1002,12 +999,11 @@ TDNFDownloadPackageToCache( BAIL_ON_TDNF_ERROR(dwError); } - dwError = TDNFAllocateStringPrintf( - &pszRpmCacheDir, - "%s/%s/%s", - pTdnf->pConf->pszCacheDir, - pszRepoName, - "rpms"); + dwError = TDNFJoinPath(&pszRpmCacheDir, + pTdnf->pConf->pszCacheDir, + pszRepoName, + "rpms", + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFNormalizePath(pszRpmCacheDir, @@ -1033,7 +1029,7 @@ TDNFDownloadPackageToCache( * TDNFDownloadPackageToTree() * * Download a package while preserving the directory path. For example, - * if pszPackageLocation is "RPMS/x86_64/foo-1.2-3.rpm, the destination will + * if pszPackageLocation is "RPMS/x86_64/foo-1.2-3.rpm", the destination will * be downloaded under the destination directory in RPMS/x86_64/foo-1.2-3.rpm * (so 'RPMS/x86_64/' will be preserved). */ @@ -1073,11 +1069,7 @@ TDNFDownloadPackageToTree( } BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf( - &pszFilePath, - "%s/%s", - pszNormalRpmCacheDir, - pszRemotePath); + dwError = TDNFJoinPath(&pszFilePath, pszNormalRpmCacheDir, pszRemotePath, NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFNormalizePath( @@ -1144,7 +1136,7 @@ TDNFDownloadPackageToTree( * TDNFDownloadPackageToDirectory() * * Download a package withou preserving the directory path. For example, - * if pszPackageLocation is "RPMS/x86_64/foo-1.2-3.rpm, the destination will + * if pszPackageLocation is "RPMS/x86_64/foo-1.2-3.rpm", the destination will * be downloaded under the destination directory (pszDirectory) as foo-1.2-3.rpm * (so RPMS/x86_64/ will be stripped). */ @@ -1184,11 +1176,7 @@ TDNFDownloadPackageToDirectory( pszFileName = basename(pszRemotePath); - dwError = TDNFAllocateStringPrintf( - &pszFilePath, - "%s/%s", - pszDirectory, - pszFileName); + TDNFJoinPath(&pszFilePath, pszDirectory, pszFileName, NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFDownloadPackage(pTdnf, pszPackageLocation, pszPkgName, diff --git a/client/repo.c b/client/repo.c index 8465d11d..559ce692 100644 --- a/client/repo.c +++ b/client/repo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -48,18 +48,18 @@ TDNFInitRepo( pConf = pTdnf->pConf; pPool = pSack->pPool; - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszRepoCacheDir, - "%s/%s", pConf->pszCacheDir, - pRepoData->pszId); + pRepoData->pszId, + NULL); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszRepoDataDir, - "%s/%s", pszRepoCacheDir, - TDNF_REPODATA_DIR_NAME); + TDNF_REPODATA_DIR_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFGetRepoMD(pTdnf, @@ -100,11 +100,11 @@ TDNFInitRepo( BAIL_ON_TDNF_ERROR(dwError); } pool_createwhatprovides(pPool); - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszLastRefreshMarker, - "%s/%s", pszRepoCacheDir, - TDNF_REPO_METADATA_MARKER); + TDNF_REPO_METADATA_MARKER, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFTouchFile(pszLastRefreshMarker); @@ -550,11 +550,12 @@ TDNFStoreBaseURLFromMetalink( BAIL_ON_TDNF_ERROR(dwError); } - dwError = TDNFAllocateStringPrintf(&pszBaseUrlFile, - "%s/%s/tmp/%s", - pTdnf->pConf->pszCacheDir, - pRepos->pszId, - TDNF_REPO_BASEURL_FILE_NAME); + dwError = TDNFJoinPath(&pszBaseUrlFile, + pTdnf->pConf->pszCacheDir, + pRepos->pszId, + "tmp", + TDNF_REPO_BASEURL_FILE_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFCreateAndWriteToFile(pszBaseUrlFile, pszRepoMDURL); @@ -619,10 +620,10 @@ TDNFDownloadUsingMetalinkResources( dwError = TDNFStoreBaseURLFromMetalink(pTdnf, pszRepo, buf); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszRepoMDUrl, - "%s/%s", - buf, - TDNF_REPO_METADATA_FILE_PATH); + dwError = TDNFJoinPath(&pszRepoMDUrl, + buf, + TDNF_REPO_METADATA_FILE_PATH, + NULL); BAIL_ON_TDNF_ERROR(dwError); *ppszRepoMDUrl = pszRepoMDUrl; break; @@ -710,16 +711,16 @@ TDNFGetRepoMD( nKeepCache = pTdnf->pConf->nKeepCache; - dwError = TDNFAllocateStringPrintf(&pszRepoMDFile, - "%s/%s", - pszRepoDataDir, - TDNF_REPO_METADATA_FILE_NAME); + dwError = TDNFJoinPath(&pszRepoMDFile, + pszRepoDataDir, + TDNF_REPO_METADATA_FILE_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszMetaLinkFile, - "%s/%s", - pszRepoDataDir, - TDNF_REPO_METALINK_FILE_NAME); + dwError = TDNFJoinPath(&pszMetaLinkFile, + pszRepoDataDir, + TDNF_REPO_METALINK_FILE_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFAllocateMemory( @@ -728,11 +729,11 @@ TDNFGetRepoMD( (void **)&pRepoMDRel); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pRepoMDRel->pszRepoCacheDir, - "%s/%s", pTdnf->pConf->pszCacheDir, - pRepoData->pszId); + pRepoData->pszId, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFAllocateString(pszRepoMDFile, &pRepoMDRel->pszRepoMD); @@ -741,10 +742,10 @@ TDNFGetRepoMD( dwError = TDNFAllocateString(pRepoData->pszId, &pRepoMDRel->pszRepo); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszBaseUrlFile, - "%s/%s", - pszRepoDataDir, - TDNF_REPO_BASEURL_FILE_NAME); + dwError = TDNFJoinPath(&pszBaseUrlFile, + pszRepoDataDir, + TDNF_REPO_BASEURL_FILE_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); if (metalink) { @@ -805,11 +806,12 @@ TDNFGetRepoMD( { pr_info("Refreshing metadata for: '%s'\n", pRepoData->pszName); /* always download to tmp */ - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszTmpRepoDataDir, - "%s/%s/tmp", pTdnf->pConf->pszCacheDir, - pRepoData->pszId); + pRepoData->pszId, + "tmp", + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFUtilsMakeDirs(pszTmpRepoDataDir); @@ -819,23 +821,23 @@ TDNFGetRepoMD( } BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszTmpRepoMDFile, - "%s/%s", pszTmpRepoDataDir, - TDNF_REPO_METADATA_FILE_NAME); + TDNF_REPO_METADATA_FILE_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); if (metalink) { - dwError = TDNFAllocateStringPrintf(&pszTmpRepoMetalinkFile, - "%s/%s", - pszTmpRepoDataDir, - TDNF_REPO_METALINK_FILE_NAME); + dwError = TDNFJoinPath(&pszTmpRepoMetalinkFile, + pszTmpRepoDataDir, + TDNF_REPO_METALINK_FILE_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszTempBaseUrlFile, - "%s/%s", - pszTmpRepoDataDir, - TDNF_REPO_BASEURL_FILE_NAME); + dwError = TDNFJoinPath(&pszTempBaseUrlFile, + pszTmpRepoDataDir, + TDNF_REPO_BASEURL_FILE_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFDownloadFile(pTdnf, pRepoData->pszId, pszRepoMetalink, pszTmpRepoMetalinkFile, pRepoData->pszId); @@ -896,10 +898,10 @@ TDNFGetRepoMD( else { // as BaseURL might have been reset - dwError = TDNFAllocateStringPrintf(&pszRepoMDUrl, - "%s/%s", - pRepoData->pszBaseUrl, - TDNF_REPO_METADATA_FILE_PATH); + dwError = TDNFJoinPath(&pszRepoMDUrl, + pRepoData->pszBaseUrl, + TDNF_REPO_METADATA_FILE_PATH, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFDownloadFile( pTdnf, @@ -1378,10 +1380,10 @@ TDNFDownloadMetadata( Pool *pPool = NULL; FILE *fp = NULL; - dwError = TDNFAllocateStringPrintf(&pszRepoMDUrl, - "%s/%s", - pRepo->pszBaseUrl, - TDNF_REPO_METADATA_FILE_PATH); + dwError = TDNFJoinPath(&pszRepoMDUrl, + pRepo->pszBaseUrl, + TDNF_REPO_METADATA_FILE_PATH, + NULL); BAIL_ON_TDNF_ERROR(dwError); if (!nPrintOnly) @@ -1389,15 +1391,18 @@ TDNFDownloadMetadata( dwError = TDNFUtilsMakeDir(pszRepoDir); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszRepoDataDir, "%s/repodata", - pszRepoDir); + dwError = TDNFJoinPath(&pszRepoDataDir, + pszRepoDir, + "repodata", + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFUtilsMakeDir(pszRepoDataDir); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszRepoMDPath, "%s/%s", - pszRepoDataDir, TDNF_REPO_METADATA_FILE_NAME); + dwError = TDNFJoinPath(&pszRepoMDPath, + pszRepoDataDir, TDNF_REPO_METADATA_FILE_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFDownloadFile(pTdnf, pRepo->pszId, pszRepoMDUrl, pszRepoMDPath, pRepo->pszId); @@ -1406,12 +1411,12 @@ TDNFDownloadMetadata( else { /* if printing only we use the already downloaded repomd.xml */ - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszRepoMDPath, - "%s/%s/%s", pTdnf->pConf->pszCacheDir, pRepo->pszId, - TDNF_REPO_METADATA_FILE_PATH); + TDNF_REPO_METADATA_FILE_PATH, + NULL); BAIL_ON_TDNF_ERROR(dwError); pr_info("%s\n", pszRepoMDUrl); @@ -1505,16 +1510,16 @@ TDNFDownloadRepoMDParts( SOLVID_POS, REPOSITORY_REPOMD_LOCATION); - dwError = TDNFAllocateStringPrintf(&pszPartUrl, - "%s/%s", - pRepo->pszBaseUrl, - pszPartFile); + dwError = TDNFJoinPath(&pszPartUrl, + pRepo->pszBaseUrl, + pszPartFile, + NULL); BAIL_ON_TDNF_ERROR(dwError); - dwError = TDNFAllocateStringPrintf(&pszPartPath, - "%s/%s", - pszDir, - pszPartFile); + dwError = TDNFJoinPath(&pszPartPath, + pszDir, + pszPartFile, + NULL); BAIL_ON_TDNF_ERROR(dwError); if (!nPrintOnly) diff --git a/client/repolist.c b/client/repolist.c index 75eb70a3..5b8d9aec 100644 --- a/client/repolist.c +++ b/client/repolist.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2020 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -90,11 +90,11 @@ TDNFLoadRepoData( continue; } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszRepoFilePath, - "%s/%s", pConf->pszRepoDir, - pEnt->d_name); + pEnt->d_name, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFLoadReposFromFile(pTdnf, pszRepoFilePath, &pRepos); diff --git a/client/repoutils.c b/client/repoutils.c index 1151408a..39dc1ab2 100644 --- a/client/repoutils.c +++ b/client/repoutils.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2017 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -202,12 +202,12 @@ TDNFRepoGetRpmCacheDir( BAIL_ON_TDNF_ERROR(dwError); } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszRpmCacheDir, - "%s/%s/%s", pTdnf->pConf->pszCacheDir, pszRepoId, - TDNF_RPM_CACHE_DIR_NAME); + TDNF_RPM_CACHE_DIR_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); if(access(pszRpmCacheDir, F_OK)) @@ -247,12 +247,12 @@ TDNFRepoRemoveCache( BAIL_ON_TDNF_ERROR(dwError); } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszRepoCacheDir, - "%s/%s/%s", pTdnf->pConf->pszCacheDir, pszRepoId, - TDNF_REPODATA_DIR_NAME); + TDNF_REPODATA_DIR_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFRecursivelyRemoveDir(pszRepoCacheDir); @@ -345,12 +345,12 @@ TDNFRemoveLastRefreshMarker( BAIL_ON_TDNF_ERROR(dwError); } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszLastRefreshMarker, - "%s/%s/%s", pTdnf->pConf->pszCacheDir, pszRepoId, - TDNF_REPO_METADATA_MARKER); + TDNF_REPO_METADATA_MARKER, + NULL); BAIL_ON_TDNF_ERROR(dwError); if (pszLastRefreshMarker) { @@ -382,12 +382,12 @@ TDNFRemoveSolvCache( BAIL_ON_TDNF_ERROR(dwError); } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszSolvCacheDir, - "%s/%s/%s", pTdnf->pConf->pszCacheDir, pszRepoId, - TDNF_SOLVCACHE_DIR_NAME); + TDNF_SOLVCACHE_DIR_NAME, + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFRecursivelyRemoveDir(pszSolvCacheDir); @@ -419,11 +419,12 @@ TDNFRemoveKeysCache( BAIL_ON_TDNF_ERROR(dwError); } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszKeysDir, - "%s/%s/keys", pTdnf->pConf->pszCacheDir, - pszRepoId); + pszRepoId, + "keys", + NULL); BAIL_ON_TDNF_ERROR(dwError); dwError = TDNFRecursivelyRemoveDir(pszKeysDir); diff --git a/client/utils.c b/client/utils.c index 8b84f40c..77705ca5 100644 --- a/client/utils.c +++ b/client/utils.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2017 VMware, Inc. All Rights Reserved. + * Copyright (C) 2015-2021 VMware, Inc. All Rights Reserved. * * Licensed under the GNU Lesser General Public License v2.1 (the "License"); * you may not use this file except in compliance with the License. The terms @@ -626,11 +626,11 @@ TDNFShouldSyncMetadata( BAIL_ON_TDNF_ERROR(dwError); } - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszMarkerFile, - "%s/%s", pszRepoDataFolder, - TDNF_REPO_METADATA_MARKER); + TDNF_REPO_METADATA_MARKER, + NULL); BAIL_ON_TDNF_ERROR(dwError); //Look for the metadata marker file diff --git a/solv/tdnfrepo.c b/solv/tdnfrepo.c index fea19fd1..d98d9c7c 100644 --- a/solv/tdnfrepo.c +++ b/solv/tdnfrepo.c @@ -564,12 +564,12 @@ SolvCreateMetaDataCache( } pRepo = pSolvRepoInfo->pRepo; - dwError = TDNFAllocateStringPrintf( + dwError = TDNFJoinPath( &pszSolvCacheDir, - "%s/%s/%s", pSack->pszCacheDir, pRepo->name, - TDNF_SOLVCACHE_DIR_NAME); + TDNF_SOLVCACHE_DIR_NAME, + NULL); BAIL_ON_TDNF_LIBSOLV_ERROR(dwError); if (access(pszSolvCacheDir, W_OK| X_OK) != 0)