if (!(c & 128))
{
x = (x << 7) | c;
- if (max && x >= max)
+ if (max && x >= (unsigned int)max)
{
data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "read_id: id too large (%u/%u)", x, max);
return 0;
continue;
}
x = (x << 6) | (c & 63);
- if (max && x >= max)
+ if (max && x >= (unsigned int)max)
{
data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "read_idarray: id too large (%u/%u)", x, max);
return 0;
continue;
}
x = (x << 6) | (c & 63);
- if (max && x >= max)
+ if (max && x >= (unsigned int)max)
{
data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_idarray: id too large (%u/%u)", x, max);
data->error = SOLV_ERROR_ID_RANGE;
}
x = old + (x - 1);
old = x;
- if (max && x >= max)
+ if (max && x >= (unsigned int)max)
{
data->error = pool_error(data->repo->pool, SOLV_ERROR_ID_RANGE, "data_read_rel_idarray: id too large (%u/%u)", x, max);
break;
static void
incore_add_blob(Repodata *data, unsigned char *buf, int len)
{
- if (data->incoredatafree < len)
+ if (data->incoredatafree < (unsigned int)len)
{
data->incoredata = solv_realloc(data->incoredata, data->incoredatalen + INCORE_ADD_CHUNK + len);
data->incoredatafree = INCORE_ADD_CHUNK + len;
{
Pool *pool = repo->pool;
int i, l;
- unsigned int numid, numrel, numdir, numsolv;
- unsigned int numkeys, numschemata;
+ int numid, numrel, numdir, numsolv;
+ int numkeys, numschemata;
Offset sizeid;
Offset *str; /* map Id -> Offset into string space */
return pool_error(pool, SOLV_ERROR_UNSUPPORTED, "unsupported SOLV version");
}
- numid = read_u32(&data);
- numrel = read_u32(&data);
- numdir = read_u32(&data);
- numsolv = read_u32(&data);
- numkeys = read_u32(&data);
- numschemata = read_u32(&data);
+ numid = (int)read_u32(&data);
+ numrel = (int)read_u32(&data);
+ numdir = (int)read_u32(&data);
+ numsolv = (int)read_u32(&data);
+ numkeys = (int)read_u32(&data);
+ numschemata = (int)read_u32(&data);
solvflags = read_u32(&data);
- if (numdir && numdir < 2)
+ if (numid < 0 || numid >= 0x20000000)
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of ids");
+ if (numrel < 0 || numrel >= 0x20000000)
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of rels");
+ if (numdir && (numdir < 2 || numdir >= 0x20000000))
return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of dirs");
+ if (numsolv < 0 || numsolv >= 0x20000000)
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of solvables");
+ if (numkeys < 0 || numkeys >= 0x20000000)
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of keys");
+ if (numschemata < 0 || numschemata >= 0x20000000)
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "bad number of schematas");
if (numrel && (flags & REPO_LOCALPOOL) != 0)
return pool_error(pool, SOLV_ERROR_CORRUPT, "relations are forbidden in a local pool");
/* remove unused keys */
keyused = solv_calloc(target.nkeys, sizeof(Id));
- for (i = 1; i < target.schemadatalen; i++)
+ for (i = 1; i < (int)target.schemadatalen; i++)
keyused[target.schemadata[i]] = 1;
keyused[0] = 0;
for (n = i = 1; i < target.nkeys; i++)
queue_truncate(keyq, 2 * n - 2);
/* update schema data to the new key ids */
- for (i = 1; i < target.schemadatalen; i++)
+ for (i = 1; i < (int)target.schemadatalen; i++)
target.schemadata[i] = keyused[target.schemadata[i]];
/* update keymap to the new key ids */
for (i = 0; i < cbdata.nkeymap; i++)
if (off >= data->lastverticaloffset)
{
off -= data->lastverticaloffset;
- if (off + len > data->vincorelen)
+ if ((unsigned int)off + len > data->vincorelen)
return 0;
return data->vincore + off;
}
- if (off + len > key->size)
+ if ((unsigned int)off + len > key->size)
return 0;
/* we now have the offset, go into vertical */
off += data->verticaloffset[key - data->keys];
case REPOKEY_TYPE_STR:
case REPOKEY_TYPE_BINARY:
case_CHKSUM_TYPES:
- if (attrs[1] < attrdatastart)
+ if ((unsigned int)attrs[1] < attrdatastart)
attrdatastart = attrs[1];
break;
case REPOKEY_TYPE_DIRSTRARRAY:
/* FALLTHROUGH */
case REPOKEY_TYPE_IDARRAY:
case REPOKEY_TYPE_DIRNUMNUMARRAY:
- if (attrs[1] < attriddatastart)
+ if ((unsigned int)attrs[1] < attriddatastart)
attriddatastart = attrs[1];
break;
case REPOKEY_TYPE_FIXARRAY: