Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
d87700c9
Commit
d87700c9
authored
Mar 02, 2007
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Return errors in case of overflow
- Do not use non-thread-safe stuff
parent
419f5e33
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
35 deletions
+12
-35
src/network/getaddrinfo.c
src/network/getaddrinfo.c
+12
-35
No files found.
src/network/getaddrinfo.c
View file @
d87700c9
...
...
@@ -163,50 +163,27 @@ __getnameinfo( const struct sockaddr *sa, socklen_t salen,
if
(
host
!=
NULL
)
{
int
solved
=
0
;
/* host name resolution */
if
(
!
(
flags
&
NI_NUMERICHOST
))
{
struct
hostent
*
hent
;
hent
=
gethostbyaddr
((
const
void
*
)
&
addr
->
sin_addr
,
4
,
AF_INET
);
if
(
hent
!=
NULL
)
{
strlcpy
(
host
,
hent
->
h_name
,
hostlen
);
/*
* only keep first part of hostname
* if user don't want fully qualified
* domain name
*/
if
(
flags
&
NI_NOFQDN
)
{
char
*
ptr
;
ptr
=
strchr
(
host
,
'.'
);
if
(
ptr
!=
NULL
)
*
ptr
=
0
;
if
(
flags
&
NI_NAMEREQD
)
return
EAI_NONAME
;
}
solved
=
1
;
}
else
if
(
flags
&
NI_NAMEREQD
)
return
gai_error_from_herrno
();
}
/* inet_ntoa() is not thread-safe, do not use it */
uint32_t
ipv4
=
ntohl
(
addr
->
sin_addr
);
if
(
!
solved
)
/* inet_ntoa() can't fail */
strlcpy
(
host
,
inet_ntoa
(
addr
->
sin_addr
),
hostlen
);
if
(
snprintf
(
host
,
hostlen
,
"%u.%u.%u.%u"
,
ipv4
>>
24
,
(
ipv4
>>
16
)
&
0xff
,
(
ipv4
>>
8
)
&
0xff
,
ipv4
&
0xff
)
>=
hostlen
)
return
EAI_OVERFLOW
;
}
if
(
serv
!=
NULL
)
{
snprintf
(
serv
,
servlen
,
"%u"
,
(
unsigned
int
)
ntohs
(
addr
->
sin_port
));
serv
[
servlen
-
1
]
=
'\0'
;
if
(
snprintf
(
serv
,
servlen
,
"%u"
,
(
unsigned
int
)
ntohs
(
addr
->
sin_port
))
>=
servlen
)
return
EAI_OVERFLOW
;
}
}
return
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