Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
Icecast-Server
Commits
a650965c
Commit
a650965c
authored
Jan 04, 2015
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup: make util_base64_encode() useful for binary data.
parent
de48bdd1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
8 deletions
+6
-8
src/slave.c
src/slave.c
+2
-2
src/util.c
src/util.c
+3
-5
src/util.h
src/util.h
+1
-1
No files found.
src/slave.c
View file @
a650965c
...
...
@@ -176,7 +176,7 @@ static client_t *open_relay_connection (relay_server *relay)
auth_header
=
malloc
(
len
);
snprintf
(
auth_header
,
len
,
"%s:%s"
,
relay
->
username
,
relay
->
password
);
esc_authorisation
=
util_base64_encode
(
auth_header
);
esc_authorisation
=
util_base64_encode
(
auth_header
,
len
);
free
(
auth_header
);
len
=
strlen
(
esc_authorisation
)
+
24
;
auth_header
=
malloc
(
len
);
...
...
@@ -637,7 +637,7 @@ static int update_from_master(ice_config_t *config)
len
=
strlen
(
username
)
+
strlen
(
password
)
+
2
;
authheader
=
malloc
(
len
);
snprintf
(
authheader
,
len
,
"%s:%s"
,
username
,
password
);
data
=
util_base64_encode
(
authheader
);
data
=
util_base64_encode
(
authheader
,
len
);
sock_write
(
mastersock
,
"GET /admin/streamlist.txt HTTP/1.0
\r\n
"
"Authorization: Basic %s
\r\n
"
...
...
src/util.c
View file @
a650965c
...
...
@@ -409,15 +409,13 @@ char *util_bin_to_hex(unsigned char *data, int len)
}
/* This isn't efficient, but it doesn't need to be */
char
*
util_base64_encode
(
const
char
*
data
)
{
int
len
=
strlen
(
data
);
char
*
util_base64_encode
(
const
char
*
data
,
size_t
len
)
{
char
*
out
=
malloc
(
len
*
4
/
3
+
4
);
char
*
result
=
out
;
in
t
chunk
;
size_
t
chunk
;
while
(
len
>
0
)
{
chunk
=
(
len
>
3
)
?
3
:
len
;
chunk
=
len
>
3
?
3
:
len
;
*
out
++
=
base64table
[(
*
data
&
0xFC
)
>>
2
];
*
out
++
=
base64table
[((
*
data
&
0x03
)
<<
4
)
|
((
*
(
data
+
1
)
&
0xF0
)
>>
4
)];
switch
(
chunk
)
{
...
...
src/util.h
View file @
a650965c
...
...
@@ -32,7 +32,7 @@ char *util_get_extension(const char *path);
char
*
util_get_path_from_uri
(
char
*
uri
);
char
*
util_get_path_from_normalised_uri
(
const
char
*
uri
);
char
*
util_normalise_uri
(
const
char
*
uri
);
char
*
util_base64_encode
(
const
char
*
data
);
char
*
util_base64_encode
(
const
char
*
data
,
size_t
len
);
char
*
util_base64_decode
(
const
char
*
input
);
char
*
util_bin_to_hex
(
unsigned
char
*
data
,
int
len
);
...
...
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