Re: [PATCH] hfs: Sanity check the root record
From: Leo Stone
Date: Tue Nov 26 2024 - 12:22:01 EST
Hello,
On Tue, Nov 26, 2024 at 10:33:13AM +0100, Jan Kara wrote:
>
> This certainly won't hurt but shouldn't we also add some stricter checks
> for entry length so that we know we've loaded enough data to have full info
> about the root dir?
Yes, that would be a good idea. Do we want to keep the existing checks
and just make sure we have at least enough to initialize the struct:
if (fd.entrylength > sizeof(rec) || fd.entrylength < 0 ||
fd.entrylength < sizeof(rec.dir)) {
res = -EIO;
goto bail_hfs_find;
}
Or be even stricter and only accept the exact length:
if (fd.entrylength != sizeof(rec.dir)) {
res = -EIO;
goto bail_hfs_find;
}
Thanks for your feedback,
Leo