aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/udf/inode.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 8d0b3ade0ff0..566df9b5a6cb 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -2047,14 +2047,29 @@ void udf_write_aext(struct inode *inode, struct extent_position *epos,
2047 epos->offset += adsize; 2047 epos->offset += adsize;
2048} 2048}
2049 2049
2050/*
2051 * Only 1 indirect extent in a row really makes sense but allow upto 16 in case
2052 * someone does some weird stuff.
2053 */
2054#define UDF_MAX_INDIR_EXTS 16
2055
2050int8_t udf_next_aext(struct inode *inode, struct extent_position *epos, 2056int8_t udf_next_aext(struct inode *inode, struct extent_position *epos,
2051 struct kernel_lb_addr *eloc, uint32_t *elen, int inc) 2057 struct kernel_lb_addr *eloc, uint32_t *elen, int inc)
2052{ 2058{
2053 int8_t etype; 2059 int8_t etype;
2060 unsigned int indirections = 0;
2054 2061
2055 while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) == 2062 while ((etype = udf_current_aext(inode, epos, eloc, elen, inc)) ==
2056 (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { 2063 (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) {
2057 int block; 2064 int block;
2065
2066 if (++indirections > UDF_MAX_INDIR_EXTS) {
2067 udf_err(inode->i_sb,
2068 "too many indirect extents in inode %lu\n",
2069 inode->i_ino);
2070 return -1;
2071 }
2072
2058 epos->block = *eloc; 2073 epos->block = *eloc;
2059 epos->offset = sizeof(struct allocExtDesc); 2074 epos->offset = sizeof(struct allocExtDesc);
2060 brelse(epos->bh); 2075 brelse(epos->bh);