- libkmipclient: Fix parsing of hex values for XML and JSON encoding (#1870700)

- Resolves: #1870700
This commit is contained in:
Dan Horák 2021-08-06 10:14:03 +02:00
parent 152ca9dfde
commit 44494aca30
2 changed files with 77 additions and 4 deletions

View File

@ -1,7 +1,11 @@
From 2e70a381e8064b9112e30b44a4be0d6c5811a0fd Mon Sep 17 00:00:00 2001
From 66cca7c6765be5a5207315a8df6de599bba306cb Mon Sep 17 00:00:00 2001
From: Alexander Egorenkov <egorenar@linux.ibm.com>
Date: Wed, 21 Jul 2021 17:22:29 +0200
Subject: [PATCH] hsavmcore: Avoid recompilation of overlay during install step
Subject: [PATCH 1/2] hsavmcore: Avoid recompilation of overlay during install
step
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
overlay.o was being recompiled during the install step because
it depended on the target check-dep-fuse which is phony and,
@ -9,9 +13,12 @@ therefore, always outdated. The solution is to create an empty file
for the target check-dep-fuse after its successful completion. This
prevents make from rebuilding overlay.o during installation.
Fixes: 5a7d2a58 ("hsavmcore: Fix fuse dependency checking")
Closes: https://github.com/ibm-s390-linux/s390-tools/pull/118
Fixes: 5a7d2a58c8b3 ("hsavmcore: Fix fuse dependency checking")
Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Suggested-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
(cherry picked from commit 80cb1553a30d7804d1521691e9b178c7613eaa8c)
---
hsavmcore/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
@ -39,3 +46,65 @@ index 7c1d4fd..82e6abc 100644
--
2.31.1
From f6f24d191ed29a1c6d49c1339e09f21fe7d24c19 Mon Sep 17 00:00:00 2001
From: Ingo Franzki <ifranzki@linux.ibm.com>
Date: Mon, 12 Jul 2021 13:20:52 +0200
Subject: [PATCH 2/2] libkmipclient: Fix parsing of hex values for XML and JSON
encoding (#1870700)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
KMIP values of type BYTE-STRING are represented as hex values when XML
or JSON encoding is used. Do not drop any leading zero bytes, if the
value has them.
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
(cherry picked from commit d2a4a8b0f3f24a19bd0363b5a4f264b50ac4a885)
---
libkmipclient/utils.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/libkmipclient/utils.c b/libkmipclient/utils.c
index 4a88d0c..dbd03fd 100644
--- a/libkmipclient/utils.c
+++ b/libkmipclient/utils.c
@@ -125,7 +125,7 @@ int kmip_parse_hex(const char *str, bool has_prefix, unsigned char **val,
{
unsigned char *buf;
BIGNUM *b = NULL;
- int len, rc;
+ int len;
if (str == NULL)
return -EINVAL;
@@ -133,18 +133,20 @@ int kmip_parse_hex(const char *str, bool has_prefix, unsigned char **val,
if (has_prefix && strncmp(str, "0x", 2) != 0)
return -EBADMSG;
- rc = BN_hex2bn(&b, str + (has_prefix ? 2 : 0));
- if (rc <= 0)
+ len = BN_hex2bn(&b, str + (has_prefix ? 2 : 0));
+ if (len <= 0)
+ return -EBADMSG;
+ if (len < (int)strlen(str) - (has_prefix ? 2 : 0))
return -EBADMSG;
- len = BN_num_bytes(b);
+ len = len / 2 + (len % 2 > 0 ? 1 : 0);
buf = calloc(1, len);
if (buf == NULL) {
BN_free(b);
return -ENOMEM;
}
- if (BN_bn2bin(b, buf) != len) {
+ if (BN_bn2binpad(b, buf, len) != len) {
BN_free(b);
free(buf);
return -EIO;
--
2.31.1

View File

@ -6,7 +6,7 @@
Name: s390utils
Summary: Utilities and daemons for IBM z Systems
Version: 2.17.0
Release: 2%{?dist}
Release: 3%{?dist}
Epoch: 2
License: MIT
ExclusiveArch: s390 s390x
@ -826,6 +826,10 @@ User-space development files for the s390/s390x architecture.
%changelog
* Fri Aug 06 2021 Dan Horák <dan[at]danny.cz> - 2:2.17.0-3
- libkmipclient: Fix parsing of hex values for XML and JSON encoding (#1870700)
- Resolves: #1870700
* Thu Jul 22 2021 Dan Horák <dan[at]danny.cz> - 2:2.17.0-2
- fix build
- Related: #1869554