Skip to content

Commit a5868e6

Browse files
authored
Fix coverity warnings (#555)
IB-7552 Signed-off-by: Raul Metsma <[email protected]>
1 parent 7dc3ce9 commit a5868e6

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jobs:
8282
steps:
8383
- name: Install Deps
8484
run: |
85-
dnf install -y \
85+
dnf install -y --setopt=install_weak_deps=False \
8686
git gcc-c++ cmake rpm-build xml-security-c-devel zlib-devel vim-common doxygen boost-test swig python3-devel java-1.8.0-openjdk-devel \
8787
https://www.codesynthesis.com/download/xsd/4.0/linux-gnu/x86_64/xsd-4.0.0-1.x86_64.rpm
8888
- name: Checkout
@@ -105,7 +105,7 @@ jobs:
105105
container: ${{ matrix.container }}
106106
strategy:
107107
matrix:
108-
container: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:23.04']
108+
container: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:23.04', 'ubuntu:23.10']
109109
env:
110110
DEBIAN_FRONTEND: noninteractive
111111
DEBFULLNAME: github-actions

cmake

src/crypto/Digest.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,20 @@ Digest::~Digest() = default;
5151

5252
vector<unsigned char> Digest::addDigestInfo(vector<unsigned char> digest, string_view uri)
5353
{
54-
vector<unsigned char> oid;
5554
switch(toMethod(uri))
5655
{
57-
case NID_sha1: oid = {0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14}; break;
58-
case NID_sha224: oid = {0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1c}; break;
59-
case NID_sha256: oid = {0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20}; break;
60-
case NID_sha384: oid = {0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30}; break;
61-
case NID_sha512: oid = {0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40}; break;
56+
case NID_sha1: digest.insert(digest.cbegin(),
57+
{0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14}); break;
58+
case NID_sha224: digest.insert(digest.cbegin(),
59+
{0x30, 0x2d, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x04, 0x05, 0x00, 0x04, 0x1c}); break;
60+
case NID_sha256: digest.insert(digest.cbegin(),
61+
{0x30, 0x31, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x04, 0x20}); break;
62+
case NID_sha384: digest.insert(digest.begin(),
63+
{0x30, 0x41, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x02, 0x05, 0x00, 0x04, 0x30}); break;
64+
case NID_sha512: digest.insert(digest.cbegin(),
65+
{0x30, 0x51, 0x30, 0x0d, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x03, 0x05, 0x00, 0x04, 0x40}); break;
6266
default: break;
6367
}
64-
if(!oid.empty())
65-
digest.insert(digest.begin(), oid.begin(), oid.end());
6668
return digest;
6769
}
6870

@@ -74,7 +76,7 @@ vector<unsigned char> Digest::digestInfoDigest(const std::vector<unsigned char>
7476
return {};
7577
const ASN1_OCTET_STRING *value {};
7678
X509_SIG_get0(sig.get(), nullptr, &value);
77-
return { value->data, value->data + value->length };
79+
return { value->data, std::next(value->data, value->length) };
7880
}
7981

8082
string Digest::digestInfoUri(const std::vector<unsigned char> &digest)
@@ -141,7 +143,7 @@ int Digest::toMethod(string_view uri)
141143
if(uri == URI_SHA3_384 || uri == URI_RSA_PSS_SHA3_384) return NID_sha3_384;
142144
if(uri == URI_SHA3_512 || uri == URI_RSA_PSS_SHA3_512) return NID_sha3_512;
143145
#endif
144-
THROW("Digest method URI '%.*s' is not supported.", uri.size(), uri.data());
146+
THROW("Digest method URI '%.*s' is not supported.", int(uri.size()), uri.data());
145147
}
146148

147149
string Digest::toRsaUri(const string &uri)

0 commit comments

Comments
 (0)