Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #435, fix string manipulations to avoid warnings #441

Merged
merged 2 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/os/shared/inc/os-shared-filesys.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ typedef struct
typedef struct
{
char device_name[OS_MAX_API_NAME]; /**< The name of the underlying block device, if applicable */
char volume_name[OS_MAX_API_NAME];
char system_mountpt[OS_MAX_PATH_LEN]; /**< The name/prefix where the contents are accessible in the host operating system */
char volume_name[OS_FS_VOL_NAME_LEN];
char system_mountpt[OS_MAX_LOCAL_PATH_LEN]; /**< The name/prefix where the contents are accessible in the host operating system */
char virtual_mountpt[OS_MAX_PATH_LEN]; /**< The name/prefix in the OSAL Virtual File system exposed to applications */
char *address;
uint32 blocksize;
Expand Down
11 changes: 7 additions & 4 deletions src/os/shared/src/osapi-filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,21 @@ int32 OS_FileSys_InitLocalFromVolTable(OS_filesys_internal_record_t *local, cons
strcmp(Vol->DeviceName,"unused") != 0)
{
strncpy(local->volume_name, Vol->VolumeName, sizeof(local->volume_name)-1);
local->volume_name[sizeof(local->volume_name)-1] = 0;
}

if (isgraph((int)Vol->PhysDevName[0]) &&
strcmp(Vol->PhysDevName,"unused") != 0)
{
strncpy(local->system_mountpt, Vol->PhysDevName, sizeof(local->system_mountpt)-1);
local->system_mountpt[sizeof(local->system_mountpt)-1] = 0;
}

if (isgraph((int)Vol->MountPoint[0]) &&
strcmp(Vol->MountPoint,"unused") != 0)
{
strncpy(local->virtual_mountpt, Vol->MountPoint, sizeof(local->virtual_mountpt)-1);
local->virtual_mountpt[sizeof(local->virtual_mountpt)-1] = 0;
}

/*
Expand Down Expand Up @@ -471,10 +474,10 @@ int32 OS_FileSysAddFixedMap(uint32 *filesys_id, const char *phys_path, const cha

memset(local, 0, sizeof(*local));
global->name_entry = local->device_name;
strcpy(local->device_name, dev_name);
strcpy(local->volume_name, dev_name);
strcpy(local->system_mountpt, phys_path);
strcpy(local->virtual_mountpt, virt_path);
strncpy(local->device_name, dev_name, sizeof(local->device_name)-1);
strncpy(local->volume_name, dev_name, sizeof(local->volume_name)-1);
strncpy(local->system_mountpt, phys_path, sizeof(local->system_mountpt)-1);
strncpy(local->virtual_mountpt, virt_path, sizeof(local->virtual_mountpt)-1);

/*
* mark the entry that it is a fixed disk
Expand Down
2 changes: 1 addition & 1 deletion src/unit-tests/inc/ut_os_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static inline bool UtOsalImplemented(int32 Fn, const char *File, uint32 Line)
/*--------------------------------------------------------------------------------*/

#define UT_os_sprintf(buf,...) \
snprintf(buf,sizeof(buf),__VA_ARGS__)
do { int x = snprintf(buf,sizeof(buf),__VA_ARGS__); if (x > 0 && x < sizeof(buf)) buf[x] = 0; } while (0)

/*--------------------------------------------------------------------------------*/

Expand Down