Exemple #1
0
int
jfs_ValidateFEAList (
	FEALIST		*pfeal,
	ULONG		*poError)
{
    USHORT	cbNeeded = 0;	/* count of storage bytes needed */
    USHORT	cbLeft;		/* count of bytes left in FEA list */
    PFEA	pfea = pfeal->list; /* pointer to current FEA */
    USHORT	cbFEA;		/* count of bytes in current FEA */

    if ((cbLeft = (USHORT) pfeal->cbList - sizeof (pfeal->cbList)) == 0)
	return 0;

    do {
	/* check for our reserved bits
	 */
	if (pfea->fEA & ~(FEA_NEEDEA) || cbLeft < sizeof *pfea)
	    return ERROR_EA_LIST_INCONSISTENT;

	cbFEA = FEA_SIZE (pfea);
	pfea = NEXT_FEA (pfea);

	if (cbLeft < cbFEA)
	{
	    *poError = (((char *) pfea) - ((char *) pfeal));
	    return ERROR_EA_LIST_INCONSISTENT;
	}

    } while ((cbLeft -= cbFEA) > 0);

    return 0;
}
int jfs_ValidateFEAList(struct FEALIST *pfeal, int size, unsigned long *poError)
{
	unsigned int cbLeft;	/* count of bytes left in FEA list */
	struct FEA *pfea = pfeal->list;	/* pointer to current FEA */
	unsigned int cbFEA;	/* count of bytes in current FEA */

	cbLeft = __le32_to_cpu(pfeal->cbList);
	if (size !=  cbLeft)
		return ERROR_EA_LIST_INCONSISTENT;

	cbLeft -= sizeof (pfeal->cbList);

	if (cbLeft == 0)
		return 0;

	do {
		/* check for our reserved bits
		 */
		if (pfea->fEA & ~(FEA_NEEDEA) || cbLeft < sizeof *pfea)
			return ERROR_EA_LIST_INCONSISTENT;

		cbFEA = FEA_SIZE(pfea);
		pfea = NEXT_FEA(pfea);

		if (cbLeft < cbFEA) {
			*poError = (((char *) pfea) - ((char *) pfeal));
			return ERROR_EA_LIST_INCONSISTENT;
		}

	} while ((cbLeft -= cbFEA) > 0);

	return 0;
}