Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
dd520ab257
!38 [sync] PR-35: 同步上游社区补丁
From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2024-10-24 03:07:00 +00:00
Pshysimon
3adc995c00 backport upstream commit, fix memory leak
(cherry picked from commit f02f090077a65f98a60afa9a873a8854292e083e)
2024-10-22 16:22:00 +08:00
openeuler-ci-bot
06bdedcbd3
!29 [sync] PR-28: backport upstream commits
From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2022-11-14 03:25:19 +00:00
shixuantong
8e86db69c8 backport upstream commits
(cherry picked from commit dc8d073ae1f2cfbd5de0f8f9eb7c5488c3b160a1)
2022-11-14 09:51:28 +08:00
openeuler-ci-bot
47f0533770
!26 【轻量级 PR】:Rebuild for next release
From: @dongyuzhen 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
2022-10-31 03:20:29 +00:00
dongyuzhen
fe4a272e58
update for mass rebuild and upgrade verification 2022-10-27 07:33:54 +00:00
openeuler-ci-bot
db6c5d688a !22 Delete BuildRequires python3-nose
Merge pull request !22 from 付安安/openEuler-22.03-LTS-Next
2021-12-25 07:35:30 +00:00
fuanan
76a06ecddd Delete BuildRequires python3-nose 2021-12-25 15:18:30 +08:00
openeuler-ci-bot
4d3d55e60f !21 update version to 1.14.2
From: @fly_fzc
Reviewed-by: @xiezhipeng1
Signed-off-by: @xiezhipeng1
2021-12-01 02:07:19 +00:00
fuanan
5b2804dc08 update version to 1.14.2 2021-11-30 16:54:21 +08:00
13 changed files with 1073 additions and 224 deletions

View File

@ -0,0 +1,69 @@
From 3c85711f35b987bd0ce17dd0fbaa0d9f2521c444 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 11 Jul 2024 15:40:03 +0200
Subject: [PATCH] Fix a memory leak in select_next_target()
If a next target URL was found (non-NULL full_url) and then a transfer was
canceled or an off-line mode was requested, full_url string was not freed and a
memory leaked.
Discovered with Covscan:
16. librepo-1.18.0/librepo/downloader.c:891:13: alloc_fn: Storage is returned from allocation function "g_strdup_inline".
17. librepo-1.18.0/librepo/downloader.c:891:13: var_assign: Assigning: "full_url" = storage returned from "g_strdup_inline(target->target->path)".
22. librepo-1.18.0/librepo/downloader.c:919:9: noescape: Resource "full_url" is not freed or pointed-to in "lr_is_local_path".
24. librepo-1.18.0/librepo/downloader.c:924:13: noescape: Assuming resource "full_url" is not freed or pointed-to as ellipsis argument to "g_debug".
28. librepo-1.18.0/librepo/downloader.c:956:17: leaked_storage: Variable "full_url" going out of scope leaks the storage it points to.
# 954| "and no local URL is available",
# 955| target->target->path);
# 956|-> return FALSE;
# 957| }
# 958| }
16. librepo-1.18.0/librepo/downloader.c:891:13: alloc_fn: Storage is returned from allocation function "g_strdup_inline".
17. librepo-1.18.0/librepo/downloader.c:891:13: var_assign: Assigning: "full_url" = storage returned from "g_strdup_inline(target->target->path)".
22. librepo-1.18.0/librepo/downloader.c:919:9: noescape: Resource "full_url" is not freed or pointed-to in "lr_is_local_path".
24. librepo-1.18.0/librepo/downloader.c:924:13: noescape: Assuming resource "full_url" is not freed or pointed-to as ellipsis argument to "g_debug".
27. librepo-1.18.0/librepo/downloader.c:946:21: leaked_storage: Variable "full_url" going out of scope leaks the storage it points to.
# 944| g_set_error(err, LR_DOWNLOADER_ERROR, LRE_CBINTERRUPTED,
# 945| "Interrupted by LR_CB_ERROR from end callback");
# 946|-> return FALSE;
# 947| }
# 948| }
This patch fixes it.
The bug was introduced in 1.7.14 version
(08e4810fcdd753ce4728bd88b252f7b3d34b2cdb commit).
Reference:https://github.com/rpm-software-management/librepo/commit/3c85711f35b987bd0ce17dd0fbaa0d9f2521c444
Conflict:no
---
librepo/downloader.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/librepo/downloader.c b/librepo/downloader.c
index 364c0af..40dbeb2 100644
--- a/librepo/downloader.c
+++ b/librepo/downloader.c
@@ -943,6 +943,7 @@ select_next_target(LrDownload *dd,
"from end callback", __func__);
g_set_error(err, LR_DOWNLOADER_ERROR, LRE_CBINTERRUPTED,
"Interrupted by LR_CB_ERROR from end callback");
+ g_free(full_url);
return FALSE;
}
}
@@ -953,6 +954,7 @@ select_next_target(LrDownload *dd,
"Cannot download %s: Offline mode is specified "
"and no local URL is available",
target->target->path);
+ g_free(full_url);
return FALSE;
}
}
--
2.33.0

View File

