@@ -1368,13 +1368,22 @@ char * adfEntryGetInfo( const struct AdfEntry * const entry )
13681368
13691369
13701370/*
1371- * adfDirCheck
1371+ * adfDirCheckLimited
13721372 *
13731373 */
1374- unsigned adfDirCheck ( const struct AdfVolume * const vol ,
1375- const ADF_SECTNUM nSect ,
1376- const bool recurs )
1374+ static unsigned adfDirCheckLimited ( const struct AdfVolume * const vol ,
1375+ const ADF_SECTNUM nSect ,
1376+ const bool recurs ,
1377+ const unsigned level )
13771378{
1379+ if ( level > ADF_DIR_MAX_LEVELS ) {
1380+ adfEnv .eFct ( "%s: Too many levels (>%u), check the volume's filesystem for "
1381+ "errors (possible invalid linking between internal data structures). "
1382+ "This also means 'path too long' on AmigaOS (max. 256 characters!)." ,
1383+ __func__ , ADF_DIR_MAX_LEVELS );
1384+ return 1 ;
1385+ }
1386+
13781387 struct AdfEntryBlock parent , entryBlk ;
13791388
13801389 if ( adfReadEntryBlock ( vol , nSect , & parent ) != ADF_RC_OK ||
@@ -1398,7 +1407,8 @@ unsigned adfDirCheck( const struct AdfVolume * const vol,
13981407 nErrors ++ ;
13991408
14001409 if ( recurs && entry -> type == ADF_ST_DIR )
1401- nErrors += adfDirCheck ( vol , entry -> sector , true );
1410+ nErrors += adfDirCheckLimited ( vol , entry -> sector , true,
1411+ level + 1 );
14021412
14031413 if ( entryBlk .nextSameHash == 0 ) {
14041414 adfFreeEntry ( entry );
@@ -1468,3 +1478,15 @@ unsigned adfDirCheck( const struct AdfVolume * const vol,
14681478
14691479 return nErrors ;
14701480}
1481+
1482+
1483+ /*
1484+ * adfDirCheck
1485+ *
1486+ */
1487+ unsigned adfDirCheck ( const struct AdfVolume * const vol ,
1488+ const ADF_SECTNUM nSect ,
1489+ const bool recurs )
1490+ {
1491+ return adfDirCheckLimited ( vol , nSect , recurs , 0 );
1492+ }
0 commit comments