Rebase to 1.5.1 and address coverity issues

Resolves: rhbz#1938772
This commit is contained in:
Jakub Jelen 2021-04-15 11:52:04 +02:00
parent 899b52c8ca
commit d5b25c5623
4 changed files with 170 additions and 3 deletions

2
.gitignore vendored
View File

@ -18,3 +18,5 @@ libksba-1.0.8.tar.bz2.sig
/libksba-1.4.0.tar.bz2.sig
/libksba-1.5.0.tar.bz2
/libksba-1.5.0.tar.bz2.sig
/libksba-1.5.1.tar.bz2
/libksba-1.5.1.tar.bz2.sig

View File

@ -0,0 +1,157 @@
From f47ac49c068f1bc640f391b8b4a9594486ed0bb7 Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Tue, 13 Apr 2021 22:33:17 +0200
Subject: [PATCH 1/5] tests: reset freed pointer for next iteration
* tests/t-oid.c (main): reset freed pointer for next iteration
--
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
tests/t-oid.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tests/t-oid.c b/tests/t-oid.c
index 0fe5944..04156b6 100644
--- a/tests/t-oid.c
+++ b/tests/t-oid.c
@@ -183,6 +183,7 @@ main (int argc, char **argv)
printf (" %02X", buffer[n]);
putchar ('\n');
free (buffer);
+ buffer = NULL;
}
}
else if (!strcmp (*argv, "--to-str"))
--
2.30.2
From 8c410c22a0366b4ce43d37b62598d8429c3ffc30 Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Tue, 13 Apr 2021 22:36:56 +0200
Subject: [PATCH 2/5] time: avoid buffer overrun
* src/time.c (_ksba_current_time): Use snprintf to avoid buffer overrun
--
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
src/time.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/time.c b/src/time.c
index d793476..f5f3a03 100644
--- a/src/time.c
+++ b/src/time.c
@@ -160,7 +160,7 @@ _ksba_current_time (ksba_isotime_t timebuf)
#else
tp = gmtime ( &epoch );
#endif
- sprintf (timebuf,"%04d%02d%02dT%02d%02d%02d",
- 1900 + tp->tm_year, tp->tm_mon+1, tp->tm_mday,
- tp->tm_hour, tp->tm_min, tp->tm_sec);
+ snprintf (timebuf, sizeof(ksba_isotime_t), "%04d%02d%02dT%02d%02d%02d",
+ 1900 + tp->tm_year, tp->tm_mon+1, tp->tm_mday,
+ tp->tm_hour, tp->tm_min, tp->tm_sec);
}
--
2.30.2
From b8581032f492b4c17d20e966f11afd591ca177ef Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Tue, 13 Apr 2021 22:44:43 +0200
Subject: [PATCH 3/5] asn1-func: Initialize buffer
* src/asn1-func.c (_ksba_asn_expand_object_id): Initialize name2 buffer
--
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
src/asn1-func.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/asn1-func.c b/src/asn1-func.c
index e64c479..05ec897 100755
--- a/src/asn1-func.c
+++ b/src/asn1-func.c
@@ -882,7 +882,7 @@ int
_ksba_asn_expand_object_id (AsnNode node)
{
AsnNode p, p2, p3, p4, p5;
- char name_root[129], name2[129*2+1];
+ char name_root[129], name2[129*2+1] = "";
/* Fixme: Make a cleaner implementation */
if (!node)
--
2.30.2
From ff510b0511443c181b9b9af87bd2596b6a5751fc Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Wed, 14 Apr 2021 10:28:10 +0200
Subject: [PATCH 4/5] ber-decoder: Avoid null pointer dereference on error
* src/ber-decoder.c (_ksba_ber_decoder_dump): break on error
--
The above branches set err if stuff go wrong, but it is never checked
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
src/ber-decoder.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/ber-decoder.c b/src/ber-decoder.c
index 755c1d7..87e58a9 100644
--- a/src/ber-decoder.c
+++ b/src/ber-decoder.c
@@ -1149,6 +1149,8 @@ _ksba_ber_decoder_dump (BerDecoder d, FILE *fp)
err = gpg_error_from_syserror ();
}
}
+ if (err)
+ break;
for (n=0; !err && n < d->val.length; n++)
{
--
2.30.2
From 0431c56f4e1b6d6c3ff302648730da36a18ae93c Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Wed, 14 Apr 2021 10:30:59 +0200
Subject: [PATCH 5/5] Mark the idential branches as intentional for coverity
* src/ber-help.c (_ksba_ber_count_tl): Mark identical branches as
intentional for coverity
--
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
---
src/ber-help.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/ber-help.c b/src/ber-help.c
index 1b72bf0..81c31ed 100644
--- a/src/ber-help.c
+++ b/src/ber-help.c
@@ -440,6 +440,7 @@ _ksba_ber_count_tl (unsigned long tag,
(void)constructed; /* Not used, but passed for uniformity of such calls. */
+ /* coverity[identical_branches] */
if (tag < 0x1f)
{
buflen++;
--
2.30.2

View File

@ -1,6 +1,6 @@
Summary: CMS and X.509 library
Name: libksba
Version: 1.5.0
Version: 1.5.1
Release: 2%{?dist}
# The library is licensed under LGPLv3+ or GPLv2+,
@ -11,6 +11,7 @@ Source0: https://www.gnupg.org/ftp/gcrypt/libksba/libksba-%{version}.tar.bz2
Source1: https://www.gnupg.org/ftp/gcrypt/libksba/libksba-%{version}.tar.bz2.sig
Patch1: libksba-1.3.0-multilib.patch
Patch2: libksba-1.5.1-coverity.patch
BuildRequires: gcc
BuildRequires: gawk
@ -36,6 +37,7 @@ Requires: pkgconfig
%setup -q
%patch1 -p1 -b .multilib
%patch2 -p1 -b .coverity
# Convert to utf-8
for file in THANKS; do
@ -80,6 +82,12 @@ make check
%changelog
* Thu Apr 15 2021 Jakub Jelen <jjelen@redhat.com> - 1.5.1-2
- Address issues reported by coverity
* Wed Apr 07 2021 Jakub Jelen <jjelen@redhat.com> - 1.5.1-1
- New upstream release (#1946544)
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

View File

@ -1,2 +1,2 @@
SHA512 (libksba-1.5.0.tar.bz2) = 84383e8b084bf47ac646a9aacb174e510ffcab4b966b649e4351990eaf7ce78cc9d199e6c4f3a1be697888c857ee86ecef949c06156790c7d8d0bd0fb0142721
SHA512 (libksba-1.5.0.tar.bz2.sig) = 5d608cd03a17b9df48bcfd62a788a93792f482ae8c39f9f69334cccd40116073abbbb37bef81aba2b381eb8bd7e700ca920a766b5bdf0062a6314232fde829c1
SHA512 (libksba-1.5.1.tar.bz2) = 156fe6a36daa7b11ce580366ab36a5fceda253413f0057ace791e4f028fd3158a70a3f6ba1d0c824fafee4420d1076864dbd0911606fb65e14c8b2332b6cc92b
SHA512 (libksba-1.5.1.tar.bz2.sig) = 65ae19253a2f4567d58d76122bd7aac94e2dfe86b34c09feb69b1c4b3b14b53bc061a9afa9f3dd6a7494a46106292be8107ffc74436ec569efdb0746d685ac16