@ -0,0 +1,296 @@
From aa591c37deee71e33e09106f8c15cd41b0a89a28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
Date: Fri, 15 Jul 2022 17:16:12 +0200
Subject: [PATCH] Fix alloc / free mismatches from covscan
---
librepo/checksum.c | 6 +++---
librepo/downloader.c | 2 +-
librepo/lrmirrorlist.c | 2 +-
librepo/package_downloader.c | 2 +-
librepo/repoconf.c | 2 +-
librepo/repoutil_yum.c | 4 ++--
librepo/util.c | 6 +++---
tests/test_checksum.c | 4 ++--
tests/test_gpg.c | 2 +-
tests/test_main.c | 2 +-
tests/test_util.c | 24 ++++++++++++------------
11 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/librepo/checksum.c b/librepo/checksum.c
index d82cb5c..4831ddc 100644
--- a/librepo/checksum.c
+++ b/librepo/checksum.c
@@ -205,8 +205,6 @@ lr_checksum_fd_compare(LrChecksumType type,
gchar **calculated,
GError **err)
{
- _cleanup_free_ gchar *checksum = NULL;
-
assert(fd >= 0);
assert(!err || *err == NULL);
@@ -262,7 +260,7 @@ lr_checksum_fd_compare(LrChecksumType type,
}
}
- checksum = lr_checksum_fd(type, fd, err);
+ char *checksum = lr_checksum_fd(type, fd, err);
if (!checksum)
return FALSE;
@@ -274,6 +272,7 @@ lr_checksum_fd_compare(LrChecksumType type,
} else {
g_set_error(err, LR_CHECKSUM_ERROR, LRE_FILE,
"fsync failed: %s", strerror(errno));
+ lr_free(checksum);
return FALSE;
}
}
@@ -287,6 +286,7 @@ lr_checksum_fd_compare(LrChecksumType type,
if (calculated)
*calculated = g_strdup(checksum);
+ lr_free(checksum);
return TRUE;
}
diff --git a/librepo/downloader.c b/librepo/downloader.c
index 3bb126b..cc4b80a 100644
--- a/librepo/downloader.c
+++ b/librepo/downloader.c
@@ -1976,7 +1976,7 @@ list_of_checksums_to_str(GSList *checksums)
tmp = g_strconcat(expected, chksum->value, "(",
chtype_str ? chtype_str : "UNKNOWN",
") ", NULL);
- free(expected);
+ g_free(expected);
expected = tmp;
}
diff --git a/librepo/lrmirrorlist.c b/librepo/lrmirrorlist.c
index c7e51b3..91cdc4b 100644
--- a/librepo/lrmirrorlist.c
+++ b/librepo/lrmirrorlist.c
@@ -156,7 +156,7 @@ lr_lrmirrorlist_append_metalink(LrInternalMirrorlist *list,
LrInternalMirror *mirror = lr_lrmirror_new(url_copy, urlvars);
mirror->preference = metalinkurl->preference;
mirror->protocol = lr_detect_protocol(mirror->url);
- lr_free(url_copy);
+ g_free(url_copy);
list = g_slist_append(list, mirror);
//g_debug("%s: Appending URL: %s", __func__, mirror->url);
diff --git a/librepo/package_downloader.c b/librepo/package_downloader.c
index adea459..353cac8 100644
--- a/librepo/package_downloader.c
+++ b/librepo/package_downloader.c
@@ -173,7 +173,7 @@ lr_packagetarget_free(LrPackageTarget *target)
if (!target)
return;
g_string_chunk_free(target->chunk);
- g_free(target);
+ lr_free(target);
}
gboolean
diff --git a/librepo/repoconf.c b/librepo/repoconf.c
index 948259e..34dbab4 100644
--- a/librepo/repoconf.c
+++ b/librepo/repoconf.c
@@ -146,7 +146,7 @@ lr_yum_repoconfs_free(LrYumRepoConfs *repos)
return;
g_slist_free_full(repos->repos, (GDestroyNotify) lr_yum_repoconf_free);
g_slist_free_full(repos->files, (GDestroyNotify) lr_yum_repofile_free);
- g_free(repos);
+ lr_free(repos);
}
GSList *
diff --git a/librepo/repoutil_yum.c b/librepo/repoutil_yum.c
index 02e796f..bb09ff5 100644
--- a/librepo/repoutil_yum.c
+++ b/librepo/repoutil_yum.c
@@ -105,11 +105,11 @@ lr_repoutil_yum_parse_repomd(const char *in_path,
if (fd < 0) {
g_set_error(err, LR_REPOUTIL_YUM_ERROR, LRE_IO,
"open(%s, O_RDONLY) error: %s", path, g_strerror(errno));
- lr_free(path);
+ g_free(path);
return FALSE;
}
- lr_free(path);
+ g_free(path);
ret = lr_yum_repomd_parse_file(repomd, fd, NULL, NULL, err);
close(fd);
diff --git a/librepo/util.c b/librepo/util.c
index 8ba7120..204572d 100644
--- a/librepo/util.c
+++ b/librepo/util.c
@@ -170,7 +170,7 @@ lr_gettmpdir(void)
{
char *template = g_build_filename(g_get_tmp_dir(), "librepo-tmpdir-XXXXXX", NULL);
if (!mkdtemp(template)) {
- lr_free(template);
+ g_free(template);
return NULL;
}
return template;
@@ -206,7 +206,7 @@ lr_pathconcat(const char *first, ...)
qmark_section = strchr(first, '?');
- res = lr_malloc(total_len + separator_len + 1);
+ res = g_malloc(total_len + separator_len + 1);
next = first;
va_start(args, first);
@@ -273,7 +273,7 @@ lr_pathconcat(const char *first, ...)
assert(offset <= total_len);
if (offset == 0) {
- lr_free(res);
+ g_free(res);
return g_strdup(first);
}
diff --git a/tests/test_checksum.c b/tests/test_checksum.c
index 548f588..264782c 100644
--- a/tests/test_checksum.c
+++ b/tests/test_checksum.c
@@ -295,8 +295,8 @@ START_TEST(test_cached_checksum_clear)
cleanup:
close(fd);
lr_free(filename);
- lr_free(timestamp_key);
- lr_free(checksum_key);
+ g_free(timestamp_key);
+ g_free(checksum_key);
}
END_TEST
diff --git a/tests/test_gpg.c b/tests/test_gpg.c
index fd322e3..0af423a 100644
--- a/tests/test_gpg.c
+++ b/tests/test_gpg.c
@@ -110,7 +110,7 @@ START_TEST(test_gpg_check_signature)
lr_free(_data_path);
lr_free(signature_path);
lr_free(_signature_path);
- lr_free(tmp_home_path);
+ g_free(tmp_home_path);
}
END_TEST
diff --git a/tests/test_main.c b/tests/test_main.c
index 1076062..b323ce5 100644
--- a/tests/test_main.c
+++ b/tests/test_main.c
@@ -39,7 +39,7 @@ init_test_globals(struct TestGlobals_s *tg, const char *testdata_dir)
static void
free_test_globals(struct TestGlobals_s *tg)
{
- lr_free(tg->tmpdir);
+ g_free(tg->tmpdir);
lr_free(tg->testdata_dir);
}
diff --git a/tests/test_util.c b/tests/test_util.c
index 595b0fe..d082445 100644
--- a/tests/test_util.c
+++ b/tests/test_util.c
@@ -54,7 +54,7 @@ START_TEST(test_gettmpdir)
char *tmp_dir = lr_gettmpdir();
ck_assert_ptr_nonnull(tmp_dir);
ck_assert_int_eq(rmdir(tmp_dir), 0);
- lr_free(tmp_dir);
+ g_free(tmp_dir);
}
END_TEST
@@ -126,7 +126,7 @@ START_TEST(test_remove_dir)
ck_assert_int_eq(rc, 0);
ck_assert_int_ne(unlink(tmp_file), 0);
ck_assert_int_ne(rmdir(tmp_dir), 0);
- lr_free(tmp_dir);
+ g_free(tmp_dir);
lr_free(tmp_file);
}
END_TEST
@@ -141,61 +141,61 @@ START_TEST(test_url_without_path)
new_url = lr_url_without_path("");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("hostname");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "hostname");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("hostname/foo/bar/");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "hostname");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("hostname:80");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "hostname:80");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("hostname:80/foo/bar");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "hostname:80");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("http://hostname:80/");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "http://hostname:80");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("http://hostname:80/foo/bar");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "http://hostname:80");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("ftp://foo.hostname:80/foo/bar");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "ftp://foo.hostname:80");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("file:///home/foobar");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "file://");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
new_url = lr_url_without_path("file:/home/foobar");
ck_assert_ptr_nonnull(new_url);
ck_assert_str_eq(new_url, "file://");
- lr_free(new_url);
+ g_free(new_url);
new_url = NULL;
}
END_TEST
--
2.27.0

