Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
29b1b066
Commit
29b1b066
authored
Sep 02, 2021
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
range: Distinguish missing separator from unknown unit
parent
b96d77c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
11 deletions
+24
-11
cache.h
bin/varnishd/cache/cache.h
+1
-1
cache_http.c
bin/varnishd/cache/cache_http.c
+14
-10
c00034.vtc
bin/varnishtest/tests/c00034.vtc
+9
-0
No files found.
bin/varnishd/cache/cache.h
View file @
29b1b066
...
@@ -669,7 +669,7 @@ extern const char H__Reason[];
...
@@ -669,7 +669,7 @@ extern const char H__Reason[];
#define http_expect_eq(str, tok) http_tok_eq(str, #tok)
#define http_expect_eq(str, tok) http_tok_eq(str, #tok)
// rfc7233,l,1207,1208
// rfc7233,l,1207,1208
#define http_range_at(str, tok
) http_ctok_at(str, #tok
)
#define http_range_at(str, tok
, l) http_tok_at(str, #tok, l
)
/* cache_main.c */
/* cache_main.c */
#define VXID(u) ((u) & VSL_IDENTMASK)
#define VXID(u) ((u) & VSL_IDENTMASK)
...
...
bin/varnishd/cache/cache_http.c
View file @
29b1b066
...
@@ -846,7 +846,7 @@ ssize_t
...
@@ -846,7 +846,7 @@ ssize_t
http_GetContentRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
)
http_GetContentRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
)
{
{
ssize_t
tmp
,
cl
;
ssize_t
tmp
,
cl
;
const
char
*
b
;
const
char
*
b
,
*
t
;
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
...
@@ -860,14 +860,14 @@ http_GetContentRange(const struct http *hp, ssize_t *lo, ssize_t *hi)
...
@@ -860,14 +860,14 @@ http_GetContentRange(const struct http *hp, ssize_t *lo, ssize_t *hi)
if
(
!
http_GetHdr
(
hp
,
H_Content_Range
,
&
b
))
if
(
!
http_GetHdr
(
hp
,
H_Content_Range
,
&
b
))
return
(
-
1
);
return
(
-
1
);
if
(
strncasecmp
(
"bytes"
,
b
,
strlen
(
"bytes"
)))
t
=
strchr
(
b
,
' '
);
return
(
-
1
);
// Unknown range unit, ignore
if
(
t
==
NULL
)
b
+=
strlen
(
"bytes"
);
return
(
-
2
);
// Missing space after range unit
if
(
!
vct_islws
(
*
b
))
if
(
!
http_range_at
(
b
,
bytes
,
t
-
b
))
return
(
-
1
);
// Unknown range unit, ignore
return
(
-
1
);
// Unknown range unit, ignore
while
(
vct_islws
(
*
b
))
b
=
t
+
1
;
b
++
;
if
(
*
b
==
'*'
)
{
// Content-Range: bytes */123
if
(
*
b
==
'*'
)
{
// Content-Range: bytes */123
*
lo
=
*
hi
=
-
1
;
*
lo
=
*
hi
=
-
1
;
b
++
;
b
++
;
...
@@ -908,7 +908,7 @@ const char *
...
@@ -908,7 +908,7 @@ const char *
http_GetRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
)
http_GetRange
(
const
struct
http
*
hp
,
ssize_t
*
lo
,
ssize_t
*
hi
)
{
{
ssize_t
tmp
;
ssize_t
tmp
;
const
char
*
b
;
const
char
*
b
,
*
t
;
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
...
@@ -922,9 +922,13 @@ http_GetRange(const struct http *hp, ssize_t *lo, ssize_t *hi)
...
@@ -922,9 +922,13 @@ http_GetRange(const struct http *hp, ssize_t *lo, ssize_t *hi)
if
(
!
http_GetHdr
(
hp
,
H_Range
,
&
b
))
if
(
!
http_GetHdr
(
hp
,
H_Range
,
&
b
))
return
(
NULL
);
return
(
NULL
);
if
(
!
http_range_at
(
b
,
bytes
=
))
t
=
strchr
(
b
,
'='
);
if
(
t
==
NULL
)
return
(
"Missing '='"
);
if
(
!
http_range_at
(
b
,
bytes
,
t
-
b
))
return
(
"Not Bytes"
);
return
(
"Not Bytes"
);
b
+=
strlen
(
"bytes="
)
;
b
=
t
+
1
;
*
lo
=
VNUM_uint
(
b
,
NULL
,
&
b
);
*
lo
=
VNUM_uint
(
b
,
NULL
,
&
b
);
if
(
*
lo
==
-
2
)
if
(
*
lo
==
-
2
)
...
...
bin/varnishtest/tests/c00034.vtc
View file @
29b1b066
...
@@ -259,6 +259,11 @@ server s1 {
...
@@ -259,6 +259,11 @@ server s1 {
expect req.http.range == <undef>
expect req.http.range == <undef>
txresp -hdr "content-range: bytes */100" -bodylen 100
txresp -hdr "content-range: bytes */100" -bodylen 100
rxreq
expect req.url == "/?invalid=content-range"
expect req.http.range == <undef>
txresp -hdr "content-range: bytes=0-99/100" -bodylen 100
rxreq
rxreq
expect req.http.range == "bytes=0-0"
expect req.http.range == "bytes=0-0"
txresp -hdr "content-range: bytes */*" -bodylen 100
txresp -hdr "content-range: bytes */*" -bodylen 100
...
@@ -295,6 +300,10 @@ client c8 {
...
@@ -295,6 +300,10 @@ client c8 {
rxresp
rxresp
expect resp.status == 503
expect resp.status == 503
txreq -url "/?invalid=content-range"
rxresp
expect resp.status == 503
txreq -hdr "range: bytes=0-0" -hdr "return: pass"
txreq -hdr "range: bytes=0-0" -hdr "return: pass"
rxresp
rxresp
expect resp.status == 503
expect resp.status == 503
...
...
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