Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
fbafa847
Commit
fbafa847
authored
May 23, 2019
by
Adrien Béraud
Browse files
base64: prevent crash in case of empty input
Change-Id: I2bfbde86083829d553a1f79e1c91aed4b2bedd6f
parent
321f83d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/base64.cpp
View file @
fbafa847
...
@@ -33,6 +33,9 @@ encode(const std::vector<uint8_t>::const_iterator begin,
...
@@ -33,6 +33,9 @@ encode(const std::vector<uint8_t>::const_iterator begin,
const
std
::
vector
<
uint8_t
>::
const_iterator
end
)
const
std
::
vector
<
uint8_t
>::
const_iterator
end
)
{
{
int
input_length
=
std
::
distance
(
begin
,
end
);
int
input_length
=
std
::
distance
(
begin
,
end
);
if
(
input_length
==
0
)
return
{};
int
output_length
=
PJ_BASE256_TO_BASE64_LEN
(
input_length
);
int
output_length
=
PJ_BASE256_TO_BASE64_LEN
(
input_length
);
std
::
string
out
;
std
::
string
out
;
out
.
resize
(
output_length
);
out
.
resize
(
output_length
);
...
@@ -54,6 +57,9 @@ encode(const std::vector<uint8_t>& dat)
...
@@ -54,6 +57,9 @@ encode(const std::vector<uint8_t>& dat)
std
::
vector
<
uint8_t
>
std
::
vector
<
uint8_t
>
decode
(
const
std
::
string
&
str
)
decode
(
const
std
::
string
&
str
)
{
{
if
(
str
.
empty
())
return
{};
int
output_length
=
PJ_BASE64_TO_BASE256_LEN
(
str
.
length
());
int
output_length
=
PJ_BASE64_TO_BASE256_LEN
(
str
.
length
());
const
pj_str_t
input
(
sip_utils
::
CONST_PJ_STR
(
str
));
const
pj_str_t
input
(
sip_utils
::
CONST_PJ_STR
(
str
));
...
...
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