Skip to content

Commit

Permalink
Merge to 1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Priyesh Padmavilasom committed Apr 26, 2016
2 parents 7b9d76c + 05877b3 commit 1a43f9c
Show file tree
Hide file tree
Showing 20 changed files with 178 additions and 127 deletions.
17 changes: 9 additions & 8 deletions client/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,16 @@ TDNFCheckLocalPackages(
pszRPMPath = g_build_filename(pszLocalPath, pszFile, NULL);
hPkg = hy_sack_add_cmdline_package(hSack, pszRPMPath);

g_free(pszRPMPath);
pszRPMPath = NULL;

if(!hPkg)
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
}
hy_packagelist_push(hPkgList, hPkg);
hPkg = NULL;

g_free(pszRPMPath);
pszRPMPath = NULL;
}

fprintf(stdout, "Found %d packages\n", hy_packagelist_count(hPkgList));
Expand Down Expand Up @@ -1023,12 +1023,13 @@ TDNFFreeCmdArgs(
TDNF_SAFE_FREE_MEMORY(pCmdArgs->ppszCmds[nIndex]);
}
TDNF_SAFE_FREE_MEMORY(pCmdArgs->ppszCmds);
}
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pszInstallRoot);
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pszConfFile);
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pszInstallRoot);
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pszConfFile);
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pszReleaseVer);

TDNF_SAFE_FREE_MEMORY(pCmdArgs->pSetOpt);
TDNF_SAFE_FREE_MEMORY(pCmdArgs);
TDNF_SAFE_FREE_MEMORY(pCmdArgs->pSetOpt);
TDNF_SAFE_FREE_MEMORY(pCmdArgs);
}
}

const char*
Expand Down
2 changes: 1 addition & 1 deletion client/clean.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TDNFCopyEnabledRepos(
return dwError;

error:
if(!pppszReposUsed)
if(pppszReposUsed)
{
*pppszReposUsed = NULL;
}
Expand Down
14 changes: 12 additions & 2 deletions client/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ TDNFApplyPackageFilter(
)
{
uint32_t dwError = 0;
int nCmpType = HY_GLOB;

if(!hQuery || !ppszPackageNameSpecs)
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
Expand All @@ -92,12 +94,20 @@ TDNFApplyPackageFilter(
{
if(TDNFIsGlob(*ppszPackageNameSpecs))
{
hy_query_filter(hQuery, HY_PKG_NAME, HY_GLOB, *ppszPackageNameSpecs);
nCmpType = HY_GLOB;
}
else
{
hy_query_filter(hQuery, HY_PKG_NAME, HY_EQ, *ppszPackageNameSpecs);
nCmpType = HY_EQ;
}

dwError = hy_query_filter(
hQuery,
HY_PKG_NAME,
nCmpType,
*ppszPackageNameSpecs);
BAIL_ON_TDNF_HAWKEY_ERROR(dwError);

++ppszPackageNameSpecs;
}

Expand Down
14 changes: 9 additions & 5 deletions client/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ TDNFReadConfig(
uint32_t dwError = 0;

GKeyFile* pKeyFile = NULL;
char* pszValue = NULL;

PTDNF_CONF pConf = NULL;

Expand Down Expand Up @@ -174,10 +173,6 @@ TDNFReadConfig(
{
g_key_file_free(pKeyFile);
}
if(pszValue)
{
g_free(pszValue);
}
return dwError;

error:
Expand Down Expand Up @@ -207,6 +202,15 @@ TDNFConfigExpandVars(
}
pConf = pTdnf->pConf;

//Allow --releasever overrides
if(!pConf->pszVarReleaseVer &&
!IsNullOrEmptyString(pTdnf->pArgs->pszReleaseVer))
{
dwError = TDNFAllocateString(pTdnf->pArgs->pszReleaseVer,
&pConf->pszVarReleaseVer);
BAIL_ON_TDNF_ERROR(dwError);
}

if(!pConf->pszVarReleaseVer &&
!IsNullOrEmptyString(pConf->pszDistroVerPkg))
{
Expand Down
81 changes: 50 additions & 31 deletions client/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,51 +37,67 @@ typedef enum
#define IsNullOrEmptyString(str) (!(str) || !(*str))

#define BAIL_ON_TDNF_ERROR(dwError) \
if (dwError) \
{ \
goto error; \
}
do { \
if (dwError) \
{ \
goto error; \
} \
} while(0)

#define BAIL_ON_TDNF_SYSTEM_ERROR(dwError) \
if (dwError) \
{ \
dwError = ERROR_TDNF_SYSTEM_BASE + dwError; \
goto error; \
}
do { \
if (dwError) \
{ \
dwError = ERROR_TDNF_SYSTEM_BASE + dwError; \
goto error; \
} \
} while(0)

#define BAIL_ON_TDNF_HAWKEY_ERROR(dwError) \
if (dwError) \
{ \
dwError = ERROR_TDNF_HAWKEY_BASE + dwError; \
goto error; \
}
do { \
if (dwError) \
{ \
dwError = ERROR_TDNF_HAWKEY_BASE + dwError; \
goto error; \
} \
} while(0)

#define BAIL_ON_TDNF_RPM_ERROR(dwError) \
if (dwError) \
{ \
dwError = ERROR_TDNF_RPM_BASE + dwError; \
goto error; \
}
do { \
if (dwError) \
{ \
dwError = ERROR_TDNF_RPM_BASE + dwError; \
goto error; \
} \
} while(0)

#define TDNF_SAFE_FREE_MEMORY(pMemory) \
if (pMemory) { \
TDNFFreeMemory(pMemory); \
}
do { \
if (pMemory) { \
TDNFFreeMemory(pMemory); \
} \
} while(0)

#define TDNF_SAFE_FREE_PKGLIST(hPkgList) \
if (hPkgList) { \
hy_packagelist_free(hPkgList); \
}
do { \
if (hPkgList) { \
hy_packagelist_free(hPkgList); \
} \
} while(0)

#define TDNF_SAFE_FREE_STRINGARRAY(ppArray) \
if (ppArray) { \
TDNFFreeStringArray(ppArray); \
}
do { \
if (ppArray) { \
TDNFFreeStringArray(ppArray); \
} \
} while(0)

#define TDNF_SAFE_FREE_PKGINFO(pPkgInfo) \
if (pPkgInfo) { \
TDNFFreePackageInfo(pPkgInfo); \
}
do { \
if (pPkgInfo) { \
TDNFFreePackageInfo(pPkgInfo); \
} \
} while(0)
//Misc
#define TDNF_RPM_EXT ".rpm"

Expand All @@ -101,6 +117,7 @@ typedef enum
#define TDNF_CONF_KEY_KEEP_CACHE "keepcache"
#define TDNF_CONF_KEY_DISTROVERPKG "distroverpkg"
#define TDNF_CONF_KEY_DISTROARCHPKG "distroarchpkg"
#define TDNF_CONF_KEY_MAX_STRING_LEN "maxstringlen"
//Repo file key names
#define TDNF_REPO_KEY_BASEURL "baseurl"
#define TDNF_REPO_KEY_ENABLED "enabled"
Expand All @@ -117,6 +134,7 @@ typedef enum
#define TDNF_DEFAULT_CACHE_LOCATION "/var/cache/tdnf"
#define TDNF_DEFAULT_DISTROVERPKG "photon-release"
#define TDNF_DEFAULT_DISTROARCHPKG "x86_64"
#define TDNF_DEFAULT_MAX_STRING_LEN 16384000
#define TDNF_RPM_CACHE_DIR_NAME "rpms"
#define TDNF_REPODATA_DIR_NAME "repodata"
//var names
Expand All @@ -138,6 +156,7 @@ typedef enum
{ERROR_TDNF_NO_DISTROVERPKG, "ERROR_TDNF_NO_DISTROVERPKG", "distroverpkg config entry is set to a package that is not installed. Check /etc/tdnf/tdnf.conf"}, \
{ERROR_TDNF_DISTROVERPKG_READ, "ERROR_TDNF_DISTROVERPKG_READ", "There was an error reading version of distroverpkg"}, \
{ERROR_TDNF_INVALID_ALLOCSIZE, "ERROR_TDNF_INVALID_ALLOCSIZE", "A memory allocation was requested with an invalid size"}, \
{ERROR_TDNF_STRING_TOO_LONG, "ERROR_TDNF_STRING_TOO_LONG", "Requested string allocation size was too long."}, \
{ERROR_TDNF_NO_ENABLED_REPOS, "ERROR_TDNF_NO_ENABLED_REPOS", "There are no enabled repos.\n Run ""tdnf repolist all"" to see the repos you have.\n You can enable repos by editing repo files in your repodir(usually /etc/yum.repos.d)"}, \
{ERROR_TDNF_PACKAGELIST_EMPTY, "ERROR_TDNF_PACKAGELIST_EMPTY", "Packagelist was empty"}, \
{ERROR_TDNF_GOAL_CREATE, "ERROR_TDNF_GOAL_CREATE", "Error creating goal"}, \
Expand Down
4 changes: 0 additions & 4 deletions client/goal.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,6 @@ TDNFGoalReportProblems(
}
}
cleanup:
if(pszProblem)
{
hy_free(pszProblem);
}
return dwError;

error:
Expand Down
7 changes: 7 additions & 0 deletions client/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ TDNFCloneCmdArgs(
BAIL_ON_TDNF_ERROR(dwError);
}

if(!IsNullOrEmptyString(pCmdArgsIn->pszReleaseVer))
{
dwError = TDNFAllocateString(
pCmdArgsIn->pszReleaseVer,
&pCmdArgs->pszReleaseVer);
BAIL_ON_TDNF_ERROR(dwError);
}

pCmdArgs->nCmdCount = pCmdArgsIn->nCmdCount;
dwError = TDNFAllocateMemory(
Expand Down
20 changes: 0 additions & 20 deletions client/packageutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ TDNFFindAvailablePkgByPkg(
{
*phPkg = NULL;
}
if(hPkg)
{
hy_package_free(hPkg);
}
goto cleanup;
}

Expand Down Expand Up @@ -205,10 +201,6 @@ TDNFFindInstalledPkgByName(
{
*phPkg = NULL;
}
if(hPkg)
{
hy_package_free(hPkg);
}
goto cleanup;
}

Expand Down Expand Up @@ -258,10 +250,6 @@ TDNFGetInstalled(
{
*phPkgList = NULL;
}
if(hPkgList)
{
hy_packagelist_free(hPkgList);
}
if(hQuery)
{
hy_query_free(hQuery);
Expand Down Expand Up @@ -315,10 +303,6 @@ TDNFMatchForReinstall(
{
*phPkgList = NULL;
}
if(hPkgList)
{
hy_packagelist_free(hPkgList);
}
if(hPkgAvailable)
{
hy_package_free(hPkgAvailable);
Expand Down Expand Up @@ -879,10 +863,6 @@ TDNFFilterPackages(
{
*phPkgList = NULL;
}
if(hPkgList)
{
hy_packagelist_free(hPkgList);
}
goto cleanup;
}

Expand Down
1 change: 1 addition & 0 deletions client/remoterepo.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ TDNFDownloadPackage(
fprintf(stdout, "\n");
cleanup:
TDNF_SAFE_FREE_MEMORY(pszBaseUrl);
TDNF_SAFE_FREE_MEMORY(pszUserPass);
if(pRepoHandle)
{
lr_handle_free(pRepoHandle);
Expand Down
19 changes: 12 additions & 7 deletions client/repoutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ TDNFRepoRemoveCache(
char* pszFilePath = NULL;
GDir* pDir = NULL;

if(!pTdnf || IsNullOrEmptyString(pszRepoId))
if(!pTdnf || !pTdnf->pConf || IsNullOrEmptyString(pszRepoId))
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
Expand Down Expand Up @@ -233,17 +233,22 @@ TDNFRepoRemoveCache(
while ((pszFile = g_dir_read_name (pDir)) != NULL)
{
pszFilePath = g_build_filename(pszRepoCacheDir, pszFile, NULL);

if(unlink(pszFilePath))
{
dwError = errno;
BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
}
if(pszFilePath)
{
if(unlink(pszFilePath))
{
dwError = errno;
BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
}

g_free(pszFilePath);
pszFilePath = NULL;
}
else
{
dwError = ERROR_TDNF_INVALID_PARAMETER;
BAIL_ON_TDNF_ERROR(dwError);
}
}
if(rmdir(pszRepoCacheDir))
{
Expand Down
14 changes: 13 additions & 1 deletion client/strings.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ TDNFAllocateString(
BAIL_ON_TDNF_ERROR(dwError);
}

if(strlen(pszSrc) > TDNF_DEFAULT_MAX_STRING_LEN)
{
dwError = ERROR_TDNF_STRING_TOO_LONG;
BAIL_ON_TDNF_ERROR(dwError);
}

pszDst = strdup(pszSrc);
if(!pszDst)
{
Expand Down Expand Up @@ -111,8 +117,14 @@ TDNFAllocateStringPrintf(
dwError = errno;
BAIL_ON_TDNF_SYSTEM_ERROR(dwError);
}

nSize = nSize + 1;

if(nSize > TDNF_DEFAULT_MAX_STRING_LEN)
{
dwError = ERROR_TDNF_STRING_TOO_LONG;
BAIL_ON_TDNF_ERROR(dwError);
}

dwError = TDNFAllocateMemory(1, nSize, (void**)&pszDst);
BAIL_ON_TDNF_ERROR(dwError);

Expand Down
Loading

0 comments on commit 1a43f9c

Please sign in to comment.