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
3e74a3e5
Commit
3e74a3e5
authored
Mar 27, 2016
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename maxlen to buflen to clarify that it is the length of buf
parent
9f8d9342
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
22 deletions
+22
-22
base64.c
src/base64.c
+9
-9
hex.c
src/hex.c
+5
-5
id.c
src/id.c
+4
-4
vmod_blobcode.h
src/vmod_blobcode.h
+4
-4
No files found.
src/base64.c
View file @
3e74a3e5
...
...
@@ -56,7 +56,7 @@ base64_decode_l(size_t l)
static
inline
int
decode
(
char
*
restrict
*
restrict
dest
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
unsigned
u
,
const
int
n
)
const
size_t
buf
len
,
unsigned
u
,
const
int
n
)
{
char
*
d
;
...
...
@@ -64,7 +64,7 @@ decode(char *restrict *restrict dest, char *restrict const buf,
return
-
1
;
d
=
*
dest
;
for
(
int
i
=
0
;
i
<
n
-
1
;
i
++
)
{
if
(
d
==
buf
+
max
len
)
if
(
d
==
buf
+
buf
len
)
return
-
1
;
*
d
++
=
(
u
>>
16
)
&
0xff
;
u
<<=
8
;
...
...
@@ -75,7 +75,7 @@ decode(char *restrict *restrict dest, char *restrict const buf,
ssize_t
base64_encode
(
const
enum
encoding
enc
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
const
char
*
restrict
const
inbuf
,
const
size_t
buf
len
,
const
char
*
restrict
const
inbuf
,
const
size_t
inlength
)
{
const
struct
b64_alphabet
*
alpha
=
&
b64_alphabet
[
enc
];
...
...
@@ -87,8 +87,8 @@ base64_encode(const enum encoding enc, char *restrict const buf,
AN
(
alpha
);
if
(
in
==
NULL
||
inlength
==
0
)
return
0
;
if
((
enc
!=
BASE64URLNOPAD
&&
max
len
<
base64_encode_l
(
inlength
))
||
max
len
<
base64nopad_encode_l
(
inlength
))
if
((
enc
!=
BASE64URLNOPAD
&&
buf
len
<
base64_encode_l
(
inlength
))
||
buf
len
<
base64nopad_encode_l
(
inlength
))
return
-
1
;
while
(
end
-
in
>=
3
)
{
...
...
@@ -115,13 +115,13 @@ base64_encode(const enum encoding enc, char *restrict const buf,
}
}
}
assert
(
p
>=
buf
&&
p
-
buf
<=
max
len
);
assert
(
p
>=
buf
&&
p
-
buf
<=
buf
len
);
return
p
-
buf
;
}
ssize_t
base64_decode
(
const
enum
encoding
dec
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
const
char
*
restrict
const
p
,
va_list
ap
)
const
size_t
buf
len
,
const
char
*
restrict
const
p
,
va_list
ap
)
{
const
struct
b64_alphabet
*
alpha
=
&
b64_alphabet
[
dec
];
char
*
dest
=
buf
;
...
...
@@ -157,7 +157,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
break
;
}
if
(
n
==
4
)
{
if
(
decode
(
&
dest
,
buf
,
max
len
,
u
,
n
-
term
)
<
0
)
{
if
(
decode
(
&
dest
,
buf
,
buf
len
,
u
,
n
-
term
)
<
0
)
{
errno
=
ENOMEM
;
return
-
1
;
}
...
...
@@ -168,7 +168,7 @@ base64_decode(const enum encoding dec, char *restrict const buf,
if
(
n
)
{
if
(
!
alpha
->
padding
)
u
<<=
6
*
(
4
-
n
);
if
(
decode
(
&
dest
,
buf
,
max
len
,
u
,
n
-
term
)
<
0
)
{
if
(
decode
(
&
dest
,
buf
,
buf
len
,
u
,
n
-
term
)
<
0
)
{
errno
=
ENOMEM
;
return
-
1
;
}
...
...
src/hex.c
View file @
3e74a3e5
...
...
@@ -74,7 +74,7 @@ hex2byte(const unsigned char hi, const unsigned char lo)
ssize_t
hex_encode
(
const
enum
encoding
enc
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
const
char
*
restrict
const
in
,
const
size_t
buf
len
,
const
char
*
restrict
const
in
,
const
size_t
inlen
)
{
char
*
p
=
buf
;
...
...
@@ -84,7 +84,7 @@ hex_encode(const enum encoding enc, char *restrict const buf,
assert
(
enc
==
HEXUC
||
enc
==
HEXLC
);
if
(
in
==
NULL
||
inlen
==
0
)
return
0
;
if
(
max
len
<
hex_encode_l
(
inlen
))
if
(
buf
len
<
hex_encode_l
(
inlen
))
return
-
1
;
if
(
enc
!=
HEXLC
)
...
...
@@ -100,7 +100,7 @@ hex_encode(const enum encoding enc, char *restrict const buf,
ssize_t
hex_decode
(
const
enum
encoding
dec
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
const
char
*
restrict
const
p
,
va_list
ap
)
const
size_t
buf
len
,
const
char
*
restrict
const
p
,
va_list
ap
)
{
char
*
dest
=
buf
;
unsigned
char
extranib
=
0
;
...
...
@@ -132,7 +132,7 @@ hex_decode(const enum encoding dec, char *restrict const buf,
errno
=
EINVAL
;
return
-
1
;
}
if
((
len
+
1
)
>>
1
>
max
len
)
{
if
((
len
+
1
)
>>
1
>
buf
len
)
{
errno
=
ENOMEM
;
return
-
1
;
}
...
...
@@ -151,6 +151,6 @@ hex_decode(const enum encoding dec, char *restrict const buf,
}
extranib
=
*
s
;
}
assert
(
dest
<=
buf
+
max
len
);
assert
(
dest
<=
buf
+
buf
len
);
return
dest
-
buf
;
}
src/id.c
View file @
3e74a3e5
...
...
@@ -48,13 +48,13 @@ id_decode_l(size_t l)
ssize_t
id_encode
(
const
enum
encoding
enc
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
const
char
*
restrict
const
in
,
const
size_t
buf
len
,
const
char
*
restrict
const
in
,
const
size_t
inlen
)
{
(
void
)
enc
;
AN
(
buf
);
if
(
max
len
<
inlen
+
1
)
if
(
buf
len
<
inlen
+
1
)
return
-
1
;
if
(
in
==
NULL
||
inlen
==
0
)
return
0
;
...
...
@@ -65,7 +65,7 @@ id_encode(const enum encoding enc, char *restrict const buf,
ssize_t
id_decode
(
const
enum
encoding
enc
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
const
char
*
restrict
const
p
,
va_list
ap
)
const
size_t
buf
len
,
const
char
*
restrict
const
p
,
va_list
ap
)
{
char
*
dest
=
buf
;
size_t
len
,
outlen
=
0
;
...
...
@@ -78,7 +78,7 @@ id_decode(const enum encoding enc, char *restrict const buf,
if
(
s
==
NULL
||
*
s
==
'\0'
)
continue
;
len
=
strlen
(
s
);
if
((
outlen
+=
len
)
>
max
len
)
{
if
((
outlen
+=
len
)
>
buf
len
)
{
errno
=
ENOMEM
;
return
-
1
;
}
...
...
src/vmod_blobcode.h
View file @
3e74a3e5
...
...
@@ -47,7 +47,7 @@ size_t len_f(size_t);
*
* enc: encoding enum (from parse_encoding.h)
* buf: destination of the encoded string
*
max
len: maximum length available at buf
*
buf
len: maximum length available at buf
* in: source of data to be encoded
* inlen: length of data to be encoded
*
...
...
@@ -66,7 +66,7 @@ size_t len_f(size_t);
*/
typedef
ssize_t
encode_f
(
const
enum
encoding
enc
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
const
char
*
restrict
const
in
,
const
size_t
buf
len
,
const
char
*
restrict
const
in
,
const
size_t
inlen
);
/*
...
...
@@ -76,7 +76,7 @@ ssize_t encode_f(const enum encoding enc, char *restrict const buf,
*
* dec: decoding enum (from parse_encoding.h)
* buf: destination of the decoded data
*
max
len: maximum length available at buf
*
buf
len: maximum length available at buf
* p, ap: strings obtained from a VCL STRING_LIST
*
* The regions pointed to by buf and any of the strings in p or ap MUST
...
...
@@ -93,7 +93,7 @@ ssize_t encode_f(const enum encoding enc, char *restrict const buf,
*/
typedef
ssize_t
decode_f
(
const
enum
encoding
dec
,
char
*
restrict
const
buf
,
const
size_t
max
len
,
const
char
*
restrict
const
p
,
va_list
ap
);
const
size_t
buf
len
,
const
char
*
restrict
const
p
,
va_list
ap
);
/* id.c */
len_f
id_encode_l
;
...
...
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