Fiddling with IPStack
[tpg/acess2.git] / Modules / Filesystems / Ext2 / ext2.c
index ac3d7e5..52793d0 100644 (file)
@@ -73,7 +73,8 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options)
        \r
        // Sanity Check Magic value\r
        if(sb.s_magic != 0xEF53) {\r
-               Log_Warning("EXT2", "Volume '%s' is not an EXT2 volume", Device);\r
+               Log_Warning("EXT2", "Volume '%s' is not an EXT2 volume (0x%x != 0xEF53)",\r
+                       Device, sb.s_magic);\r
                VFS_Close(fd);\r
                LEAVE('n');\r
                return NULL;\r
@@ -320,15 +321,17 @@ void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk)
        if(ngrp <= 1)   return;\r
        VFS_WriteAt(Disk->FD, 1*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
        \r
+       #define INT_MAX (((long long int)1<<(sizeof(int)*8))-1)\r
+       \r
        // Powers of 3\r
-       for( i = 3; i < ngrp; i *= 3 )\r
+       for( i = 3; i < ngrp && i < INT_MAX/3; i *= 3 )\r
                VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
        \r
        // Powers of 5\r
-       for( i = 5; i < ngrp; i *= 5 )\r
+       for( i = 5; i < ngrp && i < INT_MAX/5; i *= 5 )\r
                VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
        \r
        // Powers of 7\r
-       for( i = 7; i < ngrp; i *= 7 )\r
+       for( i = 7; i < ngrp && i < INT_MAX/7; i *= 7 )\r
                VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock);\r
 }\r

UCC git Repository :: git.ucc.asn.au