Compare commits

..

1 Commits
master ... f27

Author SHA1 Message Date
Brian C. Lane 4390d41ad0 - Fix aligned alloc parameters and overflow on 32bit (#1497458) 2017-10-03 10:58:53 -07:00
4 changed files with 102 additions and 62 deletions

2
.gitignore vendored
View File

@ -4,5 +4,3 @@
/1.1.0.tar.gz
/1.2.0.tar.gz
/1.2.1.tar.gz
/1.2.2.tar.gz
/1.2.3.tar.gz

View File

@ -0,0 +1,73 @@
From 64c71d7fc28c32ea61bf155bf1503646e4b1bf72 Mon Sep 17 00:00:00 2001
From: squimrel <squimrel@users.noreply.github.com>
Date: Wed, 23 Aug 2017 04:21:14 +0000
Subject: [PATCH] Fix aligned alloc parameters and overflow on 32bit size_t
(cherry picked from commit f802c54f736006566041aeb6a9d741a6d83ce687)
---
libcheckisomd5.c | 3 ++-
libimplantisomd5.c | 3 ++-
utilities.c | 4 ++--
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/libcheckisomd5.c b/libcheckisomd5.c
index b190959..3ec3d88 100644
--- a/libcheckisomd5.c
+++ b/libcheckisomd5.c
@@ -49,6 +49,7 @@ static enum isomd5sum_status checkmd5sum(int isofd, checkCallback cb, void *cbda
return ISOMD5SUM_CHECK_NOT_FOUND;
const off_t total_size = info->isosize - info->skipsectors * SECTOR_SIZE;
+ const off_t fragment_size = total_size / (info->fragmentcount + 1);
if (cb)
cb(cbdata, 0, total_size);
@@ -85,7 +86,7 @@ static enum isomd5sum_status checkmd5sum(int isofd, checkCallback cb, void *cbda
MD5_Update(&hashctx, buffer, (unsigned int) nread);
if (info->fragmentcount) {
- const size_t current_fragment = (size_t)(offset * (off_t)(info->fragmentcount + 1) / total_size);
+ const size_t current_fragment = offset / fragment_size;
const size_t fragmentsize = FRAGMENT_SUM_SIZE / info->fragmentcount;
/* If we're onto the next fragment, calculate the previous sum and check. */
if (current_fragment != previous_fragment) {
diff --git a/libimplantisomd5.c b/libimplantisomd5.c
index 53801c8..47f21d7 100644
--- a/libimplantisomd5.c
+++ b/libimplantisomd5.c
@@ -106,6 +106,7 @@ int implantISOFD(int isofd, int supported, int forceit, int quiet, char **errstr
buffer = aligned_alloc(pagesize, buffer_size * sizeof(*buffer));
const off_t total_size = isosize - SKIPSECTORS * SECTOR_SIZE;
+ const off_t fragment_size = total_size / (FRAGMENT_COUNT + 1);
size_t previous_fragment = 0UL;
off_t offset = 0LL;
while (offset < total_size) {
@@ -115,7 +116,7 @@ int implantISOFD(int isofd, int supported, int forceit, int quiet, char **errstr
break;
MD5_Update(&hashctx, buffer, (unsigned int) nread);
- const size_t current_fragment = (size_t) offset * (FRAGMENT_COUNT + 1) / (size_t) total_size;
+ const size_t current_fragment = offset / fragment_size;
const size_t fragmentsize = FRAGMENT_SUM_SIZE / FRAGMENT_COUNT;
/* If we're onto the next fragment, calculate the previous sum and check. */
if (current_fragment != previous_fragment) {
diff --git a/utilities.c b/utilities.c
index b00337f..cfa84ed 100644
--- a/utilities.c
+++ b/utilities.c
@@ -131,9 +131,9 @@ struct volume_info *const parsepvd(const int isofd) {
buffer[APPDATA_SIZE - 1] = '\0';
struct volume_info *result = malloc(sizeof(struct volume_info));
- result->skipsectors = 20;
+ result->skipsectors = SKIPSECTORS;
result->supported = 0;
- result->fragmentcount = 20;
+ result->fragmentcount = FRAGMENT_COUNT;
result->offset = offset;
result->isosize = isosize(aligned_buffer);
--
2.13.5

View File

@ -1,16 +1,18 @@
Summary: Utilities for working with md5sum implanted in ISO images
Name: isomd5sum
Version: 1.2.3
Release: 9%{?dist}
Version: 1.2.1
Release: 4%{?dist}
Epoch: 1
License: GPLv2+
Group: Applications/System
Url: https://github.com/rhinstaller/isomd5sum
Source0: https://github.com/rhinstaller/%{name}/archive/%{version}.tar.gz
BuildRequires: gcc
Patch0: 0001-Fix-aligned-alloc-parameters-and-overflow-on-32bit-s.patch
BuildRequires: popt-devel
BuildRequires: python3-devel
BuildRequires: python2-devel python3-devel
%description
The isomd5sum package contains utilities for implanting and verifying
@ -18,6 +20,7 @@ an md5sum implanted into an ISO9660 image.
%package devel
Summary: Development headers and library for using isomd5sum
Group: Development/System
Requires: %{name} = %{epoch}:%{version}-%{release}
Provides: %{name}-static = %{epoch}:%{version}-%{release}
@ -25,6 +28,14 @@ Provides: %{name}-static = %{epoch}:%{version}-%{release}
This contains header files and a library for working with the isomd5sum
implanting and checking.
%package -n python-isomd5sum
Summary: Python bindings for isomd5sum
Provides: python2-isomd5sum = %{epoch}:%{version}-%{release}
%description -n python-isomd5sum
The isomd5sum package contains utilities for implanting and verifying
an md5sum implanted into an ISO9660 image.
%package -n python3-isomd5sum
Summary: Python bindings for isomd5sum
@ -36,16 +47,23 @@ an md5sum implanted into an ISO9660 image.
%prep
%autosetup
rm -rf %{py3dir}
cp -a . %{py3dir}
%build
CFLAGS="$RPM_OPT_FLAGS -Wno-strict-aliasing"; export CFLAGS
LDFLAGS="$RPM_LD_FLAGS"; export LDFLAGS
PYTHON=%{__python2} make checkisomd5 implantisomd5 pyisomd5sum.so
pushd %{py3dir}
PYTHON=%{__python3} make checkisomd5 implantisomd5 pyisomd5sum.so
popd
%install
PYTHON=%{__python2} make DESTDIR=$RPM_BUILD_ROOT install-bin install-devel install-python
pushd %{py3dir}
PYTHON=%{__python3} make DESTDIR=$RPM_BUILD_ROOT install-bin install-devel install-python
popd
%files
%license COPYING
@ -56,65 +74,16 @@ PYTHON=%{__python3} make DESTDIR=$RPM_BUILD_ROOT install-bin install-devel insta
%files devel
%{_includedir}/*.h
%{_libdir}/*.a
/usr/share/pkgconfig/isomd5sum.pc
%files -n python-isomd5sum
%{python2_sitearch}/pyisomd5sum.so
%files -n python3-isomd5sum
%{python3_sitearch}/pyisomd5sum.so
%changelog
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 1:1.2.3-9
- Rebuilt for Python 3.9
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.2.3-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 1:1.2.3-7
- Rebuilt for Python 3.8
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.2.3-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.2.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Mon Jan 14 2019 Miro Hrončok <mhroncok@redhat.com> - 1:1.2.3-4
- Subpackage python2-isomd5sum has been removed
See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.2.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 1:1.2.3-2
- Rebuilt for Python 3.7
* Tue Apr 10 2018 Brian C. Lane <bcl@redhat.com> - 1:1.2.3-1
- New Version 1.2.3 (bcl)
- Fix 32bit bug on large files (squimrel)
- Don't put DESTDIR in the isomd5sum.pc file (bcl)
* Fri Feb 23 2018 Florian Weimer <fweimer@redhat.com> - 1:1.2.2-4
- Use LDFLAGS from redhat-rpm-config
* Mon Feb 19 2018 Brian C. Lane <bcl@redhat.com> - 1.2.2-3
- Add gcc BuildRequires for future minimal buildroot support
* Wed Feb 07 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.2.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Tue Oct 03 2017 Brian C. Lane <bcl@redhat.com> - 1:1.2.2-1
- Don't put DESTDIR in the isomd5sum.pc file
- New Version 1.2.2 (bcl)
- Fix aligned alloc parameters and overflow on 32bit size_t (#1497458) (squimrel)
- Fix memory leak (squimrel)
- Add pkgconfig file (squimrel)
- Remove line-breaks from error messages (squimrel)
- Make library C++ compatible (squimrel)
- Constify function signatures (squimrel)
- Revert checkCallback function signature (squimrel)
* Sat Aug 19 2017 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 1:1.2.1-4
- Python 2 binary package renamed to python2-isomd5sum
See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3
* Tue Oct 03 2017 Brian C. Lane <bcl@redhat.com> - 1.2.1-4
- Fix aligned alloc parameters and overflow on 32bit (#1497458)
* Wed Aug 02 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1:1.2.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild

View File

@ -1 +1 @@
SHA512 (1.2.3.tar.gz) = a500faa368377c8fb5dfc311bc3a6dbadd253e6af7928b691d1fc11e25b69819a611f72fa201e70f5df257cdc491c97d1f612bb179fa49de1fb0a638d6ac7972
SHA512 (1.2.1.tar.gz) = 8ad4b3db4a5e1c13445fa7e30f74b594a023410d0b5bc6d018eeaab250b5756bd644f9f72c27841bb9068b3472ae125baa1a2d8b474e0e2ba4177a5c04df66b3