Commit a484bcdd authored by Eric Sandeen's avatar Eric Sandeen Committed by Dave Chinner

xfs: don't overflow quota ID when initializing dqblk

Quota IDs are unsigned, and so we can pass in values up
to 2^32-1.  But if we try to initialize a block containing
values over MAX_INT, curid will overflow and assert.

curid holds a quota ID, so give it the proper
xfs_dqid_t type (and remove the now-impossible ASSERT).
Signed-off-by: default avatarEric Sandeen <sandeen@redhat.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 926132c0
...@@ -232,7 +232,8 @@ xfs_qm_init_dquot_blk( ...@@ -232,7 +232,8 @@ xfs_qm_init_dquot_blk(
{ {
struct xfs_quotainfo *q = mp->m_quotainfo; struct xfs_quotainfo *q = mp->m_quotainfo;
xfs_dqblk_t *d; xfs_dqblk_t *d;
int curid, i; xfs_dqid_t curid;
int i;
ASSERT(tp); ASSERT(tp);
ASSERT(xfs_buf_islocked(bp)); ASSERT(xfs_buf_islocked(bp));
...@@ -243,7 +244,6 @@ xfs_qm_init_dquot_blk( ...@@ -243,7 +244,6 @@ xfs_qm_init_dquot_blk(
* ID of the first dquot in the block - id's are zero based. * ID of the first dquot in the block - id's are zero based.
*/ */
curid = id - (id % q->qi_dqperchunk); curid = id - (id % q->qi_dqperchunk);
ASSERT(curid >= 0);
memset(d, 0, BBTOB(q->qi_dqchunklen)); memset(d, 0, BBTOB(q->qi_dqchunklen));
for (i = 0; i < q->qi_dqperchunk; i++, d++, curid++) { for (i = 0; i < q->qi_dqperchunk; i++, d++, curid++) {
d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC); d->dd_diskdq.d_magic = cpu_to_be16(XFS_DQUOT_MAGIC);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment