Commit 6687a313 authored by Geoff Simmons's avatar Geoff Simmons

clarified error conditions in digest.update(): error if the vmod_priv

object is NULL. If the blob's length is 0 or its priv pointer is NULL,
pass over it silently -- not an error, but no need to call the hash
update.
parent a9f58f0f
Pipeline #48 skipped
......@@ -575,7 +575,7 @@ varnish v1 -vcl {
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new a = blobcode.blob(IDENTITY, "a");
new empty = blobcode.blob(IDENTITY, "");
new d1 = blobdigest.digest(MD5);
}
......@@ -584,12 +584,12 @@ varnish v1 -vcl {
}
sub vcl_synth {
if (!d1.update(a.get())) {
if (!d1.update(empty.get())) {
set resp.status = 500;
return(deliver);
}
set resp.http.a = blobcode.encode(HEXUC, d1.final());
if (!d1.update(a.get())) {
set resp.http.empty = blobcode.encode(HEXUC, d1.final());
if (!d1.update(empty.get())) {
set resp.status = 500;
return(deliver);
}
......@@ -600,7 +600,7 @@ client c1 {
txreq
rxresp
expect resp.status == 500
expect resp.http.a == "0CC175B9C0F1B6A831C399E269772661"
expect resp.http.empty == "D41D8CD98F00B204E9800998ECF8427E"
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
......
......@@ -327,13 +327,14 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b)
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;
if (b == NULL) {
VERR(ctx, "null BLOB passed to %s.update()", h->vcl_name);
return 0;
}
if (INIT_FINI(ctx)) {
update(h->hash, &h->ctx, b->priv, b->len);
if (b->len > 0 && b->priv != NULL)
update(h->hash, &h->ctx, b->priv, b->len);
return 1;
}
......@@ -343,7 +344,8 @@ vmod_digest_update(VRT_CTX, struct vmod_blobdigest_digest *h, VCL_BLOB b)
VERR(ctx, "already finalized in %s.update()", h->vcl_name);
return 0;
}
update(h->hash, &task->ctx, b->priv, b->len);
if (b->len > 0 && b->priv != NULL)
update(h->hash, &task->ctx, b->priv, b->len);
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment