Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
This commit is contained in:
parent
127c3856ba
commit
ac5dfef37e
61
64.patch
Normal file
61
64.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From f1a7d9b5e7ee493133daf608adaf80b10a87b915 Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Uiterwijk <puiterwijk@redhat.com>
|
||||
Date: Mon, 26 Sep 2016 12:45:25 +0000
|
||||
Subject: [PATCH 1/2] Make set_record act like a setter
|
||||
|
||||
This will make sure that when set_record is called, all existing
|
||||
records of the same type are removed.
|
||||
It makes no sense to have multiple records of the same type,
|
||||
and it actively breaks libhifs checksum validation.
|
||||
|
||||
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
|
||||
---
|
||||
src/repomd.c | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/src/repomd.c b/src/repomd.c
|
||||
index fea2c7e..3e79ccf 100644
|
||||
--- a/src/repomd.c
|
||||
+++ b/src/repomd.c
|
||||
@@ -682,6 +682,14 @@ cr_repomd_set_record(cr_Repomd *repomd,
|
||||
cr_RepomdRecord *record)
|
||||
{
|
||||
if (!repomd || !record) return;
|
||||
+
|
||||
+ cr_RepomdRecord *delrec = NULL;
|
||||
+ // Remove all existing record of the same type
|
||||
+ while((delrec = cr_repomd_get_record(repomd, record->type)) != NULL) {
|
||||
+ cr_repomd_detach_record(repomd, delrec);
|
||||
+ cr_repomd_record_free(delrec);
|
||||
+ }
|
||||
+
|
||||
repomd->records = g_slist_append(repomd->records, record);
|
||||
}
|
||||
|
||||
|
||||
From 5e44d23842d68e31e92498edeb6aba2e72a63abd Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Uiterwijk <puiterwijk@redhat.com>
|
||||
Date: Mon, 26 Sep 2016 12:48:31 +0000
|
||||
Subject: [PATCH 2/2] Add test to make sure that set_record overrides the
|
||||
current record
|
||||
|
||||
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
|
||||
---
|
||||
tests/python/tests/test_repomd.py | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/tests/python/tests/test_repomd.py b/tests/python/tests/test_repomd.py
|
||||
index 283dedc..6b6b3ad 100644
|
||||
--- a/tests/python/tests/test_repomd.py
|
||||
+++ b/tests/python/tests/test_repomd.py
|
||||
@@ -99,6 +99,10 @@ def test_repomd(self):
|
||||
|
||||
self.assertEqual(len(md.records), 1)
|
||||
|
||||
+ md.set_record(rec)
|
||||
+
|
||||
+ self.assertEqual(len(md.records), 1)
|
||||
+
|
||||
md.repoid = None
|
||||
md.contenthash = None
|
||||
|
66
66.patch
Normal file
66
66.patch
Normal file
@ -0,0 +1,66 @@
|
||||
From 35ae4edd9a6abef11fbdbfef5e717ba6eee6f8ee Mon Sep 17 00:00:00 2001
|
||||
From: Patrick Uiterwijk <puiterwijk@redhat.com>
|
||||
Date: Wed, 28 Sep 2016 12:09:07 +0000
|
||||
Subject: [PATCH] Close BZ2 compressed files on cr_close
|
||||
|
||||
Per bzip2 documentation: "BZ2_bzReadClose does not call fclose on the underlying file
|
||||
handle, so you should do that yourself if appropriate.".
|
||||
This patch adds a INNERFILE element to CR_FILE to keep track of the FILE object so we
|
||||
can properly close the file on cr_close.
|
||||
|
||||
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
|
||||
---
|
||||
src/compression_wrapper.c | 6 ++++++
|
||||
src/compression_wrapper.h | 1 +
|
||||
2 files changed, 7 insertions(+)
|
||||
|
||||
diff --git a/src/compression_wrapper.c b/src/compression_wrapper.c
|
||||
index aacaf90..adc2f39 100644
|
||||
--- a/src/compression_wrapper.c
|
||||
+++ b/src/compression_wrapper.c
|
||||
@@ -347,6 +347,7 @@ cr_sopen(const char *filename,
|
||||
file = g_malloc0(sizeof(CR_FILE));
|
||||
file->mode = mode;
|
||||
file->type = type;
|
||||
+ file->INNERFILE = NULL;
|
||||
|
||||
switch (type) {
|
||||
|
||||
@@ -380,6 +381,7 @@ cr_sopen(const char *filename,
|
||||
|
||||
case (CR_CW_BZ2_COMPRESSION): { // ------------------------------------
|
||||
FILE *f = fopen(filename, mode_str);
|
||||
+ file->INNERFILE = f;
|
||||
int bzerror;
|
||||
|
||||
if (!f) {
|
||||
@@ -405,6 +407,8 @@ cr_sopen(const char *filename,
|
||||
if (bzerror != BZ_OK) {
|
||||
const char *err_msg;
|
||||
|
||||
+ fclose(f);
|
||||
+
|
||||
switch (bzerror) {
|
||||
case BZ_CONFIG_ERROR:
|
||||
err_msg = "library has been mis-compiled";
|
||||
@@ -642,6 +646,8 @@ cr_close(CR_FILE *cr_file, GError **err)
|
||||
BZ2_bzWriteClose(&rc, (BZFILE *) cr_file->FILE,
|
||||
BZ2_SKIP_FFLUSH, NULL, NULL);
|
||||
|
||||
+ fclose(cr_file->INNERFILE);
|
||||
+
|
||||
if (rc == BZ_OK) {
|
||||
ret = CRE_OK;
|
||||
} else {
|
||||
diff --git a/src/compression_wrapper.h b/src/compression_wrapper.h
|
||||
index 910fd45..65022d9 100644
|
||||
--- a/src/compression_wrapper.h
|
||||
+++ b/src/compression_wrapper.h
|
||||
@@ -79,6 +79,7 @@ void cr_contentstat_free(cr_ContentStat *cstat, GError **err);
|
||||
typedef struct {
|
||||
cr_CompressionType type; /*!< Type of compression */
|
||||
void *FILE; /*!< Pointer to gzFile, BZFILE, ... */
|
||||
+ void *INNERFILE; /*!< Pointer to underlying FILE */
|
||||
cr_OpenMode mode; /*!< Mode */
|
||||
cr_ContentStat *stat; /*!< Content stats */
|
||||
cr_ChecksumCtx *checksum_ctx; /*!< Checksum contenxt */
|
@ -20,12 +20,14 @@
|
||||
Summary: Creates a common metadata repository
|
||||
Name: createrepo_c
|
||||
Version: 0.10.0
|
||||
Release: 14%{?dist}
|
||||
Release: 15%{?dist}
|
||||
License: GPLv2+
|
||||
URL: https://github.com/rpm-software-management/createrepo_c
|
||||
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
|
||||
|
||||
Patch0: createrepo_c-0.10.0-ignorelock-doublefree.patch
|
||||
Patch1: https://patch-diff.githubusercontent.com/raw/rpm-software-management/createrepo_c/pull/64.patch
|
||||
Patch2: https://patch-diff.githubusercontent.com/raw/rpm-software-management/createrepo_c/pull/66.patch
|
||||
|
||||
BuildRequires: cmake
|
||||
BuildRequires: gcc
|
||||
@ -188,6 +190,9 @@ popd
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Fri Dec 22 2017 Patrick Uiterwijk <puiterwijk@redhat.com> - 0.10.0-15
|
||||
- Backport PR#64 and #66
|
||||
|
||||
* Fri Aug 11 2017 Igor Gnatenko <ignatenko@redhat.com> - 0.10.0-14
|
||||
- Rebuilt after RPM update (№ 3)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user