Skip to content

Commit de7c633

Browse files
authored
volume_key: fix build (#10952)
1 parent fbfa3b6 commit de7c633

2 files changed

Lines changed: 85 additions & 7 deletions

File tree

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
diff --git a/lib/kmip.c b/lib/kmip.c
2+
index dda819a..333603c 100644
3+
--- a/lib/kmip.c
4+
+++ b/lib/kmip.c
5+
@@ -1152,6 +1152,7 @@ kmip_decode_key_value (struct kmip_decoding_state *kmip,
6+
break;
7+
8+
default:
9+
+ kmip_key_value_free (res);
10+
g_return_val_if_reached (-1);
11+
}
12+
res->attributes = g_ptr_array_new ();
13+
@@ -1348,6 +1349,7 @@ kmip_decode_object_symmetric_key (struct kmip_decoding_state *kmip,
14+
g_snprintf (num, sizeof (num), "%" G_GUINT32_FORMAT, res->block->type);
15+
g_set_error (error, LIBVK_ERROR, LIBVK_ERROR_KMIP_UNSUPPORTED_VALUE,
16+
_("Unsupported symmetric key format %s"), num);
17+
+ kmip_object_symmetric_key_free (res);
18+
return -1;
19+
}
20+
*obj = res;
21+
@@ -1384,6 +1386,7 @@ kmip_decode_object_secret_data (struct kmip_decoding_state *kmip,
22+
g_snprintf (num, sizeof (num), "%" G_GUINT32_FORMAT, res->block->type);
23+
g_set_error (error, LIBVK_ERROR, LIBVK_ERROR_KMIP_UNSUPPORTED_VALUE,
24+
_("Unsupported symmetric key format %s"), num);
25+
+ kmip_object_secret_data_free (res);
26+
return -1;
27+
}
28+
*obj = res;
29+
diff --git a/lib/volume_luks.c b/lib/volume_luks.c
30+
index d1c5d47..4d32d9b 100644
31+
--- a/lib/volume_luks.c
32+
+++ b/lib/volume_luks.c
33+
@@ -547,8 +547,8 @@ luks_apply_secret (struct libvk_volume *vol, const struct libvk_volume *packet,
34+
}
35+
g_free (last_log_entry);
36+
37+
- g_return_val_if_fail (vol->v.luks->key_bytes == packet->v.luks->key_bytes,
38+
- -1);
39+
+ if (vol->v.luks->key_bytes != packet->v.luks->key_bytes)
40+
+ goto err_passphrase;
41+
luks_replace_key (vol, packet->v.luks->key);
42+
luks_replace_passphrase (vol, passphrase);
43+
vol->v.luks->passphrase_slot = res;
44+
diff --git a/src/volume_key.c b/src/volume_key.c
45+
index 074b187..24b70d6 100644
46+
--- a/src/volume_key.c
47+
+++ b/src/volume_key.c
48+
@@ -735,6 +735,11 @@ write_packet (struct packet_output_state *pos, const char *filename,
49+
|| g_file_set_contents (filename, packet, size, error) == FALSE)
50+
{
51+
g_prefix_error (error, _("Error creating `%s': "), filename);
52+
+ if (packet != NULL) {
53+
+ if (output_format_cleartext != 0)
54+
+ memset (packet, 0, size);
55+
+ g_free (packet);
56+
+ }
57+
return -1;
58+
}
59+
if (output_format_cleartext != 0)

SPECS-EXTENDED/volume_key/volume_key.spec

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Distribution: Azure Linux
2323
Summary: An utility for manipulating storage encryption keys and passphrases
2424
Name: volume_key
2525
Version: 0.3.12
26-
Release: 8%{?dist}
26+
Release: 9%{?dist}
2727
# lib/{SECerrs,SSLerrs}.h are both licensed under MPLv1.1, GPLv2 and LGPLv2
2828
License: GPLv2 and (MPLv1.1 or GPLv2 or LGPLv2)
2929
URL: https://pagure.io/%{name}/
@@ -33,9 +33,24 @@ Source0: https://releases.pagure.org/%{name}/%{name}-%{version}.tar.xz
3333
# Support all LUKS devices
3434
# - backport of 26c09768662d8958debe8c9410dae9fda02292c3
3535
Patch0: volume_key-0.3.12-support_LUKS2_and_more.patch
36+
# Fix resource leaks
37+
# - backport of bf6618ec0b09b4e51fc97fa021e687fbd87599ba
38+
Patch1: volume_key-0.3.12-fix_resource_leaks.patch
39+
3640
BuildRequires: gcc
37-
BuildRequires: cryptsetup-luks-devel, gettext-devel, glib2-devel, /usr/bin/gpg2
38-
BuildRequires: gpgme-devel, libblkid-devel, nss-devel, python3-devel
41+
BuildRequires: autoconf
42+
BuildRequires: automake
43+
BuildRequires: libtool
44+
BuildRequires: make
45+
46+
BuildRequires: cryptsetup-luks-devel
47+
BuildRequires: gettext-devel
48+
BuildRequires: glib2-devel
49+
BuildRequires: /usr/bin/gpg2
50+
BuildRequires: gpgme-devel
51+
BuildRequires: libblkid-devel
52+
BuildRequires: nss-devel
53+
BuildRequires: python3-devel
3954
%if 0%{?drop_python2} < 1
4055
BuildRequires: python2-devel
4156
%endif
@@ -105,15 +120,15 @@ Requires: %{name}-libs%{?_isa} = %{version}-%{release}
105120
%endif
106121

107122
%prep
108-
%setup -q
109-
%patch 0 -p1
123+
%autosetup -p1
124+
autoreconf -fiv
110125

111126
%build
112127
%configure %{?with_pythons}
113-
make %{?_smp_mflags}
128+
%make_build
114129

115130
%install
116-
make install DESTDIR=$RPM_BUILD_ROOT INSTALL='install -p'
131+
%make_install
117132

118133
# Remove libtool archive
119134
find %{buildroot} -type f -name "*.la" -delete
@@ -157,6 +172,10 @@ exit 1; \
157172
%endif
158173

159174
%changelog
175+
* Wed Nov 06 2024 Jyoti Kanase <v-jykanase@microsoft.com> - 0.3.12-9
176+
- added patch to fix resource leaks
177+
- License Verified
178+
160179
* Mon Mar 16 2021 Henry Li <lihl@microsoft.com> - 0.3.12-8
161180
- Initial CBL-Mariner import from Fedora 32 (license: MIT).
162181
- Disable python2 build and enable python3 build

0 commit comments

Comments
 (0)