Fix coverity issues
This commit is contained in:
parent
dc82d3fa11
commit
b635ba9b78
151
librtas-2.0.2-coverity.patch
Normal file
151
librtas-2.0.2-coverity.patch
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
diff -up librtas-2.0.2/librtasevent_src/rtas_srcfru.c.me librtas-2.0.2/librtasevent_src/rtas_srcfru.c
|
||||||
|
--- librtas-2.0.2/librtasevent_src/rtas_srcfru.c.me 2021-03-25 09:43:12.764393426 +0100
|
||||||
|
+++ librtas-2.0.2/librtasevent_src/rtas_srcfru.c 2021-03-25 10:00:06.013239296 +0100
|
||||||
|
@@ -238,9 +238,10 @@ parse_src_scn(struct rtas_event *re)
|
||||||
|
|
||||||
|
add_re_scn(re, src, re_scn_id(&src_raw->v6hdr));
|
||||||
|
|
||||||
|
- if (!src_subscns_included(src))
|
||||||
|
+ if (!src_subscns_included(src)) {
|
||||||
|
+ free (src_raw);
|
||||||
|
return 0;
|
||||||
|
-
|
||||||
|
+ }
|
||||||
|
rtas_copy( (char *) src_raw + RE_SRC_SCN_SZ + 4, re, RE_SRC_SUBSCN_SZ);
|
||||||
|
|
||||||
|
src->subscn_id = src_raw->subscn_id;
|
||||||
|
@@ -260,6 +261,7 @@ parse_src_scn(struct rtas_event *re)
|
||||||
|
if (fru == NULL) {
|
||||||
|
cleanup_rtas_event(re);
|
||||||
|
errno = ENOMEM;
|
||||||
|
+ free(src_raw);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -288,6 +290,8 @@ parse_src_scn(struct rtas_event *re)
|
||||||
|
|
||||||
|
if (cur_fruhdr == NULL) {
|
||||||
|
cleanup_rtas_event(re);
|
||||||
|
+ free(src_raw);
|
||||||
|
+ free(fru);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -309,6 +313,7 @@ parse_src_scn(struct rtas_event *re)
|
||||||
|
total_len += fru->length;
|
||||||
|
} while (total_len < srcsub_len);
|
||||||
|
|
||||||
|
+ free(src_raw);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -up librtas-2.0.2/librtasevent_src/rtas_vend.c.me librtas-2.0.2/librtasevent_src/rtas_vend.c
|
||||||
|
--- librtas-2.0.2/librtasevent_src/rtas_vend.c.me 2021-03-25 10:00:29.520558410 +0100
|
||||||
|
+++ librtas-2.0.2/librtasevent_src/rtas_vend.c 2021-03-25 10:03:25.367951457 +0100
|
||||||
|
@@ -116,6 +116,7 @@ parse_vend_errlog_scn(struct rtas_event
|
||||||
|
ve->vendor_data = malloc(ve->vendor_data_sz);
|
||||||
|
if (ve->vendor_data == NULL) {
|
||||||
|
errno = ENOMEM;
|
||||||
|
+ free(ve);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff -up librtas-2.0.2/librtasevent_src/get_rtas_event.c.me librtas-2.0.2/librtasevent_src/get_rtas_event.c
|
||||||
|
--- librtas-2.0.2/librtasevent_src/get_rtas_event.c.me 2021-03-25 11:26:19.754142871 +0100
|
||||||
|
+++ librtas-2.0.2/librtasevent_src/get_rtas_event.c 2021-03-25 11:29:24.322686995 +0100
|
||||||
|
@@ -29,6 +29,10 @@
|
||||||
|
#include "librtasevent.h"
|
||||||
|
#include "rtas_event.h"
|
||||||
|
|
||||||
|
+#if __GNUC__ >= 9
|
||||||
|
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* rtas_copy
|
||||||
|
* @brief front end for common memcpy calls
|
||||||
|
diff -up librtas-2.0.2/librtasevent_src/rtas_post.c.me librtas-2.0.2/librtasevent_src/rtas_post.c
|
||||||
|
--- librtas-2.0.2/librtasevent_src/rtas_post.c.me 2021-03-25 11:52:35.489805806 +0100
|
||||||
|
+++ librtas-2.0.2/librtasevent_src/rtas_post.c 2021-03-25 12:11:38.817324108 +0100
|
||||||
|
@@ -139,6 +139,7 @@ print_re_post_scn(struct scn_header *shd
|
||||||
|
len += rtas_print("Self-test error in firmware extended "
|
||||||
|
"diagnostics.\n");
|
||||||
|
|
||||||
|
+ /* coverity[invalid_type : FALSE] */
|
||||||
|
len += rtas_print("POST Error Code: %x\n", post->err_code);
|
||||||
|
len += rtas_print("Firmware Revision Code: %x\n", post->firmware_rev);
|
||||||
|
|
||||||
|
diff -up librtas-2.0.2/librtasevent_src/rtas_v6_misc.c.me librtas-2.0.2/librtasevent_src/rtas_v6_misc.c
|
||||||
|
--- librtas-2.0.2/librtasevent_src/rtas_v6_misc.c.me 2021-03-25 11:29:57.445143562 +0100
|
||||||
|
+++ librtas-2.0.2/librtasevent_src/rtas_v6_misc.c 2021-03-25 11:30:05.924260442 +0100
|
||||||
|
@@ -28,6 +28,10 @@
|
||||||
|
#include "librtasevent.h"
|
||||||
|
#include "rtas_event.h"
|
||||||
|
|
||||||
|
+#if __GNUC__ >= 9
|
||||||
|
+#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* months
|
||||||
|
* @brief array of month strings
|
||||||
|
diff -up librtas-2.0.2/librtas_src/syscall_calls.c.me librtas-2.0.2/librtas_src/syscall_calls.c
|
||||||
|
--- librtas-2.0.2/librtas_src/syscall_calls.c.me 2021-03-25 11:34:20.691775299 +0100
|
||||||
|
+++ librtas-2.0.2/librtas_src/syscall_calls.c 2021-03-25 11:49:03.830951225 +0100
|
||||||
|
@@ -886,7 +886,7 @@ int rtas_platform_dump(uint64_t dump_tag
|
||||||
|
uint32_t next_hi, next_lo;
|
||||||
|
uint32_t bytes_hi, bytes_lo;
|
||||||
|
uint32_t dump_tag_hi, dump_tag_lo;
|
||||||
|
- void *kernbuf;
|
||||||
|
+ void *kernbuf = NULL;
|
||||||
|
int rc, status;
|
||||||
|
|
||||||
|
rc = sanity_check();
|
||||||
|
@@ -927,6 +927,7 @@ int rtas_platform_dump(uint64_t dump_tag
|
||||||
|
if (buffer && (rc == 0))
|
||||||
|
memcpy(buffer, kernbuf, length);
|
||||||
|
|
||||||
|
+ /* coverity[uninit_use : FALSE] */
|
||||||
|
if (kernbuf)
|
||||||
|
(void)rtas_free_rmo_buffer(kernbuf, kernbuf_pa, length);
|
||||||
|
|
||||||
|
diff -up librtas-2.0.2/librtas_src/syscall_rmo.c.me librtas-2.0.2/librtas_src/syscall_rmo.c
|
||||||
|
--- librtas-2.0.2/librtas_src/syscall_rmo.c.me 2021-03-25 11:49:26.704266218 +0100
|
||||||
|
+++ librtas-2.0.2/librtas_src/syscall_rmo.c 2021-03-25 12:47:12.108229574 +0100
|
||||||
|
@@ -247,6 +247,7 @@ static int get_phys_region(size_t size,
|
||||||
|
if (bits == 0ll) {
|
||||||
|
if (acquire_file_lock(i, n_pages) == 0) {
|
||||||
|
set_bits(i, i + n_pages - 1,
|
||||||
|
+ /* coverity[overflow_before_widen : FALSE] */
|
||||||
|
(1 << n_pages) - 1,
|
||||||
|
&wa_config.pages_map);
|
||||||
|
addr = kregion->addr + (i * PAGE_SIZE);
|
||||||
|
@@ -289,6 +290,7 @@ static int release_phys_region(uint32_t
|
||||||
|
|
||||||
|
bits = get_bits(first_page, first_page + n_pages - 1,
|
||||||
|
wa_config.pages_map);
|
||||||
|
+ /* coverity[overflow_before_widen : FALSE] */
|
||||||
|
if (bits != ((1 << n_pages) - 1)) {
|
||||||
|
dbg("Invalid region [0x%x, 0x%zx]\n", phys_addr, size);
|
||||||
|
return RTAS_IO_ASSERT;
|
||||||
|
diff -up librtas-2.0.2/librtasevent_src/rtas_srcfru.c.me librtas-2.0.2/librtasevent_src/rtas_srcfru.c
|
||||||
|
--- librtas-2.0.2/librtasevent_src/rtas_srcfru.c.me 2021-03-26 08:52:29.399602640 +0100
|
||||||
|
+++ librtas-2.0.2/librtasevent_src/rtas_srcfru.c 2021-03-26 08:52:38.501720153 +0100
|
||||||
|
@@ -74,13 +74,13 @@ parse_fru_id_scn(struct rtas_event *re)
|
||||||
|
re->offset += RE_FRU_HDR_SZ;
|
||||||
|
|
||||||
|
if (fruid_has_part_no(fru_id)) {
|
||||||
|
- strcpy(fru_id->part_no, RE_EVENT_OFFSET(re));
|
||||||
|
- re->offset += 8;
|
||||||
|
+ rtas_copy(fru_id->part_no, re, 7);
|
||||||
|
+ fru_id->part_no[7] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fruid_has_proc_id(fru_id)) {
|
||||||
|
- strcpy(fru_id->procedure_id, RE_EVENT_OFFSET(re));
|
||||||
|
- re->offset += 8;
|
||||||
|
+ rtas_copy(fru_id->procedure_id, re, 7);
|
||||||
|
+ fru_id->procedure_id[7] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fruid_has_ccin(fru_id)) {
|
16
librtas.spec
16
librtas.spec
@ -1,7 +1,7 @@
|
|||||||
Summary: Libraries to provide access to RTAS calls and RTAS events
|
Summary: Libraries to provide access to RTAS calls and RTAS events
|
||||||
Name: librtas
|
Name: librtas
|
||||||
Version: 2.0.2
|
Version: 2.0.2
|
||||||
Release: 7%{?dist}
|
Release: 8%{?dist}
|
||||||
URL: https://github.com/nfont/librtas
|
URL: https://github.com/nfont/librtas
|
||||||
License: LGPL
|
License: LGPL
|
||||||
|
|
||||||
@ -11,8 +11,8 @@ BuildRequires: autoconf
|
|||||||
BuildRequires: libtool
|
BuildRequires: libtool
|
||||||
BuildRequires: make
|
BuildRequires: make
|
||||||
|
|
||||||
# Fedora specific patch
|
Patch0: librtas-2.0.1-libversion.patch
|
||||||
Patch0: %{name}-2.0.1-libversion.patch
|
Patch1: librtas-2.0.2-coverity.patch
|
||||||
|
|
||||||
ExclusiveArch: %{power64}
|
ExclusiveArch: %{power64}
|
||||||
|
|
||||||
@ -35,16 +35,11 @@ The librtas-devel packages contains the header files necessary for
|
|||||||
developing programs using librtas.
|
developing programs using librtas.
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q -n %{name}-%{version}
|
%autosetup -p1
|
||||||
%patch0 -p1 -b .ln
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
# disable "-Werror=format-security" checking gcc option until we fix
|
|
||||||
# these errors in our code.
|
|
||||||
%configure --disable-silent-rules --disable-static
|
%configure --disable-silent-rules --disable-static
|
||||||
CFLAGS="%{optflags} -fPIC -DPIC -I."
|
|
||||||
CFLAGS=`echo $CFLAGS | sed 's/-Werror=format-security//'`
|
|
||||||
%make_build CFLAGS="$CFLAGS"
|
%make_build CFLAGS="$CFLAGS"
|
||||||
|
|
||||||
%install
|
%install
|
||||||
@ -73,6 +68,9 @@ rm -f %{buildroot}/%{_docdir}/librtas/*
|
|||||||
%{_includedir}/librtasevent_v6.h
|
%{_includedir}/librtasevent_v6.h
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Mar 26 2021 Than Ngo <than@redhat.com> - 2.0.2-8
|
||||||
|
- Fix coverity issues
|
||||||
|
|
||||||
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.2-7
|
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.0.2-7
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user