Menu

#7 Minor Bug In Access Flags

open
nobody
None
5
2016-05-27
2016-05-27
PeterDMC
No

uffs_fd.h defines several macros with decimal literals where hexidecimal literals were probably intended.

#define US_IREAD    0000400 /* read permission */
#define US_IWRITE   0000200 /* write permission */

#define US_IRWXU    00700   /* RWX  owner */
#define US_IRUSR    00400   /* R    owner */
#define US_IWUSR    00200   /* W    owner */
#define US_IXUSR    00100   /* X    owner */
#define US_IRWXG    00070   /* RWX  group */
#define US_IRGRP    00040   /* R    group */
#define US_IWGRP    00020   /* W    group */
#define US_IXGRP    00010   /* X    group */
#define US_IRWXO    00007   /* RWX  other */
#define US_IROTH    00004   /* R    other */
#define US_IWOTH    00002   /* W    other */
#define US_IXOTH    00001   /* X    other */

was likely intended to be:

#define US_IREAD    0x0400  /* read permission */
#define US_IWRITE   0x0200  /* write permission */

#define US_IRWXU    0x0700  /* RWX  owner */
#define US_IRUSR    0x0400  /* R    owner */
#define US_IWUSR    0x0200  /* W    owner */
#define US_IXUSR    0x0100  /* X    owner */
#define US_IRWXG    0x0070  /* RWX  group */
#define US_IRGRP    0x0040  /* R    group */
#define US_IWGRP    0x0020  /* W    group */
#define US_IXGRP    0x0010  /* X    group */
#define US_IRWXO    0x0007  /* RWX  other */
#define US_IROTH    0x0004  /* R    other */
#define US_IWOTH    0x0002  /* W    other */
#define US_IXOTH    0x0001  /* X    other */

As far as I can tell US_IRWXU is the only one of these constants that is used (uffs_fd.c line 454).

        buf->st_mode = (info.info.attr & FILE_ATTR_DIR ? US_IFDIR : US_IFREG);
        if (info.info.attr & FILE_ATTR_WRITE)
            buf->st_mode |= US_IRWXU;

Since the incorrect value for US_IRWXU doesn't affect the US_IFDIR or US_IFREG flags. No real harm is done, but it's probably worth fixing anyhow.

Discussion


Log in to post a comment.