From 4635adeda3d3264fa736001dc092574578752b03 Mon Sep 17 00:00:00 2001 From: yixiangzhike Date: Sat, 19 Feb 2022 09:44:17 +0800 Subject: [PATCH] Fix printf usage errors highlighted by covscan (cherry picked from commit 8522b70b8c04fcb2f69b899893584e87da7415a3) --- ...-usage-errors-highlighted-by-covscan.patch | 103 ++++++++++++++++++ libkcapi.spec | 9 +- 2 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 backport-Fix-printf-usage-errors-highlighted-by-covscan.patch diff --git a/backport-Fix-printf-usage-errors-highlighted-by-covscan.patch b/backport-Fix-printf-usage-errors-highlighted-by-covscan.patch new file mode 100644 index 0000000..d2768b3 --- /dev/null +++ b/backport-Fix-printf-usage-errors-highlighted-by-covscan.patch @@ -0,0 +1,103 @@ +From b5ff1b7aa1f5f7c139b4b5e35be07a8d527c9336 Mon Sep 17 00:00:00 2001 +From: Simo Sorce +Date: Thu, 15 Jul 2021 07:24:37 -0400 +Subject: [PATCH] Fix printf usage errors highlighted by covscan + +More fallout from the type changes in the API. + +Signed-off-by: Simo Sorce +Signed-off-by: Stephan Mueller +--- + apps/kcapi-dgst.c | 8 ++++---- + apps/kcapi-enc.c | 2 +- + apps/kcapi-rng.c | 8 ++++---- + 3 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/apps/kcapi-dgst.c b/apps/kcapi-dgst.c +index 6e9350a..9cd99dc 100644 +--- a/apps/kcapi-dgst.c ++++ b/apps/kcapi-dgst.c +@@ -139,7 +139,7 @@ static int cipher_op(struct kcapi_handle *handle, struct opt_data *opts) + + if ((uint32_t)ret != kcapi_md_digestsize(handle)) { + dolog(KCAPI_LOG_ERR, +- "Unexpected digest output size: %d (expected %u)\n", ++ "Unexpected digest output size: %ld (expected %u)\n", + ret, kcapi_md_digestsize(handle)); + ret = -EFAULT; + goto out; +@@ -157,7 +157,7 @@ static int cipher_op(struct kcapi_handle *handle, struct opt_data *opts) + } + } + +- dolog(KCAPI_LOG_VERBOSE, "Digest of %d bytes generated\n", ret); ++ dolog(KCAPI_LOG_VERBOSE, "Digest of %ld bytes generated\n", ret); + } else { + if ((uint64_t)outsb.st_size != outlen) { + ret = ftruncate(outfd, outlen); +@@ -183,7 +183,7 @@ static int cipher_op(struct kcapi_handle *handle, struct opt_data *opts) + + if ((uint32_t)ret != kcapi_md_digestsize(handle)) { + dolog(KCAPI_LOG_ERR, +- "Unexpected digest output size: %d (expected %u)\n", ++ "Unexpected digest output size: %ld (expected %u)\n", + ret, kcapi_md_digestsize(handle)); + ret = -EFAULT; + goto out; +@@ -193,7 +193,7 @@ static int cipher_op(struct kcapi_handle *handle, struct opt_data *opts) + bin2hex(tmpbuf, kcapi_md_digestsize(handle), + (char *)outmem, outlen, 0); + +- dolog(KCAPI_LOG_VERBOSE, "Digest of %d bytes generated\n", ret); ++ dolog(KCAPI_LOG_VERBOSE, "Digest of %ld bytes generated\n", ret); + } + + out: +diff --git a/apps/kcapi-enc.c b/apps/kcapi-enc.c +index 0f92c38..20588dd 100644 +--- a/apps/kcapi-enc.c ++++ b/apps/kcapi-enc.c +@@ -273,7 +273,7 @@ static size_t outbufsize(struct kcapi_handle *handle, struct opt_data *opts, + opts->func_blocksize(handle); + } + +- dolog(KCAPI_LOG_DEBUG, "Data size expected to be generated: %u", ++ dolog(KCAPI_LOG_DEBUG, "Data size expected to be generated: %lu", + outsize); + + return outsize; +diff --git a/apps/kcapi-rng.c b/apps/kcapi-rng.c +index 1ace323..14af437 100644 +--- a/apps/kcapi-rng.c ++++ b/apps/kcapi-rng.c +@@ -84,15 +84,15 @@ static ssize_t get_random(uint8_t *buf, size_t buflen) + #ifdef HAVE_GETRANDOM + ret = getrandom(buf, buflen, 0); + dolog(KCAPI_LOG_DEBUG, +- "Accessed getrandom system call for %u bytes", buflen); ++ "Accessed getrandom system call for %lu bytes", buflen); + #elif defined __NR_getrandom + ret = syscall(__NR_getrandom, buf, buflen, 0); + dolog(KCAPI_LOG_DEBUG, +- "Accessed getrandom system call for %u bytes", buflen); ++ "Accessed getrandom system call for %lu bytes", buflen); + #else + ret = read(random_fd, buf, buflen); + dolog(KCAPI_LOG_DEBUG, +- "Accessed /dev/urandom for %u bytes", buflen); ++ "Accessed /dev/urandom for %lu bytes", buflen); + #endif + if (0 < ret) { + buflen -= (size_t)ret; +@@ -286,7 +286,7 @@ int main(int argc, char *argv[]) + ret = kcapi_rng_seed(rng, seedbuf, seedsize); + if (ret) + dolog(KCAPI_LOG_WARN, +- "User-provided seed of %lu bytes not accepted by DRNG (error: %d)", ++ "User-provided seed of %lu bytes not accepted by DRNG (error: %ld)", + (unsigned long)sizeof(buf), ret); + else + dolog(KCAPI_LOG_DEBUG, +-- +1.8.3.1 + diff --git a/libkcapi.spec b/libkcapi.spec index 9ea4d4e..cb3655c 100644 --- a/libkcapi.spec +++ b/libkcapi.spec @@ -4,7 +4,7 @@ Name: libkcapi Version: 1.3.1 -Release: 2 +Release: 3 Summary: libkcapi - Linux Kernel Crypto API User Space Interface Library License: BSD or GPLv2 @@ -13,6 +13,7 @@ Source0: http://www.chronox.de/%{name}/%{name}-%{version}.tar.xz Source1: http://www.chronox.de/%{name}/%{name}-%{version}.tar.xz.asc Patch0: libkcapi-1.1.1-lib_Fix_kcapi_handle_destroy_closing_FD_0.patch +Patch1: backport-Fix-printf-usage-errors-highlighted-by-covscan.patch BuildRequires: clang coreutils cppcheck docbook-utils-pdf gcc hardlink BuildRequires: libtool openssl perl systemd xmlto kernel-headers >= 4.10.0 @@ -194,6 +195,12 @@ popd %{_mandir}/man3/kcapi_*.3.* %changelog +* Sat Feb 19 2022 yixiangzhike - 1.3.1-3 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC:Fix printf usage errors highlighted by covscan + * Wed Jan 26 2022 yixiangzhike - 1.3.1-2 - Type:enhancement - ID:NA -- Gitee