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
415e9ebf
Commit
415e9ebf
authored
Jan 25, 2016
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
define safe encoding and decoding lengths more precisely
parent
99e3618a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
5 deletions
+8
-5
base64.c
src/base64.c
+2
-1
vmod_convert.h
src/vmod_convert.h
+6
-4
No files found.
src/base64.c
View file @
415e9ebf
...
...
@@ -127,7 +127,8 @@ base64_encode(const enum encoding enc, char *restrict const buf,
AN
(
buf
);
if
(
in
==
NULL
||
inlen
==
0
)
return
0
;
if
(
outlen
<
base64_encode_l
(
inlen
))
if
((
enc
!=
BASE64URLNOPAD
&&
outlen
<
base64_encode_l
(
inlen
))
||
outlen
<
base64nopad_encode_l
(
inlen
))
return
-
1
;
while
(
1
)
{
...
...
src/vmod_convert.h
View file @
415e9ebf
...
...
@@ -40,10 +40,12 @@
* SAFE LENGTH ESTIMATES
*/
#define base64_decode_l(l) ((l * 3 / 4) + 1)
#define base64_encode_l(l) (((((l * 4 / 3) + 3) / 4) * 4) + 1)
#define hex_encode_l(l) ((l * 2) + 1)
#define hex_decode_l(l) ((l / 2) + 1)
#define base64_decode_l(l) (((l) * 3) >> 2)
#define base64_l(l) (((l) << 2) / 3)
#define base64nopad_encode_l(l) (base64_l(l) + 1)
#define base64_encode_l(l) ((((base64_l(l)) + 3) & ~3) + 1)
#define hex_encode_l(l) (((l) << 1) + 1)
#define hex_decode_l(l) (((l) + 1) >> 1)
/*
* General interface for an encoder: encode the data at in of length inlen
...
...
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