| 204 | ****************************************************************************/ |
| 205 | |
| 206 | static void rpmsgfs_mkpath(FAR struct rpmsgfs_mountpt_s *fs, |
| 207 | FAR const char *relpath, |
| 208 | FAR char *path, int pathlen) |
| 209 | { |
| 210 | int depth = 0; |
| 211 | int first; |
| 212 | int x; |
| 213 | |
| 214 | /* Copy base host path to output */ |
| 215 | |
| 216 | strlcpy(path, fs->fs_root, pathlen); |
| 217 | |
| 218 | /* Be sure we aren't trying to use ".." to display outside of our |
| 219 | * mounted path. |
| 220 | */ |
| 221 | |
| 222 | x = 0; |
| 223 | while (relpath[x] == '/') |
| 224 | { |
| 225 | x++; |
| 226 | } |
| 227 | |
| 228 | first = x; |
| 229 | |
| 230 | while (relpath[x] != '\0') |
| 231 | { |
| 232 | /* Test for ".." occurrence */ |
| 233 | |
| 234 | if (strncmp(&relpath[x], "..", 2) == 0) |
| 235 | { |
| 236 | /* Reduce depth by 1 */ |
| 237 | |
| 238 | depth--; |
| 239 | x += 2; |
| 240 | } |
| 241 | |
| 242 | else if (relpath[x] == '/' && relpath[x + 1] != '/' && |
| 243 | relpath[x + 1] != '\0') |
| 244 | { |
| 245 | depth++; |
| 246 | x++; |
| 247 | } |
| 248 | else |
| 249 | { |
| 250 | x++; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | if (depth >= 0) |
| 255 | { |
| 256 | strlcat(path, &relpath[first], pathlen - strlen(path)); |
| 257 | } |
| 258 | |
| 259 | while (fs->timeout > 0) |
| 260 | { |
| 261 | struct stat buf; |
| 262 | int ret; |
| 263 |
no test coverage detected