Fix important Covscan defects

- resolves: #1938712
This commit is contained in:
Nikola Forró 2021-07-30 16:28:51 +02:00
parent 1a33315f8b
commit c5436ad5de
5 changed files with 86 additions and 1 deletions

27
coverity.patch Normal file
View File

@ -0,0 +1,27 @@
diff --git a/src/arch-ia64.c b/src/arch-ia64.c
index 2573d69..6ca1129 100644
--- a/src/arch-ia64.c
+++ b/src/arch-ia64.c
@@ -119,8 +119,8 @@ ia64_adjust_rela (DSO *dso, GElf_Rela *rela, GElf_Addr start,
}
else
{
- write_le64 (dso, rela->r_offset, val);
- write_le64 (dso, rela->r_offset + 8, gp);
+ write_be64 (dso, rela->r_offset, val);
+ write_be64 (dso, rela->r_offset + 8, gp);
}
}
return 0;
diff --git a/src/fptr.c b/src/fptr.c
index cfe3aed..5d68c11 100644
--- a/src/fptr.c
+++ b/src/fptr.c
@@ -458,6 +458,7 @@ opd_size (struct prelink_info *info, GElf_Word entsize)
e->val = f->val;
e->gp = f->gp;
e->opd = ret | OPD_ENT_NEW;
+ f->ent = e;
ret += entsize;
}

View File

@ -1,6 +1,6 @@
Name: execstack Name: execstack
Version: 0.5.0 Version: 0.5.0
Release: 21%{?dist} Release: 22%{?dist}
Summary: Utility to set/clear/query executable stack bit Summary: Utility to set/clear/query executable stack bit
%global commit 4c79120bcdbde0616f592458ccde7035e92ca3d8 %global commit 4c79120bcdbde0616f592458ccde7035e92ca3d8
@ -11,6 +11,7 @@ License: GPLv2+
Source0: https://github.com/keszybz/prelink/archive/%{commit}.tar.gz#/prelink-%{shortcommit}.tar.gz Source0: https://github.com/keszybz/prelink/archive/%{commit}.tar.gz#/prelink-%{shortcommit}.tar.gz
Patch0: Add-PL_ARCH-for-AArch64.patch Patch0: Add-PL_ARCH-for-AArch64.patch
Patch1: coverity.patch
BuildRequires: gcc BuildRequires: gcc
BuildRequires: gcc-c++ BuildRequires: gcc-c++
@ -58,6 +59,10 @@ install -Dm0644 doc/execstack.8 %{buildroot}%{_mandir}/man8/execstack.8
%{_mandir}/man8/execstack.8.* %{_mandir}/man8/execstack.8.*
%changelog %changelog
* Fri Jul 30 2021 Nikola Forró <nforro@redhat.com> - 0.5.0-22
- Fix important Covscan defects
resolves: #1938712
* Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 0.5.0-21 * Thu Apr 15 2021 Mohan Boddu <mboddu@redhat.com> - 0.5.0-21
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937 - Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937

6
gating.yaml Normal file
View File

@ -0,0 +1,6 @@
--- !Policy
product_versions:
- rhel-9
decision_context: osci_compose_gate
rules:
- !PassingTestCaseRule {test_case_name: osci.brew-build.tier0.functional}

35
tests/test_execstack Executable file
View File

@ -0,0 +1,35 @@
#!/bin/bash
. /usr/share/beakerlib/beakerlib.sh
TEST="/CRB/execstack/Sanity/execstack"
PACKAGES=${PACKAGES:-execstack}
REQUIRES=${REQUIRES:-gcc}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm --all
rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"
rlRun "pushd $TmpDir"
rlPhaseEnd
rlPhaseStartTest
rlRun "echo 'int main() {}' | gcc -x c -z noexecstack - -o A" 0 "Compiling binary without executable stack"
rlRun "echo 'int main() {}' | gcc -x c -z execstack - -o B" 0 "Compiling binary with executable stack"
rlRun "execstack --query A > out" 0 "Querying binary A"
rlAssertGrep "^-" "out"
rlRun "execstack --query B > out" 0 "Querying binary B"
rlAssertGrep "^X" "out"
rlRun "execstack --clear-execstack B" 0 "Clearing executable stack marking from binary B"
rlRun "execstack --query B > out" 0 "Querying binary B"
rlAssertGrep "^-" "out"
rlPhaseEnd
rlPhaseStartCleanup
rlRun "popd"
rlRun "rm -r $TmpDir" 0 "Removing tmp directory"
rlPhaseEnd
rlJournalEnd
rlJournalPrintText

12
tests/tests.yml Normal file
View File

@ -0,0 +1,12 @@
- hosts: localhost
roles:
- role: standard-test-beakerlib
tags:
- atomic
- classic
- container
tests:
- test_execstack
required_packages:
- execstack
- gcc