Tag data must have count greater than zero

Zero counts are invalid, and they cause problems elsewhere.  For
instance, strtaglen() will suffer an integer underflow.
This commit is contained in:
Demi Marie Obenour 2021-01-13 15:54:17 -05:00 committed by Panu Matilainen
parent 11f7c13e15
commit 5e40166380
1 changed files with 9 additions and 0 deletions

View File

@ -128,6 +128,13 @@ static const size_t headerMaxbytes = (256*1024*1024);
**/
#define hdrchkTag(_tag) ((_tag) < HEADER_I18NTABLE)
/**
* Reasonableness check on count values.
* Catches nasty stuff like negative or zero counts, which would cause
* integer underflows in strtaglen().
*/
#define hdrchkCount(_count) ((_count) == 0)
/**
* Sanity check on type values.
*/
@ -279,6 +286,8 @@ static rpmRC hdrblobVerifyInfo(hdrblob blob, char **emsg)
goto err;
if (hdrchkType(info.type))
goto err;
if (hdrchkCount(info.count))
goto err;
if (hdrchkAlign(info.type, info.offset))
goto err;
if (hdrchkRange(blob->dl, info.offset))