Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
13bd0121
Commit
13bd0121
authored
Aug 19, 2012
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vlc_getaddrinfo: port is unsigned, 0 means unspecified
parent
fbd30448
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
14 deletions
+20
-14
include/vlc_network.h
include/vlc_network.h
+2
-1
src/network/getaddrinfo.c
src/network/getaddrinfo.c
+18
-13
No files found.
include/vlc_network.h
View file @
13bd0121
...
...
@@ -260,7 +260,8 @@ VLC_API int getnameinfo ( const struct sockaddr *, socklen_t,
#endif
VLC_API
int
vlc_getnameinfo
(
const
struct
sockaddr
*
,
int
,
char
*
,
int
,
int
*
,
int
);
VLC_API
int
vlc_getaddrinfo
(
vlc_object_t
*
,
const
char
*
,
int
,
const
struct
addrinfo
*
,
struct
addrinfo
**
);
VLC_API
int
vlc_getaddrinfo
(
vlc_object_t
*
,
const
char
*
,
unsigned
,
const
struct
addrinfo
*
,
struct
addrinfo
**
);
#ifdef __OS2__
...
...
src/network/getaddrinfo.c
View file @
13bd0121
...
...
@@ -80,25 +80,30 @@ int vlc_getnameinfo( const struct sockaddr *sa, int salen,
* On failure, *res is undefined. On success, it must be freed with
* freeaddrinfo().
*/
int
vlc_getaddrinfo
(
vlc_object_t
*
p_this
,
const
char
*
node
,
int
i_
port
,
const
struct
addrinfo
*
p_hints
,
struct
addrinfo
**
res
)
int
vlc_getaddrinfo
(
vlc_object_t
*
p_this
,
const
char
*
node
,
unsigned
port
,
const
struct
addrinfo
*
p_hints
,
struct
addrinfo
**
res
)
{
struct
addrinfo
hints
;
char
psz_buf
[
NI_MAXHOST
],
p
sz_service
[
6
]
;
char
psz_buf
[
NI_MAXHOST
],
p
ortbuf
[
6
],
*
servname
;
/*
* In VLC, we always use port number as integer rather than strings
* for historical reasons (and portability).
*/
if
(
(
i_port
>
65535
)
||
(
i_port
<
0
)
)
if
(
port
!=
0
)
{
msg_Err
(
p_this
,
"invalid port number %d specified"
,
i_port
);
if
(
port
>
65535
)
{
msg_Err
(
p_this
,
"invalid port number %u specified"
,
port
);
return
EAI_SERVICE
;
}
/* cannot overflow */
snprintf
(
psz_service
,
6
,
"%d"
,
i_port
);
snprintf
(
portbuf
,
sizeof
(
portbuf
),
"%u"
,
port
);
servname
=
portbuf
;
}
else
servname
=
NULL
;
/* Check if we have to force ipv4 or ipv6 */
memset
(
&
hints
,
0
,
sizeof
(
hints
));
...
...
@@ -164,7 +169,7 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
if
((
hints
.
ai_flags
&
AI_NUMERICHOST
)
==
0
)
{
hints
.
ai_flags
|=
AI_NUMERICHOST
;
ret
=
getaddrinfo
(
node
,
psz_servic
e
,
&
hints
,
res
);
ret
=
getaddrinfo
(
node
,
servnam
e
,
&
hints
,
res
);
if
(
ret
==
0
)
goto
out
;
hints
.
ai_flags
&=
~
AI_NUMERICHOST
;
...
...
@@ -173,13 +178,13 @@ int vlc_getaddrinfo( vlc_object_t *p_this, const char *node,
#ifdef AI_IDN
/* Run-time I18n Domain Names support */
hints
.
ai_flags
|=
AI_IDN
;
ret
=
getaddrinfo
(
node
,
psz_servic
e
,
&
hints
,
res
);
ret
=
getaddrinfo
(
node
,
servnam
e
,
&
hints
,
res
);
if
(
ret
!=
EAI_BADFLAGS
)
goto
out
;
/* IDN not available: disable and retry without it */
hints
.
ai_flags
&=
~
AI_IDN
;
#endif
ret
=
getaddrinfo
(
node
,
psz_servic
e
,
&
hints
,
res
);
ret
=
getaddrinfo
(
node
,
servnam
e
,
&
hints
,
res
);
#if defined(AI_IDN) || defined(WIN32)
out:
...
...
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