|
43 | 43 | #include "os-posix.h"
|
44 | 44 | #include "os-shared-filesys.h"
|
45 | 45 | #include "os-shared-idmap.h"
|
| 46 | +#include "os-shared-common.h" |
46 | 47 |
|
47 | 48 | /****************************************************************************************
|
48 | 49 | DEFINES
|
@@ -84,6 +85,8 @@ int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token)
|
84 | 85 | OS_filesys_internal_record_t *local;
|
85 | 86 | struct stat stat_buf;
|
86 | 87 | const char * tmpdir;
|
| 88 | + size_t mplen; |
| 89 | + size_t vollen; |
87 | 90 | uint32 i;
|
88 | 91 | enum
|
89 | 92 | {
|
@@ -168,7 +171,24 @@ int32 OS_FileSysStartVolume_Impl(const OS_object_token_t *token)
|
168 | 171 | return OS_FS_ERR_DRIVE_NOT_CREATED;
|
169 | 172 | }
|
170 | 173 |
|
171 |
| - snprintf(local->system_mountpt, sizeof(local->system_mountpt), "%s/osal:%s", tmpdir, local->volume_name); |
| 174 | + /* |
| 175 | + * Note - performing the concatenation in a single snprintf() call seems |
| 176 | + * to trigger a (false) pointer overlap warning, because volume_name should |
| 177 | + * always be null terminated. To get around this, calculate the |
| 178 | + * string size and check that it is within the expected size, and do the |
| 179 | + * append of volume_name explicitly. |
| 180 | + */ |
| 181 | + mplen = snprintf(local->system_mountpt, sizeof(local->system_mountpt), "%s/osal:", tmpdir); |
| 182 | + if (mplen < sizeof(local->system_mountpt)) |
| 183 | + { |
| 184 | + vollen = OS_strnlen(local->volume_name, sizeof(local->volume_name)); |
| 185 | + if ((vollen + mplen) >= sizeof(local->system_mountpt)) |
| 186 | + { |
| 187 | + vollen = sizeof(local->system_mountpt) - mplen - 1; |
| 188 | + } |
| 189 | + memcpy(&local->system_mountpt[mplen], local->volume_name, vollen); |
| 190 | + local->system_mountpt[mplen + vollen] = 0; |
| 191 | + } |
172 | 192 | }
|
173 | 193 |
|
174 | 194 | return OS_SUCCESS;
|
|
0 commit comments