!13 fix sz < 0

From: @tong_1001 
Reviewed-by: @xiezhipeng1 
Signed-off-by: @xiezhipeng1
This commit is contained in:
openeuler-ci-bot 2022-05-07 08:26:50 +00:00 committed by Gitee
commit 44ea9f4305
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 14 additions and 11 deletions

View File

@ -1,6 +1,6 @@
Name: libtar
Version: 1.2.20
Release: 21
Release: 22
Summary: Library for manipulating tar files from within C programs.
License: BSD
URL: http://repo.or.cz/libtar.git
@ -71,6 +71,9 @@ rm $RPM_BUILD_ROOT%{_libdir}/*.la
%{_mandir}/man3/*.3*
%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
- Ensure that sz is greater than 0.

View File

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