Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
6e66a5b7
Commit
6e66a5b7
authored
Feb 10, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net/Resolver: relax size check in LocalAddressToString()
Handles abstract sockets on Linux.
parent
cf5c10bb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
Resolver.cxx
src/net/Resolver.cxx
+20
-2
No files found.
src/net/Resolver.cxx
View file @
6e66a5b7
...
...
@@ -23,6 +23,8 @@
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include <algorithm>
#ifndef WIN32
#include <sys/socket.h>
#include <netdb.h>
...
...
@@ -48,10 +50,26 @@ const Domain resolver_domain("resolver");
static
std
::
string
LocalAddressToString
(
const
struct
sockaddr_un
&
s_un
,
size_t
size
)
{
if
(
size
<
sizeof
(
s_un
)
||
s_un
.
sun_path
[
0
]
==
0
)
const
size_t
prefix_size
=
(
size_t
)
((
struct
sockaddr_un
*
)
nullptr
)
->
sun_path
;
assert
(
size
>=
prefix_size
);
size_t
result_length
=
size
-
prefix_size
;
/* remove the trailing null terminator */
if
(
result_length
>
0
&&
s_un
.
sun_path
[
result_length
-
1
]
==
0
)
--
result_length
;
if
(
result_length
==
0
)
return
"local"
;
return
s_un
.
sun_path
;
std
::
string
result
(
s_un
.
sun_path
,
result_length
);
/* replace all null bytes with '@'; this also handles abstract
addresses (Linux specific) */
std
::
replace
(
result
.
begin
(),
result
.
end
(),
'\0'
,
'@'
);
return
result
;
}
#endif
...
...
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