[libfat] FAT_setAttr dsi exception

Post Reply
Oibaf
Posts: 34
Joined: Mon Jul 04, 2011 1:03 pm

[libfat] FAT_setAttr dsi exception

Post by Oibaf » Sun Jan 11, 2015 7:21 pm

The instruction FAT_setAttr gives "dsi exeption" in all the last versions (1.10.11-13) of libfat.

This is due to a bug in FAT_setAttr (fatfile.c): a NULL pointer is passed to _FAT_directory_entryFromPath which expects a pointer to a variable.

Moreover there is another bug. The code does take into account the endianess of powerPC and therefore the attr variable is always passed with a 0 value.

This code solves both the issues (NEW indicates the new lines).

int FAT_setAttr(const char *file, int attr) {

// Defines...
DIR_ENTRY_POSITION entryEnd;
PARTITION *partition = NULL;
DIR_ENTRY* dirEntry = NULL;

DIR_ENTRY dirEntry_variable; //NEW
char attr_byte; //NEW

dirEntry =&dirEntry_variable; //NEW
attr_byte= (char) attr; //NEW
...

// Write Data
_FAT_cache_writePartialSector (
partition->cache // Cache to write
, &attr_byte // Value to be written ----> NEW
, _FAT_fat_clusterToSector( partition , entryEnd.cluster ) + entryEnd.sector // cluster
, entryEnd.offset * DIR_ENTRY_DATA_SIZE + DIR_ENTRY_attributes // offset
, 1 // Size in bytes
);

Oibaf
Posts: 34
Joined: Mon Jul 04, 2011 1:03 pm

Re: [libfat] FAT_setAttr dsi exception

Post by Oibaf » Wed Jan 14, 2015 1:10 pm

The issue was fixed by Wintermute with 2 patches

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests