Skip to content

Commit

Permalink
[vdisk] Treat 8.3 filename as a single 11-byte array
Browse files Browse the repository at this point in the history
Eliminate complaints from Coverity by explicitly declaring the 8.3
filename as an 11-byte array (rather than an 8-byte array followed by
a 3-byte array).

Signed-off-by: Michael Brown <mbrown@fensystems.co.uk>
  • Loading branch information
mcb30 committed May 10, 2017
1 parent 7f42b27 commit bb21155
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
8 changes: 3 additions & 5 deletions src/vdisk.c
Expand Up @@ -197,18 +197,16 @@ vdisk_directory_entry ( union vdisk_directory_entry *dirent, const char *name,
unsigned int i;

/* Populate directory entry (with invalid 8.3 filename) */
memset ( dos->dos.filename, ' ', sizeof ( dos->dos.filename ) );
memset ( dos->dos.extension, ' ', sizeof ( dos->dos.extension ) );
memset ( dos->dos.filename.raw, ' ', sizeof ( dos->dos.filename.raw ) );
dos->dos.attr = attr;
dos->dos.size = len;
dos->dos.cluster_high = ( cluster >> 16 );
dos->dos.cluster_low = ( cluster & 0xffff );

/* Calculate checksum of 8.3 filename */
checksum = 0;
checksum_data = ( ( uint8_t * ) dos->dos.filename );
for ( i = 0 ; i < ( sizeof ( dos->dos.filename ) +
sizeof ( dos->dos.extension ) ) ; i++ ) {
checksum_data = dos->dos.filename.raw;
for ( i = 0 ; i < sizeof ( dos->dos.filename.raw ) ; i++ ) {
checksum = ( ( ( ( checksum & 1 ) << 7 ) |
( checksum >> 1 ) ) +
*(checksum_data++) );
Expand Down
14 changes: 11 additions & 3 deletions src/vdisk.h
Expand Up @@ -361,9 +361,17 @@ struct vdisk_fsinfo {
/** An 8.3 filename record */
struct vdisk_short_filename {
/** Filename */
char filename[8];
/** Extension */
char extension[3];
union {
/** Structured 8.3 base name and extension */
struct {
/** Base name */
char base[8];
/** Extension */
char ext[3];
} __attribute__ (( packed ));
/** Raw bytes */
uint8_t raw[11];
} filename;
/** Attributes */
uint8_t attr;
/** Reserved */
Expand Down

0 comments on commit bb21155

Please sign in to comment.