Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
45779569
Commit
45779569
authored
Sep 29, 2013
by
MinRK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
return NULL and set EINVAL on bad z85 input
asserts aren't appropriate for checking user input.
parent
87254abc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
zmq_utils.cpp
src/zmq_utils.cpp
+11
-2
No files found.
src/zmq_utils.cpp
View file @
45779569
...
...
@@ -104,10 +104,14 @@ static uint8_t decoder [96] = {
// Encode a binary frame as a string; destination string MUST be at least
// size * 5 / 4 bytes long plus 1 byte for the null terminator. Returns
// dest. Size must be a multiple of 4.
// Returns NULL and sets errno = EINVAL for invalid input.
char
*
zmq_z85_encode
(
char
*
dest
,
uint8_t
*
data
,
size_t
size
)
{
assert
(
size
%
4
==
0
);
if
(
size
%
4
!=
0
)
{
errno
=
EINVAL
;
return
NULL
;
}
unsigned
int
char_nbr
=
0
;
unsigned
int
byte_nbr
=
0
;
uint32_t
value
=
0
;
...
...
@@ -134,10 +138,15 @@ char *zmq_z85_encode (char *dest, uint8_t *data, size_t size)
// Decode an encoded string into a binary frame; dest must be at least
// strlen (string) * 4 / 5 bytes long. Returns dest. strlen (string)
// must be a multiple of 5.
// Returns NULL and sets errno = EINVAL for invalid input.
uint8_t
*
zmq_z85_decode
(
uint8_t
*
dest
,
char
*
string
)
{
assert
(
strlen
(
string
)
%
5
==
0
);
if
(
strlen
(
string
)
%
5
!=
0
)
{
errno
=
EINVAL
;
return
NULL
;
}
unsigned
int
byte_nbr
=
0
;
unsigned
int
char_nbr
=
0
;
uint32_t
value
=
0
;
...
...
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