From bde7e18ea04d8cb458e2961193925c0063f04fd9 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 20 Nov 2000 13:29:21 +0000 Subject: 2000-11-20 Dmitry Kargapolov * libc/mount.c: Make sure there is space allocated for a device name in the mount table entry. --- cpukit/libcsupport/src/mount.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'cpukit/libcsupport/src') diff --git a/cpukit/libcsupport/src/mount.c b/cpukit/libcsupport/src/mount.c index 6b5471422e..7e39357285 100644 --- a/cpukit/libcsupport/src/mount.c +++ b/cpukit/libcsupport/src/mount.c @@ -74,6 +74,7 @@ int mount( rtems_filesystem_location_info_t loc; rtems_filesystem_mount_table_entry_t *temp_mt_entry; rtems_filesystem_location_info_t *loc_to_free = NULL; + size_t size; /* XXX add code to check for required operations */ @@ -100,7 +101,10 @@ int mount( * Allocate a mount table entry */ - temp_mt_entry = malloc( sizeof(rtems_filesystem_mount_table_entry_t) ); + size = sizeof(rtems_filesystem_mount_table_entry_t); + if ( device ) + size += strlen( device ) + 1; + temp_mt_entry = malloc( size ); if ( !temp_mt_entry ) { errno = ENOMEM; @@ -109,9 +113,11 @@ int mount( temp_mt_entry->mt_fs_root.mt_entry = temp_mt_entry; temp_mt_entry->options = options; - if ( device ) + if ( device ) { + temp_mt_entry->dev = + (char *)temp_mt_entry + sizeof( rtems_filesystem_mount_table_entry_t ); strcpy( temp_mt_entry->dev, device ); - else + } else temp_mt_entry->dev = 0; /* -- cgit v1.2.3