Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
monado
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
monado
Commits
78afc55d
Commit
78afc55d
authored
6 years ago
by
Jakob Bornecrantz
Committed by
Ryan Pavlik
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
st/oxr: Improve the fixed size single path verifier
parent
9b3b3704
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/xrt/state_trackers/oxr/oxr_api_verify.h
+4
-1
4 additions, 1 deletion
src/xrt/state_trackers/oxr/oxr_api_verify.h
src/xrt/state_trackers/oxr/oxr_verify.cpp
+37
-5
37 additions, 5 deletions
src/xrt/state_trackers/oxr/oxr_verify.cpp
with
41 additions
and
6 deletions
src/xrt/state_trackers/oxr/oxr_api_verify.h
+
4
−
1
View file @
78afc55d
...
@@ -136,10 +136,13 @@ extern "C" {
...
@@ -136,10 +136,13 @@ extern "C" {
*
*
*/
*/
/*!
* Verify a single path level that sits inside of a fixed sized array.
*/
XrResult
XrResult
oxr_verify_fixed_size_single_level_path
(
struct
oxr_logger
*
,
oxr_verify_fixed_size_single_level_path
(
struct
oxr_logger
*
,
const
char
*
path
,
const
char
*
path
,
uint32_t
size
,
uint32_t
array_
size
,
const
char
*
name
);
const
char
*
name
);
XrResult
XrResult
...
...
This diff is collapsed.
Click to expand it.
src/xrt/state_trackers/oxr/oxr_verify.cpp
+
37
−
5
View file @
78afc55d
...
@@ -9,7 +9,8 @@
...
@@ -9,7 +9,8 @@
* @ingroup oxr_api
* @ingroup oxr_api
*/
*/
#include
<stdio.h>
#include
<cstdio>
#include
<cstring>
#include
"xrt/xrt_compiler.h"
#include
"xrt/xrt_compiler.h"
#include
"util/u_debug.h"
#include
"util/u_debug.h"
...
@@ -25,6 +26,24 @@
...
@@ -25,6 +26,24 @@
*
*
*/
*/
static
bool
valid_path_char
(
const
char
c
)
{
if
(
'a'
<=
c
&&
c
<=
'z'
)
{
return
true
;
}
if
(
'0'
<=
c
&&
c
<=
'9'
)
{
return
true
;
}
if
(
c
==
'-'
||
c
==
'_'
||
c
==
'.'
||
c
==
'/'
)
{
return
true
;
}
return
false
;
}
static
bool
static
bool
contains_zero
(
const
char
*
path
,
uint32_t
size
)
contains_zero
(
const
char
*
path
,
uint32_t
size
)
{
{
...
@@ -40,10 +59,10 @@ contains_zero(const char* path, uint32_t size)
...
@@ -40,10 +59,10 @@ contains_zero(const char* path, uint32_t size)
extern
"C"
XrResult
extern
"C"
XrResult
oxr_verify_fixed_size_single_level_path
(
struct
oxr_logger
*
log
,
oxr_verify_fixed_size_single_level_path
(
struct
oxr_logger
*
log
,
const
char
*
path
,
const
char
*
path
,
uint32_t
size
,
uint32_t
array_
size
,
const
char
*
name
)
const
char
*
name
)
{
{
if
(
size
==
0
)
{
if
(
array_
size
==
0
)
{
return
oxr_error
(
log
,
XR_ERROR_VALIDATION_FAILURE
,
return
oxr_error
(
log
,
XR_ERROR_VALIDATION_FAILURE
,
"(%s) internal runtime error"
,
name
);
"(%s) internal runtime error"
,
name
);
}
}
...
@@ -53,13 +72,26 @@ oxr_verify_fixed_size_single_level_path(struct oxr_logger* log,
...
@@ -53,13 +72,26 @@ oxr_verify_fixed_size_single_level_path(struct oxr_logger* log,
"(%s) can not be empty"
,
name
);
"(%s) can not be empty"
,
name
);
}
}
if
(
!
contains_zero
(
path
,
size
))
{
if
(
!
contains_zero
(
path
,
array_
size
))
{
return
oxr_error
(
log
,
XR_ERROR_VALIDATION_FAILURE
,
return
oxr_error
(
log
,
XR_ERROR_VALIDATION_FAILURE
,
"(%s) must include zero termination '
\\
0'."
,
"(%s) must include zero termination '
\\
0'."
,
name
);
name
);
}
}
//! @todo verify more!
size_t
length
=
strlen
(
path
);
for
(
size_t
i
=
0
;
i
<
length
;
i
++
)
{
const
char
c
=
path
[
i
];
// Slashes are not valid in single level paths.
if
(
valid_path_char
(
c
)
&&
c
!=
'/'
)
{
continue
;
}
return
oxr_error
(
log
,
XR_ERROR_VALIDATION_FAILURE
,
"(%s) 0x%02x is not a valid character at position %u"
,
name
,
c
,
(
uint32_t
)
i
);
}
return
XR_SUCCESS
;
return
XR_SUCCESS
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment