Changeset a21d837 in mainline


Ignore:
Timestamp:
2013-04-01T16:54:02Z (11 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c8830a2
Parents:
66108658
Message:

Explicitly treat the str argument to fat_lfn_str_nlength() as unaligned.

fat_lfn_str_nlength() was defined to take uint16_t * and as such had
reasons to assume natural alignment of the pointed object. This was
however not the case when the function was called from fat_lfn_size()
because the argument there is an address from inside a packed structure.

Location:
uspace/srv/fs/fat
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_dentry.c

    r66108658 ra21d837  
    4444#include <assert.h>
    4545#include <unistd.h>
     46#include <sys/types.h>
    4647
    4748/** Compare path component with the name read from the dentry.
     
    232233/** Get number of bytes in a string with size limit.
    233234 *
    234  * @param str  NULL-terminated (or not) string.
     235 * @param str  NULL-terminated (or not) string. The pointer comes from a packed
     236 *             structure and as such is expected to be unaligned.
    235237 * @param size Maximum number of bytes to consider.
    236238 *
     
    238240 *
    239241 */
    240 size_t fat_lfn_str_nlength(const uint16_t *str, size_t size)
     242size_t fat_lfn_str_nlength(const unaligned_uint16_t *str, size_t size)
    241243{
    242244        size_t offset = 0;
  • uspace/srv/fs/fat/fat_dentry.h

    r66108658 ra21d837  
    3737#include <stdint.h>
    3838#include <stdbool.h>
     39#include <sys/types.h>
    3940
    4041#define IS_D_CHAR(ch) (isalnum(ch) || ch == '_')
     
    132133} __attribute__ ((packed)) fat_dentry_t;
    133134
    134 
    135135extern int fat_dentry_namecmp(char *, const char *);
    136136extern void fat_dentry_name_get(const fat_dentry_t *, char *);
     
    139139extern uint8_t fat_dentry_chksum(uint8_t *);
    140140
    141 extern size_t fat_lfn_str_nlength(const uint16_t *, size_t);
     141extern size_t fat_lfn_str_nlength(const unaligned_uint16_t *, size_t);
    142142extern size_t fat_lfn_size(const fat_dentry_t *);
    143143extern size_t fat_lfn_get_entry(const fat_dentry_t *, uint16_t *, size_t *);
Note: See TracChangeset for help on using the changeset viewer.