Allow zero size lengths

This commit is contained in:
Martin Tůma 2025-01-07 09:16:55 +01:00
parent 57af4fca5b
commit 00c52d5ab7

View File

@ -48,7 +48,7 @@ static bool length(CTX &ctx, qint32 &val)
if (!varint(ctx, val)) if (!varint(ctx, val))
return false; return false;
return (val > 0); return (val >= 0);
} }
static bool str(CTX &ctx, QByteArray &val) static bool str(CTX &ctx, QByteArray &val)
@ -98,7 +98,7 @@ static bool packed(CTX &ctx, QVector<quint32> &vals)
if (TYPE(ctx.tag) == LEN) { if (TYPE(ctx.tag) == LEN) {
qint32 len; qint32 len;
if (!varint(ctx, len) || len <= 0) if (!varint(ctx, len) || len < 0)
return false; return false;
const char *ee = ctx.bp + len; const char *ee = ctx.bp + len;
if (ee > ctx.be) if (ee > ctx.be)
@ -129,7 +129,7 @@ static bool skip(CTX &ctx)
len = 8; len = 8;
break; break;
case LEN: case LEN:
if (!varint(ctx, len) || len <= 0) if (!varint(ctx, len) || len < 0)
return false; return false;
break; break;
case I32: case I32: