Hacking Possible fix for the WBFS corruption

  • Thread starter Thread starter AllWiidUp
  • Start date Start date
  • Views Views 29,049
  • Replies Replies 49

AllWiidUp

Well-Known Member
Newcomer
Joined
Dec 17, 2008
Messages
84
Reaction score
0
Trophies
1
XP
41
Country
Canada
Looking at the WBFS alloc and free functions I noticed an off by 1 error, that likely frees the wrong block.

in libwbfs.c:

CODE--- a/libwbfs.cÂÂ 2009-03-31 18:26:00.000000000 -0700
+++ b/libwbfs.cÂÂÂÂ 2009-04-12 12:28:23.516024000 -0700
@@ -389,8 +389,8 @@
}
static void free_block(wbfs_t *p,int bl)
{
-ÂÂÂÂÂÂÂÂint i = bl/(32);
-ÂÂÂÂÂÂÂÂint j = bl&31;
+ÂÂÂÂÂÂÂÂint i = (bl-1)/(32);
+ÂÂÂÂÂÂÂÂint j = (bl-1)&31;
ÂÂÂÂÂÂÂÂ u32 v = wbfs_ntohl(p->freeblks);
ÂÂÂÂÂÂÂÂ p->freeblks = wbfs_htonl(v | 1freeblks);
ÂÂÂÂÂÂÂÂp->freeblks = wbfs_htonl(v | 1wlba_table); // bl = info->wlba_table
ÂÂÂÂÂÂÂÂÂÂif (iwlba)
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂfree_block(p,iwlba); // should have beenÂÂfree_block(p,iwlba - 1);[/code]
but since "alloc_block" adds the +1 then "free_block" should have the -1, otherwise someone else might introduce the bug again, if the use free_block in another place since both block functions are used for "wlba_table".



EDIT:
WiiNinja compiled and tested a windows version with the fix and all it well ;P
WBFS.Windows.with.free.space.fix

now supported in WBFuse

Managers with Support:
WBFS Manager 2.2


Loaders with support:
KongsNutz Loader
Waninkoko v1.4
 
Mark McDonut said:
you should contact qwiirk or waninkoko, you really may be on to something.


I don't know Kwiirk's contact info and since he did up this version, I thought I'd put it out there in case he could see.
 
He's on Wiibrew
smile.gif
 
So in what manner would this possibly fix the corruption? Would it cause a game to move the other games out of the way instead of overwriting them or something?
 
Can someone confirm this fix - this would be the best Loader out there ... a Loader with no corruption in the file system ! 8)
 
From what I gather this has to do with the wbfs filesystem itself and not any loader application, but correct me if I'm wrong.
 
Its the libwbfs ... so its part of something when compiled ... so the usb loader has this code in it i guess ...
also the wbfs tools ...
 
It would be a great find if its the fix - its been bugging everyone and makes the format seem a little unstable for most.
well done AllWiidup
 
That's awesome!!!
smile.gif
.Good work! Have you maybe also found the bug why games can't be dumped by the Wii to a Partition over 512GB
tongue.gif
? That would be also awesome
wink.gif
.
 
You're completely right. It frees an incorrect block (we don't free the first block of the game, but we free the first block next to the last block of the game).
 
QUOTE said:
You're completely right. It frees an incorrect block (we don't free the first block of the game, but we free the first block next to the last block of the game).

Finally, the bug is found. Thanks AllWiidup.
 
waninkoko said:
You're completely right. It frees an incorrect block (we don't free the first block of the game, but we free the first block next to the last block of the game).

So... i see... i'm sure u and kwiirk will fix this very soon... CIOS11 is on it's way.
wink.gif

U guys are great!
 
QUOTE said:
yeah, and? I thougth it's a problem of libwbfs and not the loader...

THe loader contains wbfs code for adding/deleting ISOs.

Version 1.3 does not fix this problem. I suspect 1.4.
 

Site & Scene News

Popular threads in this forum