Skip to content

Commit

Permalink
fs/adfs: super: limit idlen according to directory type
Browse files Browse the repository at this point in the history
Limit idlen according to the directory type, as idlen (the size of a
fragment ID) can not be more than 16 with the "new directory" layout.

Signed-off-by: Russell King <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
Russell King authored and Al Viro committed Jun 27, 2019
1 parent 5808b14 commit 8616108
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fs/adfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void adfs_msg(struct super_block *sb, const char *pfx, const char *fmt, ...)

static int adfs_checkdiscrecord(struct adfs_discrecord *dr)
{
unsigned int max_idlen;
int i;

/* sector size must be 256, 512 or 1024 bytes */
Expand All @@ -73,8 +74,13 @@ static int adfs_checkdiscrecord(struct adfs_discrecord *dr)
if (le32_to_cpu(dr->disc_size_high) >> dr->log2secsize)
return 1;

/* idlen must be no greater than 19 v2 [1.0] */
if (dr->idlen > 19)
/*
* Maximum idlen is limited to 16 bits for new directories by
* the three-byte storage of an indirect disc address. For
* big directories, idlen must be no greater than 19 v2 [1.0]
*/
max_idlen = dr->format_version ? 19 : 16;
if (dr->idlen > max_idlen)
return 1;

/* reserved bytes should be zero */
Expand Down

0 comments on commit 8616108

Please sign in to comment.