Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-blobdigest
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
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-blobdigest
Commits
58858a78
Commit
58858a78
authored
Nov 01, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
verify that digest.update() fails after .final() has already been called
parent
4eeed3b6
Pipeline
#46
skipped
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
2 deletions
+71
-2
md5.vtc
src/tests/md5.vtc
+65
-0
vmod_blobdigest.c
src/vmod_blobdigest.c
+6
-2
No files found.
src/tests/md5.vtc
View file @
58858a78
...
...
@@ -543,3 +543,68 @@ client c1 {
expect resp.http.d2_c1 == "0CC175B9C0F1B6A831C399E269772661"
expect resp.http.d2_c2 == "0CC175B9C0F1B6A831C399E269772661"
} -run
# digest.update() may not be called after digest.final()
varnish v1 -errvcl {vmod blobdigest error: already finalized in d1.update()} {
import blobdigest from "${vmod_topbuild}/src/.libs/libvmod_blobdigest.so";
import blobcode;
import blob;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new empty = blobcode.blob(IDENTITY, "");
new hash = blobcode.blob(HEX,
"D41D8CD98F00B204E9800998ECF8427E");
new d1 = blobdigest.digest(MD5);
if (!d1.update(empty.get())) {
return(fail);
}
if (!blob.equal(d1.final(), hash.get())) {
return(fail);
}
if (!d1.update(empty.get())) {
return(fail);
}
}
}
varnish v1 -vcl {
import blobdigest from "${vmod_topbuild}/src/.libs/libvmod_blobdigest.so";
import blobcode;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new a = blobcode.blob(IDENTITY, "a");
new d1 = blobdigest.digest(MD5);
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (!d1.update(a.get())) {
set resp.status = 500;
return(deliver);
}
set resp.http.a = blobcode.encode(HEXUC, d1.final());
if (!d1.update(a.get())) {
set resp.status = 500;
return(deliver);
}
}
}
client c1 {
txreq
rxresp
expect resp.status == 500
expect resp.http.a == "0CC175B9C0F1B6A831C399E269772661"
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod blobdigest error: already finalized in d1.update..$"
expect * = End
} -run
src/vmod_blobdigest.c
View file @
58858a78
...
...
@@ -45,6 +45,9 @@
#define ERR(ctx, msg) \
errmsg((ctx), "vmod blobdigest error: " msg)
#define VERR(ctx, fmt, ...) \
errmsg((ctx), "vmod blobdigest error: " fmt, __VA_ARGS__)
#define ERRNOMEM(ctx, msg) \
ERR((ctx), msg ", out of space")
...
...
@@ -291,11 +294,12 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b)
CHECK_OBJ_NOTNULL
(
h
,
VMOD_BLOBDIGEST_DIGEST_MAGIC
);
if
(
h
->
result
!=
NULL
)
{
ERR
(
ctx
,
"already finalized in digest.update()"
);
VERR
(
ctx
,
"already finalized in %s.update()"
,
h
->
vcl_name
);
return
0
;
}
/* XXX: is b == NULL an error? */
/* XXX: no error calling .update() after .final() in these cases */
if
(
b
==
NULL
||
b
->
len
==
0
||
b
->
priv
==
NULL
)
return
1
;
...
...
@@ -307,7 +311,7 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b)
task
=
get_task
(
ctx
,
h
);
CHECK_OBJ_NOTNULL
(
task
,
VMOD_BLOBDIGEST_DIGEST_TASK_MAGIC
);
if
(
task
->
result
!=
NULL
)
{
ERR
(
ctx
,
"already finalized in digest.update()"
);
VERR
(
ctx
,
"already finalized in %s.update()"
,
h
->
vcl_name
);
return
0
;
}
update
(
h
->
hash
,
&
task
->
ctx
,
b
->
priv
,
b
->
len
);
...
...
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