Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-tus
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-tus
Commits
88d42892
Unverified
Commit
88d42892
authored
Jan 07, 2024
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid magic string lengths
parent
8f23ac49
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
9 deletions
+28
-9
tus_file.c
src/tus_file.c
+5
-5
tus_file.h
src/tus_file.h
+20
-0
tus_request.c
src/tus_request.c
+3
-4
No files found.
src/tus_file.c
View file @
88d42892
...
...
@@ -83,18 +83,18 @@ tus_file_final_concat_parse(const char *spec)
while
(
spec
!=
NULL
)
{
while
(
*
spec
==
' '
)
spec
++
;
if
(
strncmp
(
spec
,
"http"
,
4
)
==
0
)
{
spec
+=
4
;
if
(
TOK
(
spec
,
"http"
)
)
{
AN
(
spec
)
;
if
(
*
spec
==
's'
)
spec
++
;
if
(
strncmp
(
spec
,
"://"
,
3
)
!=
0
)
if
(
!
TOK
(
spec
,
"://"
)
)
goto
err
;
spec
+=
3
;
p
=
strchr
(
spec
,
'/'
);
if
(
p
==
NULL
)
goto
err
;
spec
=
p
;
}
AN
(
spec
);
if
(
*
spec
!=
'/'
)
goto
err
;
p
=
strchr
(
spec
,
' '
);
...
...
@@ -862,7 +862,7 @@ tus_file_load(struct VPFX(tus_server) *srv)
dir
=
fdopendir
(
dup
(
basefd
));
AN
(
dir
);
while
((
ent
=
readdir
(
dir
))
!=
NULL
)
{
if
(
strncmp
(
ent
->
d_name
,
TUS_FILE_PFX
,
strlen
(
TUS_FILE_PFX
)
))
if
(
STRNCMP
(
ent
->
d_name
,
TUS_FILE_PFX
))
continue
;
if
(
ent
->
d_type
!=
DT_REG
)
continue
;
...
...
src/tus_file.h
View file @
88d42892
...
...
@@ -40,6 +40,26 @@
*/
extern
struct
VSC_lck
*
lck_fcore
;
/* ============================================================
* Util - could move elsewhere
*/
#define STRNCMP(var, literal) \
strncmp(var, literal, strlen(literal))
/*
* lint:
* 820: Boolean test of a parenthesized assignment
* 774: Boolean within 'right side of && within if' always
* evaluates to True
*/
#define TOK(var, literal) \
(STRNCMP(var, literal) == 0 && ((var) += strlen(literal)) \
/*lint -e(820,774)*/
)
/* ============================================================
* tus_file
*/
#define TUS_PATH_MAX ((size_t)PATH_MAX)
#define TUS_METADATA_MAX ((size_t)2048) // ballpark of AWS S3 metadata
...
...
src/tus_request.c
View file @
88d42892
...
...
@@ -281,12 +281,11 @@ tus_request(VRT_CTX, struct VPFX(tus_server) *tussrv,
}
if
(
http_GetHdr
(
ctx
->
http_req
,
hdr_concat
,
&
concat
))
{
if
(
strcmp
(
concat
,
"partial"
)
==
0
)
{
if
(
strcmp
(
concat
,
"partial"
)
==
0
)
type
=
TUS_PARTIAL
;
}
else
if
(
strncmp
(
concat
,
"final;"
,
6
)
==
0
)
{
else
if
(
TOK
(
concat
,
"final;"
))
type
=
TUS_FINAL
;
concat
+=
6
;
}
else
{
else
{
r
->
s
.
status
=
400
;
return
(
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment