From aed1deba584ead039d51d1fe09ccab3123304c59 Mon Sep 17 00:00:00 2001 From: jkar8572 Date: Thu, 17 Mar 2005 11:14:34 +0000 Subject: Fixed illegal reference checking in quotacheck(8) (Jan Kara) Fix of fix of sanity check in repquota(8) (Jan Kara) --- quotaio_v2.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'quotaio_v2.c') diff --git a/quotaio_v2.c b/quotaio_v2.c index 6ba7225..5176435 100644 --- a/quotaio_v2.c +++ b/quotaio_v2.c @@ -748,6 +748,12 @@ static int report_block(struct dquot *dquot, uint blk, char *bitmap, return entries; } +static void check_reference(struct quota_handle *h, uint blk) +{ + if (blk >= h->qh_info.u.v2_mdqi.dqi_blocks) + die(2, _("Illegal reference in %s quota file on %s. Quota file is probably corrupted.\nPlease run quotacheck(8) and try again.\n"), type2name(h->qh_type), h->qh_quotadev); +} + static int report_tree(struct dquot *dquot, uint blk, int depth, char *bitmap, int (*process_dquot) (struct dquot *, char *)) { @@ -759,17 +765,18 @@ static int report_tree(struct dquot *dquot, uint blk, int depth, char *bitmap, if (depth == V2_DQTREEDEPTH - 1) { for (i = 0; i < V2_DQBLKSIZE >> 2; i++) { blk = __le32_to_cpu(ref[i]); - if (blk >= dquot->dq_h->qh_info.u.v2_mdqi.dqi_blocks) - die(2, _("Illegal reference in %s quota file on %s. Quota file is probably corrupted.\nPlease run quotacheck(8) and try again.\n"), type2name(dquot->dq_h->qh_type), dquot->dq_h->qh_quotadev); + check_reference(dquot->dq_h, blk); if (blk && !get_bit(bitmap, blk)) entries += report_block(dquot, blk, bitmap, process_dquot); } } else { for (i = 0; i < V2_DQBLKSIZE >> 2; i++) - if ((blk = __le32_to_cpu(ref[i]))) + if ((blk = __le32_to_cpu(ref[i]))) { + check_reference(dquot->dq_h, blk); entries += report_tree(dquot, blk, depth + 1, bitmap, process_dquot); + } } freedqbuf(buf); return entries; -- cgit v1.2.3