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
723cd7b2
Commit
723cd7b2
authored
Feb 25, 2021
by
Dridi Boukelmoune
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: Explode http_GetContentLength() for reuse
parent
de952053
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
cache_http.c
bin/varnishd/cache/cache_http.c
+25
-12
No files found.
bin/varnishd/cache/cache_http.c
View file @
723cd7b2
...
...
@@ -821,29 +821,42 @@ http_GetHdrField(const struct http *hp, hdr_t hdr,
/*--------------------------------------------------------------------*/
static
ssize_t
http_parse_uint
(
const
char
*
b
,
const
char
**
e
)
{
ssize_t
u
;
unsigned
n
;
u
=
0
;
if
(
!
vct_isdigit
(
*
b
))
return
(
-
1
);
for
(;
vct_isdigit
(
*
b
);
b
++
)
{
if
(
u
>
(
SSIZE_MAX
/
10
))
return
(
-
1
);
u
*=
10
;
n
=
*
b
-
'0'
;
if
(
u
>
(
SSIZE_MAX
-
n
))
return
(
-
1
);
u
+=
n
;
}
*
e
=
b
;
return
(
u
);
}
ssize_t
http_GetContentLength
(
const
struct
http
*
hp
)
{
ssize_t
cl
;
const
char
*
b
;
unsigned
n
;
CHECK_OBJ_NOTNULL
(
hp
,
HTTP_MAGIC
);
if
(
!
http_GetHdr
(
hp
,
H_Content_Length
,
&
b
))
return
(
-
1
);
cl
=
0
;
if
(
!
vct_isdigit
(
*
b
)
)
cl
=
http_parse_uint
(
b
,
&
b
)
;
if
(
cl
<
0
)
return
(
-
2
);
for
(;
vct_isdigit
(
*
b
);
b
++
)
{
if
(
cl
>
(
SSIZE_MAX
/
10
))
return
(
-
2
);
cl
*=
10
;
n
=
*
b
-
'0'
;
if
(
cl
>
(
SSIZE_MAX
-
n
))
return
(
-
2
);
cl
+=
n
;
}
while
(
vct_islws
(
*
b
))
b
++
;
if
(
*
b
!=
'\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