gazebosim / gazebosim/sdformat

sdf::findFile does not sanitize input filename, when given a path instead of a file name.

Open
#572 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
216
Forks
125
Avg merge
1d 14h
Merged PRs (30d)
14

Description

## Environment
* OS Version: Ubuntu 20.04
* Source build, branch `sdf11`

## Description
* Expected behavior:

When calling `sdf::findFile` with `test_model/model.sdf` as the input `_filename`, instead of a base file name (e.g. `model.sdf`), it does not throw any exceptions and returns the full path `/path/to/test_model/model.sdf`.

* Actual behavior:

In Windows machines however, we will produce a path like so `C:/somewhere\\path\\to\\models\\test_model/model.sdf`, due to the lack of path sanitization.

## Output

This was how it looked like during the Windows CI build for the lines https://github.com/osrf/sdformat/blob/sdf11/test/sdf/includes.sdf#L17-L20,

```
17: [ RUN ] ElementTracing.includes
17: C:\Jenkins\workspace\sdformat-ci-pr_any-windows7-amd64\ws\sdformat\test\integration\element_tracing.cc(283): error: Expected equality of these values:
17: modelFilePath
17: Which is: "C:/Jenkins/workspace/sdformat-ci-pr_any-windows7-amd64/ws/sdformat\\test\\integration\\model\\test_model\\model.sdf"
17: overrideModelWithFileElem->FilePath()
17: Which is: "C:/Jenkins/workspace/sdformat-ci-pr_any-windows7-amd64/ws/sdformat\\test\\integration\\model\\test_model/model.sdf"
17: [ FAILED ] ElementTracing.includes (201 ms)
```

Contributor guide

Open the contributing guide

Research direction

Start at the sdf::findFile entry point and inspect the include case in test/sdf/includes.sdf, especially the lines linked in the report. Run ElementTracing.includes in test/integration/element_tracing.cc and confirm that paths produced from test_model/model.sdf are sanitized consistently, including on Windows.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.