fix sz < 0

This commit is contained in:
shixuantong 2022-05-07 16:09:49 +08:00
parent 4fc28b25d3
commit 6f59ae3421
2 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,6 @@
Name: libtar Name: libtar
Version: 1.2.20 Version: 1.2.20
Release: 21 Release: 22
Summary: Library for manipulating tar files from within C programs. Summary: Library for manipulating tar files from within C programs.
License: BSD License: BSD
URL: http://repo.or.cz/libtar.git URL: http://repo.or.cz/libtar.git
@ -71,6 +71,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la
%{_mandir}/man3/*.3* %{_mandir}/man3/*.3*
%changelog %changelog
* Sat May 07 2022 shixuantong <shixuantong@h-partners.com> - 1.2.20-22
- fix sz < 0
* Wed Apr 06 2022 shixuantong <shixuantong@h-partners.com> - 1.2.20-21 * Wed Apr 06 2022 shixuantong <shixuantong@h-partners.com> - 1.2.20-21
- Ensure that sz is greater than 0. - Ensure that sz is greater than 0.

View File

@ -15,11 +15,11 @@ index 092bc28..80b41ac 100644
if (TH_ISLONGLINK(t)) if (TH_ISLONGLINK(t))
{ {
sz = th_get_size(t); sz = th_get_size(t);
+ if (sz <= 0) + if ((int)sz <= 0)
+ { + {
+ errno = EINVAL; + errno = EINVAL;
+ return -1; + return -1;
+ } + }
blocks = (sz / T_BLOCKSIZE) + (sz % T_BLOCKSIZE ? 1 : 0); blocks = (sz / T_BLOCKSIZE) + (sz % T_BLOCKSIZE ? 1 : 0);
if (blocks > ((size_t)-1 / T_BLOCKSIZE)) if (blocks > ((size_t)-1 / T_BLOCKSIZE))
{ {
@ -27,11 +27,11 @@ index 092bc28..80b41ac 100644
if (TH_ISLONGNAME(t)) if (TH_ISLONGNAME(t))
{ {
sz = th_get_size(t); sz = th_get_size(t);
+ if (sz <= 0) + if ((int)sz <= 0)
+ { + {
+ errno = EINVAL; + errno = EINVAL;
+ return -1; + return -1;
+ } + }
blocks = (sz / T_BLOCKSIZE) + (sz % T_BLOCKSIZE ? 1 : 0); blocks = (sz / T_BLOCKSIZE) + (sz % T_BLOCKSIZE ? 1 : 0);
if (blocks > ((size_t)-1 / T_BLOCKSIZE)) if (blocks > ((size_t)-1 / T_BLOCKSIZE))
{ {