View File

@ -1,32 +0,0 @@
From 9e9b29a8447403890bea6586804206e1060c27d1 Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Thu, 6 May 2021 17:34:16 +0200
Subject: [PATCH] Fix: lr_fastestmirror_prepare: Resource leaks
---
librepo/fastestmirror.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/librepo/fastestmirror.c b/librepo/fastestmirror.c
index afa1f22..348483a 100644
--- a/librepo/fastestmirror.c
+++ b/librepo/fastestmirror.c
@@ -352,6 +352,7 @@ lr_fastestmirror_prepare(LrHandle *handle,
g_set_error(err, LR_FASTESTMIRROR_ERROR, LRE_CURL,
"curl_easy_setopt(_, CURLOPT_URL, %s) failed: %s",
url, curl_easy_strerror(curlcode));
+ curl_easy_cleanup(curlh);
ret = FALSE;
break;
}
@@ -361,6 +362,7 @@ lr_fastestmirror_prepare(LrHandle *handle,
g_set_error(err, LR_FASTESTMIRROR_ERROR, LRE_CURL,
"curl_easy_setopt(_, CURLOPT_CONNECT_ONLY, 1) failed: %s",
curl_easy_strerror(curlcode));
+ curl_easy_cleanup(curlh);
ret = FALSE;
break;
}
--
1.8.3.1

View File

@ -1,26 +0,0 @@
From f889cdba3b71eec66c3f9756b11b709f74f8b388 Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Thu, 6 May 2021 17:54:11 +0200
Subject: [PATCH] Fix: lr_get_curl_handle: Check curl_easy handle before use
---
librepo/handle.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/librepo/handle.c b/librepo/handle.c
index d59aad9..8db9c16 100644
--- a/librepo/handle.c
+++ b/librepo/handle.c
@@ -56,6 +56,9 @@ lr_get_curl_handle()
lr_global_init();
h = curl_easy_init();
+ if (!h)
+ return NULL;
+
curl_easy_setopt(h, CURLOPT_FOLLOWLOCATION, 1);
curl_easy_setopt(h, CURLOPT_MAXREDIRS, 6);
curl_easy_setopt(h, CURLOPT_CONNECTTIMEOUT, LRO_CONNECTTIMEOUT_DEFAULT);
--
1.8.3.1

View File

@ -1,44 +0,0 @@
From 2e905e313c80a2b6b187a3b3e831e2e291f9a1eb Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Tue, 23 Mar 2021 19:31:51 +0100
Subject: [PATCH] Fix: memory leaks
---
librepo/metadata_downloader.c | 1 +
librepo/yum.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/librepo/metadata_downloader.c b/librepo/metadata_downloader.c
index fa05cc1..be6fe68 100644
--- a/librepo/metadata_downloader.c
+++ b/librepo/metadata_downloader.c
@@ -307,6 +307,7 @@ create_repomd_xml_download_targets(GSList *targets,
(*fd_list) = appendFdValue((*fd_list), fd);
(*paths) = appendPath((*paths), path);
+ lr_free(path);
}
}
diff --git a/librepo/yum.c b/librepo/yum.c
index 4198d4a..7a26a8b 100644
--- a/librepo/yum.c
+++ b/librepo/yum.c
@@ -875,12 +875,14 @@ error_handling(GSList *targets, GError **dest_error, GError *src_error)
target->err,
NULL);
} else {
+ char *tmp = error_summary;
error_summary = g_strconcat(error_summary,
"; ",
target->path,
" - ",
target->err,
NULL);
+ g_free(tmp);
}
}
--
1.8.3.1

View File

