X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Modules%2FFilesystems%2FExt2%2Fext2.c;h=52793d0179c695d47b6272cfc55202af17efc262;hb=f429a25f24ffd4762d59bee5f7122ac06881f3ca;hp=ac3d7e5c5fed14d7c216b09ed9c964d95458d567;hpb=351dd3b194833c923bad0292e9019320fb2a41fa;p=tpg%2Facess2.git diff --git a/Modules/Filesystems/Ext2/ext2.c b/Modules/Filesystems/Ext2/ext2.c index ac3d7e5c..52793d01 100644 --- a/Modules/Filesystems/Ext2/ext2.c +++ b/Modules/Filesystems/Ext2/ext2.c @@ -73,7 +73,8 @@ tVFS_Node *Ext2_InitDevice(char *Device, char **Options) // Sanity Check Magic value if(sb.s_magic != 0xEF53) { - Log_Warning("EXT2", "Volume '%s' is not an EXT2 volume", Device); + Log_Warning("EXT2", "Volume '%s' is not an EXT2 volume (0x%x != 0xEF53)", + Device, sb.s_magic); VFS_Close(fd); LEAVE('n'); return NULL; @@ -320,15 +321,17 @@ void Ext2_int_UpdateSuperblock(tExt2_Disk *Disk) if(ngrp <= 1) return; VFS_WriteAt(Disk->FD, 1*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock); + #define INT_MAX (((long long int)1<<(sizeof(int)*8))-1) + // Powers of 3 - for( i = 3; i < ngrp; i *= 3 ) + for( i = 3; i < ngrp && i < INT_MAX/3; i *= 3 ) VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock); // Powers of 5 - for( i = 5; i < ngrp; i *= 5 ) + for( i = 5; i < ngrp && i < INT_MAX/5; i *= 5 ) VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock); // Powers of 7 - for( i = 7; i < ngrp; i *= 7 ) + for( i = 7; i < ngrp && i < INT_MAX/7; i *= 7 ) VFS_WriteAt(Disk->FD, i*bpg*Disk->BlockSize, 1024, &Disk->SuperBlock); }