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
30e90214
Commit
30e90214
authored
Sep 11, 2017
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VMOD blob: rename subblob() as sub().
Closes #2421
parent
33523f05
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
40 deletions
+40
-40
m00045.vtc
bin/varnishtest/tests/m00045.vtc
+24
-24
vmod.vcc
lib/libvmod_blob/vmod.vcc
+10
-10
vmod_blob.c
lib/libvmod_blob/vmod_blob.c
+6
-6
No files found.
bin/varnishtest/tests/m00045.vtc
View file @
30e90214
varnishtest "VMOD blob same(), equal(), length() and sub
blob
()"
varnishtest "VMOD blob same(), equal(), length() and sub()"
varnish v1 -vcl {
import blob;
...
...
@@ -165,7 +165,7 @@ client c1 {
expect resp.http.empty2len == "0"
} -run
# sub
blob
()
# sub()
varnish v1 -vcl {
import blob;
backend b { .host = "${bad_ip}"; }
...
...
@@ -183,23 +183,23 @@ varnish v1 -vcl {
sub vcl_synth {
set resp.http.up03
= blob.encode(BASE64, blob=blob.sub
blob
(up07.get(), 4B));
= blob.encode(BASE64, blob=blob.sub(up07.get(), 4B));
set resp.http.down07060504
= blob.encode(BASE64, blob=blob.sub
blob
(down07.get(), 4B));
= blob.encode(BASE64, blob=blob.sub(down07.get(), 4B));
set resp.http.up04050607
= blob.encode(BASE64,
blob=blob.sub
blob
(up07.get(), 4B, 4B));
blob=blob.sub(up07.get(), 4B, 4B));
set resp.http.down03
= blob.encode(BASE64,
blob=blob.sub
blob
(down07.get(), 4B, 4B));
blob=blob.sub(down07.get(), 4B, 4B));
set resp.http.up07
= blob.encode(BASE64, blob=blob.sub
blob
(up07.get(), 8B));
= blob.encode(BASE64, blob=blob.sub(up07.get(), 8B));
set resp.http.down07
= blob.encode(BASE64, blob=blob.sub
blob
(down07.get(), 8B));
= blob.encode(BASE64, blob=blob.sub(down07.get(), 8B));
set resp.http.zerobytes
= blob.encode(BASE64, blob=blob.sub
blob
(down07.get(), 0B));
= blob.encode(BASE64, blob=blob.sub(down07.get(), 0B));
set resp.http.zerolen
= blob.length(blob.sub
blob
(down07.get(), 0B));
= blob.length(blob.sub(down07.get(), 0B));
}
}
...
...
@@ -217,7 +217,7 @@ client c1 {
expect resp.http.zerolen == "0"
} -run
# sub
blob
() failures
# sub() failures
server s1 -repeat 3 {
rxreq
txresp
...
...
@@ -234,23 +234,23 @@ varnish v1 -vcl+backend {
sub vcl_deliver {
if (req.url == "/empty") {
set resp.http.empty = blob.encode(BASE64, blob=
blob.sub
blob
(empty.get(), 1B));
blob.sub(empty.get(), 1B));
}
elsif (req.url == "/toolong") {
set resp.http.toolong
= blob.encode(BASE64,
blob=blob.sub
blob
(up07.get(), 9B));
blob=blob.sub(up07.get(), 9B));
}
elsif (req.url == "/badoffset") {
set resp.http.badoffset = blob.encode(BASE64,
blob=blob.sub
blob
(up07.get(), 4B, 5B));
blob=blob.sub(up07.get(), 4B, 5B));
}
}
}
logexpect l1 -v v1 -d 0 -g vxid -q "VCL_Error" {
expect 0 * Begin req
expect * = VCL_Error "^vmod blob error: blob is empty in blob.sub
blob
..$"
expect * = VCL_Error "^vmod blob error: blob is empty in blob.sub..$"
expect * = End
} -start
...
...
@@ -273,7 +273,7 @@ client c1 {
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * * VCL_Error "^vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.sub
blob
..$"
expect * * VCL_Error "^vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.sub..$"
} -run
client c1 {
...
...
@@ -285,41 +285,41 @@ client c1 {
} -run
logexpect l1 -v v1 -d 1 -g vxid -q "VCL_Error" {
expect * * VCL_Error "^vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.sub
blob
..$"
expect * * VCL_Error "^vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.sub..$"
} -run
# VCL load failures from sub
blob
()
varnish v1 -errvcl {vmod blob error: blob is empty in blob.sub
blob
()} {
# VCL load failures from sub()
varnish v1 -errvcl {vmod blob error: blob is empty in blob.sub()} {
import blob;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new empty = blob.blob(IDENTITY, "");
if (blob.same(empty.get(), blob.sub
blob
(empty.get(), 0B))) {
if (blob.same(empty.get(), blob.sub(empty.get(), 0B))) {
new B = blob.blob(IDENTITY, "b");
}
}
}
varnish v1 -errvcl {vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.sub
blob
()} {
varnish v1 -errvcl {vmod blob error: size 9 from offset 0 requires more bytes than blob length 8 in blob.sub()} {
import blob;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new up07 = blob.blob(BASE64, "AAECAwQFBgc=");
if (blob.same(up07.get(), blob.sub
blob
(up07.get(), 9B))) {
if (blob.same(up07.get(), blob.sub(up07.get(), 9B))) {
new B = blob.blob(IDENTITY, "b");
}
}
}
varnish v1 -errvcl {vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.sub
blob
()} {
varnish v1 -errvcl {vmod blob error: size 4 from offset 5 requires more bytes than blob length 8 in blob.sub()} {
import blob;
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new up07 = blob.blob(BASE64, "AAECAwQFBgc=");
if (blob.same(up07.get(), blob.sub
blob
(up07.get(), 4B, 5B))) {
if (blob.same(up07.get(), blob.sub(up07.get(), 4B, 5B))) {
new B = blob.blob(IDENTITY, "b");
}
}
...
...
lib/libvmod_blob/vmod.vcc
View file @
30e90214
...
...
@@ -20,7 +20,7 @@ $Module blob 3 utilities for the VCL blob type
BOOL blob.same(BLOB, BLOB)
BOOL blob.equal(BLOB, BLOB)
INT blob.length(BLOB)
BLOB blob.sub
blob
(BLOB, BYTES length [, BYTES offset])
BLOB blob.sub(BLOB, BYTES length [, BYTES offset])
# blob object
new OBJ = blob.blob([ENUM decoding,] STRING_LIST encoded)
...
...
@@ -298,14 +298,14 @@ $Function INT length(BLOB)
Returns the length of the BLOB.
$Function BLOB sub
blob
(BLOB, BYTES length, BYTES offset = 0)
$Function BLOB sub(BLOB, BYTES length, BYTES offset = 0)
Returns a new BLOB formed from ``length`` bytes of the BLOB argument
starting at ``offset`` bytes from the start of its memory region. The
default value of ``offset`` is 0B.
``sub
blob()`` fails and returns NULL if the BLOB argument is empty, or
if
``offset + length`` requires more bytes than are available in the
``sub
()`` fails and returns NULL if the BLOB argument is empty, or if
``offset + length`` requires more bytes than are available in the
BLOB.
$Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX,
...
...
@@ -377,7 +377,7 @@ not known until runtime.
ERRORS
======
The encoders, decoders and ``sub
blob
()`` may fail if there is
The encoders, decoders and ``sub()`` may fail if there is
insufficient space to create the new blob or string. Decoders may also
fail if the encoded string is an illegal format for the decoding
scheme.
...
...
@@ -408,11 +408,11 @@ strings. The ``blob`` object and its methods allocate memory from the
heap, and hence they are only limited by available virtual memory.
The ``encode()``, ``decode()`` and ``transcode()`` functions allocate
Varnish workspace, as does ``sub
blob()`` for the newly created BLOB.
If these functions are failing, as indicated by "out of space"
messages in the Varnish log (with the ``VCL_Error`` tag), then you
will need to increase the varnishd parameters ``workspace_client``
and/or
``workspace_backend``.
Varnish workspace, as does ``sub
()`` for the newly created BLOB. If
these functions are failing, as indicated by "out of space" messages
in the Varnish log (with the ``VCL_Error`` tag), then you will need to
increase the varnishd parameters ``workspace_client`` and/or
``workspace_backend``.
The ``transcode()`` function also allocates space on the stack for a
temporary BLOB. If this function causes stack overflow, you may need
...
...
lib/libvmod_blob/vmod_blob.c
View file @
30e90214
...
...
@@ -549,8 +549,8 @@ vmod_length(VRT_CTX, VCL_BLOB b)
return
b
->
len
;
}
VCL_BLOB
__match_proto__
(
td_blob_sub
blob
)
vmod_sub
blob
(
VRT_CTX
,
VCL_BLOB
b
,
VCL_BYTES
n
,
VCL_BYTES
off
)
VCL_BLOB
__match_proto__
(
td_blob_sub
)
vmod_sub
(
VRT_CTX
,
VCL_BLOB
b
,
VCL_BYTES
n
,
VCL_BYTES
off
)
{
uintptr_t
snap
;
struct
vmod_priv
*
sub
;
...
...
@@ -560,13 +560,13 @@ vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off)
assert
(
off
>=
0
);
if
(
b
==
NULL
||
b
->
len
==
0
||
b
->
priv
==
NULL
)
{
ERR
(
ctx
,
"blob is empty in blob.sub
blob
()"
);
ERR
(
ctx
,
"blob is empty in blob.sub()"
);
return
NULL
;
}
assert
(
b
->
len
>=
0
);
if
(
off
+
n
>
b
->
len
)
{
VERR
(
ctx
,
"size %lld from offset %lld requires more bytes than "
"blob length %d in blob.sub
blob
()"
,
n
,
off
,
b
->
len
);
"blob length %d in blob.sub()"
,
n
,
off
,
b
->
len
);
return
NULL
;
}
...
...
@@ -575,11 +575,11 @@ vmod_subblob(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off)
snap
=
WS_Snapshot
(
ctx
->
ws
);
if
((
sub
=
WS_Alloc
(
ctx
->
ws
,
sizeof
(
*
sub
)))
==
NULL
)
{
ERRNOMEM
(
ctx
,
"Allocating BLOB result in blob.sub
blob
()"
);
ERRNOMEM
(
ctx
,
"Allocating BLOB result in blob.sub()"
);
return
NULL
;
}
if
((
sub
->
priv
=
WS_Alloc
(
ctx
->
ws
,
n
))
==
NULL
)
{
VERRNOMEM
(
ctx
,
"Allocating %lld bytes in blob.sub
blob
()"
,
n
);
VERRNOMEM
(
ctx
,
"Allocating %lld bytes in blob.sub()"
,
n
);
WS_Reset
(
ctx
->
ws
,
snap
);
return
NULL
;
}
...
...
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