@ -0,0 +1,578 @@
From d2508e206514bdbf841ee72f4971336766c16fe1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
Date: Thu, 21 Jul 2022 10:11:17 +0200
Subject: [PATCH] More covscan fixes
---
librepo/metadata_downloader.c | 18 +++++++++---------
librepo/metalink.c | 2 +-
librepo/repomd.c | 2 +-
librepo/xmlparser.c | 4 ++--
librepo/xmlparser_internal.h | 2 +-
librepo/yum.c | 32 ++++++++++++++++----------------
tests/test_checksum.c | 10 +++++-----
tests/test_downloader.c | 16 ++++++++--------
tests/test_metalink.c | 18 +++++++++---------
tests/test_mirrorlist.c | 6 +++---
tests/test_util.c | 16 ++++++++--------
11 files changed, 63 insertions(+), 63 deletions(-)
diff --git a/librepo/metadata_downloader.c b/librepo/metadata_downloader.c
index 10068bb..6fc44ec 100644
--- a/librepo/metadata_downloader.c
+++ b/librepo/metadata_downloader.c
@@ -191,7 +191,7 @@ handle_failure(LrMetadataTarget *target,
GSList **paths,
GError *err)
{
- lr_metadatatarget_append_error(target, err->message, NULL);
+ lr_metadatatarget_append_error(target, err->message);
fillInvalidationValues(fd_list, paths);
g_error_free(err);
}
@@ -220,13 +220,13 @@ create_repomd_xml_download_targets(GSList *targets,
handle = target->handle;
if (!handle->urls && !handle->mirrorlisturl && !handle->metalinkurl) {
- lr_metadatatarget_append_error(target, "No LRO_URLS, LRO_MIRRORLISTURL nor LRO_METALINKURL specified", NULL);
+ lr_metadatatarget_append_error(target, "No LRO_URLS, LRO_MIRRORLISTURL nor LRO_METALINKURL specified");
fillInvalidationValues(fd_list, paths);
continue;
}
if (handle->repotype != LR_YUMREPO) {
- lr_metadatatarget_append_error(target, "Bad LRO_REPOTYPE specified", NULL);
+ lr_metadatatarget_append_error(target, "Bad LRO_REPOTYPE specified");
fillInvalidationValues(fd_list, paths);
continue;
}
@@ -241,14 +241,14 @@ create_repomd_xml_download_targets(GSList *targets,
if (!lr_handle_prepare_internal_mirrorlist(handle,
handle->fastestmirror,
&err)) {
- lr_metadatatarget_append_error(target, "Cannot prepare internal mirrorlist: %s", err->message, NULL);
+ lr_metadatatarget_append_error(target, "Cannot prepare internal mirrorlist: %s", err->message);
fillInvalidationValues(fd_list, paths);
g_error_free(err);
continue;
}
if (mkdir(handle->destdir, S_IRWXU) == -1 && errno != EEXIST) {
- lr_metadatatarget_append_error(target, "Cannot create tmpdir: %s %s", handle->destdir, g_strerror(errno), NULL);
+ lr_metadatatarget_append_error(target, "Cannot create tmpdir: %s %s", handle->destdir, g_strerror(errno));
fillInvalidationValues(fd_list, paths);
g_error_free(err);
continue;
@@ -334,12 +334,12 @@ process_repomd_xml(GSList *targets,
handle->gnupghomedir = g_strdup(target->gnupghomedir);
if (target->download_target->rcode != LRE_OK) {
- lr_metadatatarget_append_error(target, (char *) lr_strerror(target->download_target->rcode), NULL);
+ lr_metadatatarget_append_error(target, (char *) lr_strerror(target->download_target->rcode));
goto fail;
}
if (!lr_check_repomd_xml_asc_availability(handle, target->repo, fd_value, path->data, &error)) {
- lr_metadatatarget_append_error(target, error->message, NULL);
+ lr_metadatatarget_append_error(target, error->message);
g_error_free(error);
goto fail;
}
@@ -348,7 +348,7 @@ process_repomd_xml(GSList *targets,
ret = lr_yum_repomd_parse_file(target->repomd, fd_value, lr_xml_parser_warning_logger,
"Repomd xml parser", &error);
if (!ret) {
- lr_metadatatarget_append_error(target, "Parsing unsuccessful: %s", error->message, NULL);
+ lr_metadatatarget_append_error(target, "Parsing unsuccessful: %s", error->message);
g_error_free(error);
goto fail;
}
@@ -376,7 +376,7 @@ lr_metadata_download_cleanup(GSList *download_targets)
LrDownloadTarget *download_target = elem->data;
LrMetadataTarget *target = download_target->userdata;
if (download_target->err)
- lr_metadatatarget_append_error(target, download_target->err, NULL);
+ lr_metadatatarget_append_error(target, download_target->err);
if (target->err != NULL) {
ret = FALSE;
diff --git a/librepo/metalink.c b/librepo/metalink.c
index 0f939de..1f839a9 100644
--- a/librepo/metalink.c
+++ b/librepo/metalink.c
@@ -504,7 +504,7 @@ lr_metalink_parse_file(LrMetalink *metalink,
// Parsing
- ret = lr_xml_parser_generic(parser, pd, fd, &tmp_err);
+ ret = lr_xml_parser_generic(&parser, pd, fd, &tmp_err);
if (tmp_err) {
g_propagate_error(err, tmp_err);
goto err;
diff --git a/librepo/repomd.c b/librepo/repomd.c
index f0fd2ad..2905749 100644
--- a/librepo/repomd.c
+++ b/librepo/repomd.c
@@ -570,7 +570,7 @@ lr_yum_repomd_parse_file(LrYumRepoMd *repomd,
// Parsing
- ret = lr_xml_parser_generic(parser, pd, fd, &tmp_err);
+ ret = lr_xml_parser_generic(&parser, pd, fd, &tmp_err);
if (tmp_err)
g_propagate_error(err, tmp_err);
diff --git a/librepo/xmlparser.c b/librepo/xmlparser.c
index 793c272..88d16aa 100644
--- a/librepo/xmlparser.c
+++ b/librepo/xmlparser.c
@@ -143,7 +143,7 @@ lr_xml_parser_strtoll(LrParserData *pd,
}
gboolean
-lr_xml_parser_generic(XmlParser parser,
+lr_xml_parser_generic(XmlParser *parser,
LrParserData *pd,
int fd,
GError **err)
@@ -151,7 +151,7 @@ lr_xml_parser_generic(XmlParser parser,
/* Note: This function uses .err members of LrParserData! */
gboolean ret = TRUE;
- xmlParserCtxtPtr ctxt = xmlCreatePushParserCtxt(&parser, pd, NULL, 0, NULL);
+ xmlParserCtxtPtr ctxt = xmlCreatePushParserCtxt(parser, pd, NULL, 0, NULL);
ctxt->linenumbers = 1;
assert(ctxt);
diff --git a/librepo/xmlparser_internal.h b/librepo/xmlparser_internal.h
index c9bacac..25a48a5 100644
--- a/librepo/xmlparser_internal.h
+++ b/librepo/xmlparser_internal.h
@@ -159,7 +159,7 @@ lr_xml_parser_strtoll(LrParserData *pd,
/** Generic parser.
*/
gboolean
-lr_xml_parser_generic(XmlParser parser,
+lr_xml_parser_generic(XmlParser *parser,
LrParserData *pd,
int fd,
GError **err);
diff --git a/librepo/yum.c b/librepo/yum.c
index 3b287cd..56bca3e 100644
--- a/librepo/yum.c
+++ b/librepo/yum.c
@@ -335,7 +335,7 @@ lr_prepare_repodata_dir(LrHandle *handle,
return FALSE;
}
}
- lr_free(path_to_repodata);
+ g_free(path_to_repodata);
return TRUE;
}
@@ -356,7 +356,7 @@ lr_store_mirrorlist_files(LrHandle *handle,
g_debug("%s: Cannot create: %s", __func__, ml_file_path);
g_set_error(err, LR_YUM_ERROR, LRE_IO,
"Cannot create %s: %s", ml_file_path, g_strerror(errno));
- lr_free(ml_file_path);
+ g_free(ml_file_path);
return FALSE;
}
rc = lr_copy_content(handle->mirrorlist_fd, fd);
@@ -366,7 +366,7 @@ lr_store_mirrorlist_files(LrHandle *handle,
g_set_error(err, LR_YUM_ERROR, LRE_IO,
"Cannot copy content of mirrorlist file %s: %s",
ml_file_path, g_strerror(errno));
- lr_free(ml_file_path);
+ g_free(ml_file_path);
return FALSE;
}
repo->mirrorlist = ml_file_path;
@@ -391,7 +391,7 @@ lr_copy_metalink_content(LrHandle *handle,
g_debug("%s: Cannot create: %s", __func__, ml_file_path);
g_set_error(err, LR_YUM_ERROR, LRE_IO,
"Cannot create %s: %s", ml_file_path, g_strerror(errno));
- lr_free(ml_file_path);
+ g_free(ml_file_path);
return FALSE;
}
rc = lr_copy_content(handle->metalink_fd, fd);
@@ -401,7 +401,7 @@ lr_copy_metalink_content(LrHandle *handle,
g_set_error(err, LR_YUM_ERROR, LRE_IO,
"Cannot copy content of metalink file %s: %s",
ml_file_path, g_strerror(errno));
- lr_free(ml_file_path);
+ g_free(ml_file_path);
return FALSE;
}
repo->metalink = ml_file_path;
@@ -422,7 +422,7 @@ lr_prepare_repomd_xml_file(LrHandle *handle,
if (fd == -1) {
g_set_error(err, LR_YUM_ERROR, LRE_IO,
"Cannot open %s: %s", *path, g_strerror(errno));
- lr_free(*path);
+ g_free(*path);
return -1;
}
@@ -458,13 +458,13 @@ lr_check_repomd_xml_asc_availability(LrHandle *handle,
g_debug("%s: Cannot open: %s", __func__, signature);
g_set_error(err, LR_YUM_ERROR, LRE_IO,
"Cannot open %s: %s", signature, g_strerror(errno));
- lr_free(signature);
+ g_free(signature);
return FALSE;
}
url = lr_pathconcat(handle->used_mirror, "repodata/repomd.xml.asc", NULL);
ret = lr_download_url(handle, url, fd_sig, &tmp_err);
- lr_free(url);
+ g_free(url);
close(fd_sig);
if (!ret) {
// Error downloading signature
@@ -474,7 +474,7 @@ lr_check_repomd_xml_asc_availability(LrHandle *handle,
"repository does not support GPG verification: %s", tmp_err->message);
g_clear_error(&tmp_err);
unlink(signature);
- lr_free(signature);
+ g_free(signature);
return FALSE;
} else {
// Signature downloaded
@@ -483,7 +483,7 @@ lr_check_repomd_xml_asc_availability(LrHandle *handle,
path,
handle->gnupghomedir,
&tmp_err);
- lr_free(signature);
+ g_free(signature);
if (!ret) {
g_debug("%s: GPG signature verification failed: %s",
__func__, tmp_err->message);
@@ -680,7 +680,7 @@ prepare_repo_download_std_target(LrHandle *handle,
__func__, *path, g_strerror(errno));
g_set_error(err, LR_YUM_ERROR, LRE_IO,
"Cannot create/open %s: %s", *path, g_strerror(errno));
- lr_free(*path);
+ g_free(*path);
g_slist_free_full(*targets, (GDestroyNotify) lr_downloadtarget_free);
return FALSE;
}
@@ -713,7 +713,7 @@ prepare_repo_download_zck_target(LrHandle *handle,
__func__, *path, g_strerror(errno));
g_set_error(err, LR_YUM_ERROR, LRE_IO,
"Cannot create/open %s: %s", *path, g_strerror(errno));
- lr_free(*path);
+ g_free(*path);
g_slist_free_full(*targets, (GDestroyNotify) lr_downloadtarget_free);
return FALSE;
}
@@ -778,7 +778,7 @@ prepare_repo_download_targets(LrHandle *handle,
char *dest_dir = realpath(handle->destdir, NULL);
path = lr_pathconcat(handle->destdir, record->location_href, NULL);
char *requested_dir = realpath(dirname(path), NULL);
- lr_free(path);
+ g_free(path);
if (!g_str_has_prefix(requested_dir, dest_dir)) {
g_debug("%s: Invalid path: %s", __func__, location_href);
g_set_error(err, LR_YUM_ERROR, LRE_IO, "Invalid path: %s", location_href);
@@ -850,7 +850,7 @@ prepare_repo_download_targets(LrHandle *handle,
/* Because path may already exists in repo (while update) */
lr_yum_repo_update(repo, record->type, path);
- lr_free(path);
+ g_free(path);
}
return TRUE;
@@ -1130,7 +1130,7 @@ lr_yum_use_local_load_base(LrHandle *handle,
repo->mirrorlist = mrl_fn;
} else {
repo->mirrorlist = NULL;
- lr_free(mrl_fn);
+ g_free(mrl_fn);
}
}
@@ -1142,7 +1142,7 @@ lr_yum_use_local_load_base(LrHandle *handle,
repo->metalink = mtl_fn;
} else {
repo->metalink = NULL;
- lr_free(mtl_fn);
+ g_free(mtl_fn);
}
}
diff --git a/tests/test_checksum.c b/tests/test_checksum.c
index 264782c..efac88b 100644
--- a/tests/test_checksum.c
+++ b/tests/test_checksum.c
@@ -87,7 +87,7 @@ START_TEST(test_checksum_fd)
test_checksum(file, LR_CHECKSUM_SHA512, CHKS_VAL_01_SHA512);
ck_assert_msg(remove(file) == 0, "Cannot delete temporary test file");
- lr_free(file);
+ g_free(file);
}
END_TEST
@@ -235,9 +235,9 @@ START_TEST(test_cached_checksum_value)
ck_assert(attr_ret == -1); // Cached checksum should not exists
lr_free(calculated);
- lr_free(filename);
- lr_free(timestamp_key);
- lr_free(checksum_key);
+ g_free(filename);
+ g_free(timestamp_key);
+ g_free(checksum_key);
lr_free(mtime_str);
}
END_TEST
@@ -294,7 +294,7 @@ START_TEST(test_cached_checksum_clear)
ck_assert(attr_ret != -1);
cleanup:
close(fd);
- lr_free(filename);
+ g_free(filename);
g_free(timestamp_key);
g_free(checksum_key);
}
diff --git a/tests/test_downloader.c b/tests/test_downloader.c
index 34958ab..a3fff20 100644
--- a/tests/test_downloader.c
+++ b/tests/test_downloader.c
@@ -52,7 +52,7 @@ START_TEST(test_downloader_single_file)
tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_XXXXXX", NULL);
fd1 = mkstemp(tmpfn1);
- lr_free(tmpfn1);
+ g_free(tmpfn1);
ck_assert_int_ge(fd1, 0);
t1 = lr_downloadtarget_new(handle, "index.html", NULL, fd1, NULL, NULL,
@@ -97,7 +97,7 @@ START_TEST(test_downloader_single_file_2)
tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_2_XXXXXX", NULL);
fd1 = mkstemp(tmpfn1);
- lr_free(tmpfn1);
+ g_free(tmpfn1);
ck_assert_int_ge(fd1, 0);
t1 = lr_downloadtarget_new(NULL, "http://seznam.cz/index.html", NULL,
@@ -154,8 +154,8 @@ START_TEST(test_downloader_two_files)
fd1 = mkstemp(tmpfn1);
fd2 = mkstemp(tmpfn2);
- lr_free(tmpfn1);
- lr_free(tmpfn2);
+ g_free(tmpfn1);
+ g_free(tmpfn2);
ck_assert_int_ge(fd1, 0);
ck_assert_int_ge(fd2, 0);
@@ -223,9 +223,9 @@ START_TEST(test_downloader_three_files_with_error)
fd1 = mkstemp(tmpfn1);
fd2 = mkstemp(tmpfn2);
fd3 = mkstemp(tmpfn3);
- lr_free(tmpfn1);
- lr_free(tmpfn2);
- lr_free(tmpfn3);
+ g_free(tmpfn1);
+ g_free(tmpfn2);
+ g_free(tmpfn3);
ck_assert_int_ge(fd1, 0);
ck_assert_int_ge(fd2, 0);
ck_assert_int_ge(fd3, 0);
@@ -329,7 +329,7 @@ START_TEST(test_downloader_checksum)
tmpfn1 = lr_pathconcat(test_globals.tmpdir, "single_file_XXXXXX", NULL);
fd1 = mkstemp(tmpfn1);
- lr_free(tmpfn1);
+ g_free(tmpfn1);
ck_assert_int_ge(fd1, 0);
checksum = lr_downloadtargetchecksum_new(LR_CHECKSUM_SHA512,
diff --git a/tests/test_metalink.c b/tests/test_metalink.c
index e425742..1440125 100644
--- a/tests/test_metalink.c
+++ b/tests/test_metalink.c
@@ -48,7 +48,7 @@ START_TEST(test_metalink_good_01)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_good_01", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
@@ -160,7 +160,7 @@ START_TEST(test_metalink_good_02)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_good_02", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
@@ -206,7 +206,7 @@ START_TEST(test_metalink_good_03)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_good_03", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
@@ -250,7 +250,7 @@ START_TEST(test_metalink_bad_01)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_bad_01", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
@@ -371,7 +371,7 @@ START_TEST(test_metalink_bad_02)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_bad_02", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
@@ -395,7 +395,7 @@ START_TEST(test_metalink_really_bad_01)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_really_bad_01", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
@@ -419,7 +419,7 @@ START_TEST(test_metalink_really_bad_02)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_really_bad_02", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
@@ -443,7 +443,7 @@ START_TEST(test_metalink_really_bad_03)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_really_bad_03", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
@@ -470,7 +470,7 @@ START_TEST(test_metalink_with_alternates)
path = lr_pathconcat(test_globals.testdata_dir, METALINK_DIR,
"metalink_with_alternates", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_metalink_init();
ck_assert_ptr_nonnull(ml);
diff --git a/tests/test_mirrorlist.c b/tests/test_mirrorlist.c
index cc00b7f..ec924b6 100644
--- a/tests/test_mirrorlist.c
+++ b/tests/test_mirrorlist.c
@@ -35,7 +35,7 @@ START_TEST(test_mirrorlist_01)
path = lr_pathconcat(test_globals.testdata_dir, MIRRORLIST_DIR,
"mirrorlist_01", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_mirrorlist_init();
ck_assert_ptr_nonnull(ml);
@@ -68,7 +68,7 @@ START_TEST(test_mirrorlist_02)
path = lr_pathconcat(test_globals.testdata_dir, MIRRORLIST_DIR,
"mirrorlist_02", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_mirrorlist_init();
ck_assert_ptr_nonnull(ml);
@@ -92,7 +92,7 @@ START_TEST(test_mirrorlist_03)
path = lr_pathconcat(test_globals.testdata_dir, MIRRORLIST_DIR,
"mirrorlist_03", NULL);
fd = open(path, O_RDONLY);
- lr_free(path);
+ g_free(path);
ck_assert_int_ge(fd, 0);
ml = lr_mirrorlist_init();
ck_assert_ptr_nonnull(ml);
diff --git a/tests/test_util.c b/tests/test_util.c
index d082445..96e82aa 100644
--- a/tests/test_util.c
+++ b/tests/test_util.c
@@ -68,43 +68,43 @@ START_TEST(test_pathconcat)
path = lr_pathconcat("", NULL);
ck_assert_ptr_nonnull(path);
ck_assert_str_eq(path, "");
- lr_free(path);
+ g_free(path);
path = NULL;
path = lr_pathconcat("/tmp", "foo///", "bar", NULL);
ck_assert_ptr_nonnull(path);
ck_assert_str_eq(path, "/tmp/foo/bar");
- lr_free(path);
+ g_free(path);
path = NULL;
path = lr_pathconcat("foo", "bar/", NULL);
ck_assert_ptr_nonnull(path);
ck_assert_str_eq(path, "foo/bar");
- lr_free(path);
+ g_free(path);
path = NULL;
path = lr_pathconcat("foo", "/bar/", NULL);
ck_assert_ptr_nonnull(path);
ck_assert_str_eq(path, "foo/bar");
- lr_free(path);
+ g_free(path);
path = NULL;
path = lr_pathconcat("foo", "bar", "", NULL);
ck_assert_ptr_nonnull(path);
ck_assert_str_eq(path, "foo/bar/");
- lr_free(path);
+ g_free(path);
path = NULL;
path = lr_pathconcat("http://host.net", "path/to/somewhere", NULL);
ck_assert_ptr_nonnull(path);
ck_assert_str_eq(path, "http://host.net/path/to/somewhere");
- lr_free(path);
+ g_free(path);
path = NULL;
path = lr_pathconcat("http://host.net?hello=1", "path/to/", "somewhere", NULL);
ck_assert_ptr_nonnull(path);
ck_assert_str_eq(path, "http://host.net/path/to/somewhere?hello=1");
- lr_free(path);
+ g_free(path);
path = NULL;
}
END_TEST
@@ -127,7 +127,7 @@ START_TEST(test_remove_dir)
ck_assert_int_ne(unlink(tmp_file), 0);
ck_assert_int_ne(rmdir(tmp_dir), 0);
g_free(tmp_dir);
- lr_free(tmp_file);
+ g_free(tmp_file);
}
END_TEST
--
2.27.0

View File

@ -1,56 +0,0 @@
From ac36c6a4269f25878b838825590e37c3bdcd67c8 Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Thu, 6 May 2021 18:16:38 +0200
Subject: [PATCH] Remove "may be used uninitialized" compiler warnings
warning: 'path' may be used uninitialized in this function
[-Wmaybe-uninitialized]
warning: 'file_basename' may be used uninitialized in this function
[-Wmaybe-uninitialized]
---
librepo/handle.c | 6 ++----
librepo/package_downloader.c | 3 +--
2 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/librepo/handle.c b/librepo/handle.c
index c44ec61..8ac7234 100644
--- a/librepo/handle.c
+++ b/librepo/handle.c
@@ -905,8 +905,7 @@ lr_handle_prepare_mirrorlist(LrHandle *handle, gchar *localpath, GError **err)
return TRUE;
} else if (localpath && !handle->mirrorlisturl) {
// Just try to use mirrorlist of the local repository
- _cleanup_free_ gchar *path;
- path = lr_pathconcat(localpath, "mirrorlist", NULL);
+ _cleanup_free_ gchar *path = lr_pathconcat(localpath, "mirrorlist", NULL);
if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
g_debug("%s: Local mirrorlist found at %s", __func__, path);
@@ -1021,8 +1020,7 @@ lr_handle_prepare_metalink(LrHandle *handle, gchar *localpath, GError **err)
return TRUE;
} else if (localpath && !handle->metalinkurl) {
// Just try to use metalink of the local repository
- _cleanup_free_ gchar *path;
- path = lr_pathconcat(localpath, "metalink.xml", NULL);
+ _cleanup_free_ gchar *path = lr_pathconcat(localpath, "metalink.xml", NULL);
if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
g_debug("%s: Local metalink.xml found at %s", __func__, path);
diff --git a/librepo/package_downloader.c b/librepo/package_downloader.c
index 509f2a0..adea459 100644
--- a/librepo/package_downloader.c
+++ b/librepo/package_downloader.c
@@ -547,8 +547,7 @@ lr_check_packages(GSList *targets,
if (packagetarget->dest) {
if (g_file_test(packagetarget->dest, G_FILE_TEST_IS_DIR)) {
// Dir specified
- _cleanup_free_ gchar *file_basename;
- file_basename = g_path_get_basename(packagetarget->relative_url);
+ _cleanup_free_ gchar *file_basename = g_path_get_basename(packagetarget->relative_url);
local_path = g_build_filename(packagetarget->dest,
file_basename,
--
1.8.3.1

View File

@ -0,0 +1,55 @@
From 7b1559ff55703be22a50a26858c6fcbb8cd257c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
Date: Tue, 16 Aug 2022 15:41:44 +0200
Subject: [PATCH] Use g_list_free_full() to free LRMetadataTarget::err
Fixes a memory leak where the char * items in the list were not freed.
---
CMakeLists.txt | 2 +-
librepo.spec | 2 +-
librepo/metadata_downloader.c | 3 +--
3 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a45d5c4..b4007e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,7 +28,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Find necessare libraries
FIND_PACKAGE(PkgConfig)
-PKG_CHECK_MODULES(GLIB2 glib-2.0 REQUIRED)
+PKG_CHECK_MODULES(GLIB2 glib-2.0>=2.28 REQUIRED)
PKG_SEARCH_MODULE(LIBCRYPTO REQUIRED libcrypto openssl)
PKG_CHECK_MODULES(LIBXML2 libxml-2.0 REQUIRED)
FIND_PACKAGE(CURL 7.52.0 REQUIRED)
diff --git a/librepo.spec b/librepo.spec
index 1eb2373..5eaafe4 100644
--- a/librepo.spec
+++ b/librepo.spec
@@ -23,7 +23,7 @@ BuildRequires: cmake
BuildRequires: gcc
BuildRequires: check-devel
BuildRequires: doxygen
-BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(glib-2.0) >= 2.28
BuildRequires: gpgme-devel
BuildRequires: libattr-devel
BuildRequires: libcurl-devel >= %{libcurl_version}
diff --git a/librepo/metadata_downloader.c b/librepo/metadata_downloader.c
index a18efdd..123c77b 100644
--- a/librepo/metadata_downloader.c
+++ b/librepo/metadata_downloader.c
@@ -88,8 +88,7 @@ lr_metadatatarget_free(LrMetadataTarget *target)
if (!target)
return;
g_string_chunk_free(target->chunk);
- if (target->err != NULL)
- g_list_free(target->err);
+ g_list_free_full(target->err, g_free);
g_free(target);
}
--
2.27.0

View File

@ -0,0 +1,51 @@
From 12ac81382ed0fa41bf8d4dbed02e52e68670ee04 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Hr=C3=A1zk=C3=BD?= <lhrazky@redhat.com>
Date: Tue, 16 Aug 2022 13:44:22 +0200
Subject: [PATCH] Use g_strdup_vprintf() instead of manually calculating
allocation space
Fixes an error introduced in d2508e206514bdbf841ee72f4971336766c16fe1 by
removing trailing NULLs, on which the size calculation code was relying.
Instead of this incosistent argument iteration, use g_strdup_vprintf(),
which allocates the new string correctly.
---
librepo/metadata_downloader.c | 19 ++-----------------
1 file changed, 2 insertions(+), 17 deletions(-)
diff --git a/librepo/metadata_downloader.c b/librepo/metadata_downloader.c
index 6fc44ec..a18efdd 100644
--- a/librepo/metadata_downloader.c
+++ b/librepo/metadata_downloader.c
@@ -97,26 +97,11 @@ void
lr_metadatatarget_append_error(LrMetadataTarget *target, char *format, ...)
{
va_list valist;
- size_t length = strlen(format);
- char *error_message = NULL;
-
- va_start(valist, format);
- while (1) {
- char *arg = va_arg(valist, char*);
- if (arg == NULL)
- break;
-
- length += strlen(arg);
- }
- length += RESERVE;
- va_end(valist);
-
va_start(valist, format);
- error_message = malloc(length * sizeof(char));
- vsnprintf(error_message, length, format, valist);
+ gchar *error_message = g_strdup_vprintf(format, valist);
va_end(valist);
- target->err = g_list_append(target->err, (gpointer) error_message);
+ target->err = g_list_append(target->err, error_message);
}
static gboolean
--
2.27.0

View File

@ -1,57 +0,0 @@
From bb7b40faae33b3b764429267df0f7c26c9f468b1 Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Thu, 6 May 2021 17:59:00 +0200
Subject: [PATCH] lr_get_curl_handle: Strict check of `curl_easy_setopt` return
code
---
librepo/handle.c | 31 ++++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/librepo/handle.c b/librepo/handle.c
index 8db9c16..c44ec61 100644
--- a/librepo/handle.c
+++ b/librepo/handle.c
@@ -59,17 +59,30 @@ lr_get_curl_handle()
if (!h)
return NULL;
- curl_easy_setopt(h, CURLOPT_FOLLOWLOCATION, 1);
- curl_easy_setopt(h, CURLOPT_MAXREDIRS, 6);
- curl_easy_setopt(h, CURLOPT_CONNECTTIMEOUT, LRO_CONNECTTIMEOUT_DEFAULT);
- curl_easy_setopt(h, CURLOPT_LOW_SPEED_TIME, LRO_LOWSPEEDTIME_DEFAULT);
- curl_easy_setopt(h, CURLOPT_LOW_SPEED_LIMIT, LRO_LOWSPEEDLIMIT_DEFAULT);
- curl_easy_setopt(h, CURLOPT_SSL_VERIFYHOST, 2);
- curl_easy_setopt(h, CURLOPT_SSL_VERIFYPEER, 1);
- curl_easy_setopt(h, CURLOPT_FTP_USE_EPSV, LRO_FTPUSEEPSV_DEFAULT);
- curl_easy_setopt(h, CURLOPT_FILETIME, 0);
+ if (curl_easy_setopt(h, CURLOPT_FOLLOWLOCATION, 1) != CURLE_OK)
+ goto err;
+ if (curl_easy_setopt(h, CURLOPT_MAXREDIRS, 6) != CURLE_OK)
+ goto err;
+ if (curl_easy_setopt(h, CURLOPT_CONNECTTIMEOUT, LRO_CONNECTTIMEOUT_DEFAULT) != CURLE_OK)
+ goto err;
+ if (curl_easy_setopt(h, CURLOPT_LOW_SPEED_TIME, LRO_LOWSPEEDTIME_DEFAULT) != CURLE_OK)
+ goto err;
+ if (curl_easy_setopt(h, CURLOPT_LOW_SPEED_LIMIT, LRO_LOWSPEEDLIMIT_DEFAULT) != CURLE_OK)
+ goto err;
+ if (curl_easy_setopt(h, CURLOPT_SSL_VERIFYHOST, 2) != CURLE_OK)
+ goto err;
+ if (curl_easy_setopt(h, CURLOPT_SSL_VERIFYPEER, 1) != CURLE_OK)
+ goto err;
+ if (curl_easy_setopt(h, CURLOPT_FTP_USE_EPSV, LRO_FTPUSEEPSV_DEFAULT) != CURLE_OK)
+ goto err;
+ if (curl_easy_setopt(h, CURLOPT_FILETIME, 0) != CURLE_OK)
+ goto err;
return h;
+
+err:
+ curl_easy_cleanup(h);
+ return NULL;
}
void
--
1.8.3.1

Binary file not shown.

BIN
librepo-1.14.2.tar.gz Normal file

Binary file not shown.

View File

@ -1,22 +1,22 @@
%global libcurl_version 7.28.0
%global libcurl_version 7.52.0
%global dnf_conflict 2.8.8
%bcond_without pythontests
%bcond_with zchunk
Name: librepo
Version: 1.12.1
Release: 2
Version: 1.14.2
Release: 5
Summary: Repodata downloading library
License: LGPLv2+
URL: https://github.com/rpm-software-management/librepo
Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
Patch0: backport-Fix-memory-leaks.patch
Patch1: backport-Fix-lr_fastestmirror_prepare-Resource-leaks.patch
Patch2: backport-Fix-lr_get_curl_handle-Check-curl_easy-handle-before.patch
Patch3: backport-lr_get_curl_handle-Strict-check-of-curl_easy_setopt-.patch
Patch4: backport-Remove-may-be-used-uninitialized-compiler-warnings.patch
Patch1: backport-Fix-alloc-free-mismatches-from-covscan.patch
Patch2: backport-More-covscan-fixes.patch
Patch3: backport-Use-g_strdup_vprintf-instead-of-manually-calculating.patch
Patch4: backport-Use-g_list_free_full-to-free-LRMetadataTarget-err.patch
Patch5: backport-Fix-a-memory-leak-in-select_next_target.patch
BuildRequires: cmake check-devel doxygen pkgconfig(glib-2.0) gcc
BuildRequires: libcurl-devel >= %{libcurl_version} pkgconfig(libxml-2.0)
@ -37,7 +37,7 @@ Development files for librepo.
%package -n python3-librepo
Summary: Python 3 bindings for the librepo library
%{?python_provide:%python_provide python3-%{name}}
BuildRequires: python3-devel python3-gpg python3-flask python3-nose
BuildRequires: python3-devel python3-gpg python3-flask
BuildRequires: python3-pyxattr python3-requests python3-sphinx
Requires: %{name} = %{version}-%{release}
Obsoletes: platform-python-%{name} < %{version}-%{release}
@ -84,6 +84,21 @@ popd
%{python3_sitearch}/%{name}/
%changelog
* Mon Oct 21 2024 caixiaomeng <caixiaomeng2@huawei.com> - 1.14.2-5
- backport upstream commits, fix memory leak
* Sat Nov 12 2022 shixuantong <shixuantong1@huawei.com> - 1.14.2-4
- backport upstream commits
* Thu Oct 27 2022 dongyuzhen <dongyuzhen@h-partners.com> - 1.14.2-3
- Rebuild for next release
* Tue Nov 30 2021 fuanan <fuanan3@huawei.com> - 1.14.2-2
- Delete BuildRequires python3-nose
* Tue Nov 30 2021 fuanan <fuanan3@huawei.com> - 1.14.2-1
- update version to 1.14.2
* Sat May 29 2021 fuanan <fuanan3@huawei.com> - 1.12.0-2
- Type:bugfix
- ID:NA