Correct compilation issues

This commit is contained in:
Petr Menšík 2022-01-22 17:55:34 +01:00
parent ae238f1389
commit 55b24201ff
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,41 @@
From 1f30af480852de8aa9ccba77a99d55b06832fc87 Mon Sep 17 00:00:00 2001
From: Petr Mensik <pemensik@redhat.com>
Date: Sat, 22 Jan 2022 17:51:48 +0100
Subject: [PATCH] Ensure variable is not used after free
Move free to end of function, where it would not need that variable
again.
---
backends/hosts.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/backends/hosts.c b/backends/hosts.c
index a93f74c..2378b6f 100644
--- a/backends/hosts.c
+++ b/backends/hosts.c
@@ -126,13 +126,13 @@ read_list(struct hosts_list *list)
char *new;
size_t size;
- free(hosts_file);
if (fd == -1) {
error("Cannot read hosts file '%s': %s", hosts_file, strerror(errno));
goto fail_open;
}
+
while (true) {
if (current == end)
goto out;
@@ -166,6 +166,7 @@ read_list(struct hosts_list *list)
out:
close(fd);
fail_open:
+ free(hosts_file);
add_node(list, NULL, 0, NULL, 0);
list->reserved = list->count;
list->items = realloc(list->items, list->reserved * sizeof *list->items);
--
2.31.1

View File

@ -2,7 +2,7 @@
Name: netresolve
Version: 0.0.1
Release: 0.32%{?snapshot_suffix}%{?dist}
Release: 0.33%{?snapshot_suffix}%{?dist}
Summary: Generic name resolution library
License: BSD
# https://github.com/crossdistro/netresolve , possibly?
@ -14,6 +14,7 @@ Patch0: netresolve-0.0.1-test-equality.patch
Patch1: netresolve-0.0.1-strncpy.patch
# https://github.com/crossdistro/netresolve/issues/3
Patch2: netresolve-0.0.1-hosts.patch
Patch3: netresolve-0.0.1-use-after-free.patch
BuildRequires: make
BuildRequires: ldns-devel
@ -237,6 +238,9 @@ make check || { cat ./test-suite.log; false; }
%{_libdir}/libnss_netresolve.so
%changelog
* Sat Jan 22 2022 Petr Menšík <pemensik@redhat.com> - 0.0.1-0.33.20160317git
- Correct compilation issues
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.0.1-0.32.20160317git
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild