Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-blobcode
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
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-blobcode
Commits
b47ed0a2
Commit
b47ed0a2
authored
Jan 18, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix base64_decode() for BASE64URLNOPAD
parent
9d6513e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
base64.c
src/base64.c
+6
-3
base64.vtc
src/tests/base64.vtc
+23
-0
No files found.
src/base64.c
View file @
b47ed0a2
...
@@ -189,14 +189,14 @@ base64_decode(const enum encoding dec, char *restrict const buf,
...
@@ -189,14 +189,14 @@ base64_decode(const enum encoding dec, char *restrict const buf,
const
size_t
maxlen
,
const
char
*
restrict
const
p
,
va_list
ap
)
const
size_t
maxlen
,
const
char
*
restrict
const
p
,
va_list
ap
)
{
{
struct
b64_alphabet
*
alpha
=
&
b64_alphabet
[
dec
];
struct
b64_alphabet
*
alpha
=
&
b64_alphabet
[
dec
];
const
char
*
s
;
char
*
dest
=
buf
;
char
*
dest
=
buf
;
unsigned
u
=
0
,
term
=
0
;
unsigned
u
=
0
,
term
=
0
;
int
n
=
0
;
int
n
=
0
;
AN
(
buf
);
AN
(
buf
);
for
(
s
=
p
;
s
!=
vrt_magic_string_end
;
s
=
va_arg
(
ap
,
const
char
*
))
{
for
(
const
char
*
s
=
p
;
s
!=
vrt_magic_string_end
;
s
=
va_arg
(
ap
,
const
char
*
))
{
if
(
s
==
NULL
)
if
(
s
==
NULL
)
continue
;
continue
;
if
(
*
s
&&
term
)
{
if
(
*
s
&&
term
)
{
...
@@ -229,11 +229,14 @@ base64_decode(const enum encoding dec, char *restrict const buf,
...
@@ -229,11 +229,14 @@ base64_decode(const enum encoding dec, char *restrict const buf,
}
}
}
}
}
}
if
(
n
)
if
(
n
)
{
if
(
!
alpha
->
padding
)
u
<<=
6
*
(
4
-
n
);
if
(
decode
(
&
dest
,
buf
,
maxlen
,
u
,
n
-
term
)
<
0
)
{
if
(
decode
(
&
dest
,
buf
,
maxlen
,
u
,
n
-
term
)
<
0
)
{
errno
=
ENOMEM
;
errno
=
ENOMEM
;
return
-
1
;
return
-
1
;
}
}
}
return
dest
-
buf
;
return
dest
-
buf
;
}
}
src/tests/base64.vtc
View file @
b47ed0a2
...
@@ -68,6 +68,25 @@ varnish v1 -vcl+backend {
...
@@ -68,6 +68,25 @@ varnish v1 -vcl+backend {
+
"H"
+
resp
.
http
.
mid2
+
"kLw"
+
"H"
+
resp
.
http
.
mid2
+
"kLw"
+
resp
.
http
.
pad
));
+
resp
.
http
.
pad
));
set
resp
.
http
.
decnopad
=
convert
.
encode
(
IDENTITY
,
convert
.
decode
(
BASE64URLNOPAD
,
"L0hlbGxvIHdvcmxkLw"
));
set
resp
.
http
.
decnopad2pieces
=
convert
.
encode
(
IDENTITY
,
convert
.
decode
(
BASE64URLNOPAD
,
resp
.
http
.
l
+
"0hlbGxvIHdvcmxkLw"
));
set
resp
.
http
.
decnopad6pieces
=
convert
.
encode
(
IDENTITY
,
convert
.
decode
(
BASE64URLNOPAD
,
resp
.
http
.
l
+
"0hlb"
+
resp
.
http
.
mid1
+
"H"
+
resp
.
http
.
mid2
+
"kLw"
));
set
resp
.
http
.
decnopadlong
=
convert
.
encode
(
IDENTITY
,
convert
.
decode
(
BASE64URLNOPAD
,
"VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw"
));
}
}
}
-
start
}
-
start
...
@@ -86,6 +105,10 @@ client c1 {
...
@@ -86,6 +105,10 @@ client c1 {
expect
resp
.
http
.
dec2pieces
==
"/Hello world/"
expect
resp
.
http
.
dec2pieces
==
"/Hello world/"
expect
resp
.
http
.
dec3pieces
==
"/Hello world/"
expect
resp
.
http
.
dec3pieces
==
"/Hello world/"
expect
resp
.
http
.
dec7pieces
==
"/Hello world/"
expect
resp
.
http
.
dec7pieces
==
"/Hello world/"
expect
resp
.
http
.
decnopad
==
"/Hello world/"
expect
resp
.
http
.
decnopad2pieces
==
"/Hello world/"
expect
resp
.
http
.
decnopad6pieces
==
"/Hello world/"
expect
resp
.
http
.
decnopadlong
==
"The quick brown fox jumps over the lazy dog"
}
}
client
c1
-
run
client
c1
-
run
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