Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
9a2da0bb
Commit
9a2da0bb
authored
11 years ago
by
Tristan Matthews
Browse files
Options
Downloads
Patches
Plain Diff
* #28529: daemon: better validation of port ranges
parent
63c7ba0a
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/sip/sipaccount.cpp
+22
-23
22 additions, 23 deletions
daemon/src/sip/sipaccount.cpp
daemon/src/sip/sipaccount.h
+2
-1
2 additions, 1 deletion
daemon/src/sip/sipaccount.h
with
24 additions
and
24 deletions
daemon/src/sip/sipaccount.cpp
+
22
−
23
View file @
9a2da0bb
...
@@ -66,7 +66,7 @@ const char *const TRUE_STR = "true";
...
@@ -66,7 +66,7 @@ const char *const TRUE_STR = "true";
const
char
*
const
FALSE_STR
=
"false"
;
const
char
*
const
FALSE_STR
=
"false"
;
}
}
bool
SIPAccount
::
portsInUse_
[
1
<<
16
];
bool
SIPAccount
::
portsInUse_
[
MAX_PORT
];
SIPAccount
::
SIPAccount
(
const
std
::
string
&
accountID
)
SIPAccount
::
SIPAccount
(
const
std
::
string
&
accountID
)
:
Account
(
accountID
)
:
Account
(
accountID
)
...
@@ -121,7 +121,7 @@ SIPAccount::SIPAccount(const std::string& accountID)
...
@@ -121,7 +121,7 @@ SIPAccount::SIPAccount(const std::string& accountID)
,
via_addr_
()
,
via_addr_
()
,
audioPortRange_
({
16384
,
32766
})
,
audioPortRange_
({
16384
,
32766
})
#ifdef SFL_VIDEO
#ifdef SFL_VIDEO
,
videoPortRange_
({
49152
,
(
1
<<
16
)
-
2
})
,
videoPortRange_
({
49152
,
(
MAX_PORT
)
-
2
})
#endif
#endif
{
{
via_addr_
.
host
.
ptr
=
0
;
via_addr_
.
host
.
ptr
=
0
;
...
@@ -152,18 +152,23 @@ serializeRange(Conf::MappingNode &accountMap, const char *minKey, const char *ma
...
@@ -152,18 +152,23 @@ serializeRange(Conf::MappingNode &accountMap, const char *minKey, const char *ma
return
result
;
return
result
;
}
}
void
updateRange
(
int
min
,
int
max
,
std
::
pair
<
uint16_t
,
uint16_t
>
&
range
)
{
if
(
min
>
0
and
(
max
>
min
)
and
max
<=
MAX_PORT
-
2
)
{
range
.
first
=
min
;
range
.
second
=
max
;
}
}
void
void
unserializeRange
(
const
Conf
::
YamlNode
&
mapNode
,
const
char
*
minKey
,
const
char
*
maxKey
,
std
::
pair
<
uint16_t
,
uint16_t
>
&
range
)
unserializeRange
(
const
Conf
::
YamlNode
&
mapNode
,
const
char
*
minKey
,
const
char
*
maxKey
,
std
::
pair
<
uint16_t
,
uint16_t
>
&
range
)
{
{
int
tmp
=
0
;
int
tmpMin
=
0
;
mapNode
.
getValue
(
minKey
,
&
tmp
);
int
tmpMax
=
0
;
mapNode
.
getValue
(
minKey
,
&
tmpMin
);
if
(
tmp
)
mapNode
.
getValue
(
maxKey
,
&
tmpMax
);
range
.
first
=
tmp
;
updateRange
(
tmpMin
,
tmpMax
,
range
);
mapNode
.
getValue
(
maxKey
,
&
tmp
);
if
(
tmp
)
range
.
second
=
tmp
;
}
}
}
}
...
@@ -577,19 +582,13 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details)
...
@@ -577,19 +582,13 @@ void SIPAccount::setAccountDetails(std::map<std::string, std::string> details)
userAgent_
=
details
[
CONFIG_ACCOUNT_USERAGENT
];
userAgent_
=
details
[
CONFIG_ACCOUNT_USERAGENT
];
keepAliveEnabled_
=
details
[
CONFIG_KEEP_ALIVE_ENABLED
]
==
TRUE_STR
;
keepAliveEnabled_
=
details
[
CONFIG_KEEP_ALIVE_ENABLED
]
==
TRUE_STR
;
int
tmp
=
atoi
(
details
[
CONFIG_ACCOUNT_AUDIO_PORT_MIN
].
c_str
());
int
tmpMin
=
atoi
(
details
[
CONFIG_ACCOUNT_AUDIO_PORT_MIN
].
c_str
());
if
(
tmp
>
0
)
int
tmpMax
=
atoi
(
details
[
CONFIG_ACCOUNT_AUDIO_PORT_MAX
].
c_str
());
audioPortRange_
.
first
=
tmp
;
updateRange
(
tmpMin
,
tmpMax
,
audioPortRange_
);
tmp
=
atoi
(
details
[
CONFIG_ACCOUNT_AUDIO_PORT_MAX
].
c_str
());
if
(
tmp
>
0
)
audioPortRange_
.
second
=
tmp
;
#ifdef SFL_VIDEO
#ifdef SFL_VIDEO
tmp
=
atoi
(
details
[
CONFIG_ACCOUNT_VIDEO_PORT_MIN
].
c_str
());
tmpMin
=
atoi
(
details
[
CONFIG_ACCOUNT_VIDEO_PORT_MIN
].
c_str
());
if
(
tmp
>
0
)
tmpMax
=
atoi
(
details
[
CONFIG_ACCOUNT_VIDEO_PORT_MAX
].
c_str
());
videoPortRange_
.
first
=
tmp
;
updateRange
(
tmpMin
,
tmpMax
,
videoPortRange_
);
tmp
=
atoi
(
details
[
CONFIG_ACCOUNT_VIDEO_PORT_MAX
].
c_str
());
if
(
tmp
>
0
)
videoPortRange_
.
second
=
tmp
;
#endif
#endif
// srtp settings
// srtp settings
...
...
This diff is collapsed.
Click to expand it.
daemon/src/sip/sipaccount.h
+
2
−
1
View file @
9a2da0bb
...
@@ -104,6 +104,7 @@ class SIPVoIPLink;
...
@@ -104,6 +104,7 @@ class SIPVoIPLink;
* @file sipaccount.h
* @file sipaccount.h
* @brief A SIP Account specify SIP specific functions and object = SIPCall/SIPVoIPLink)
* @brief A SIP Account specify SIP specific functions and object = SIPCall/SIPVoIPLink)
*/
*/
enum
{
MAX_PORT
=
65536
};
class
SIPAccount
:
public
Account
{
class
SIPAccount
:
public
Account
{
public:
public:
...
@@ -788,7 +789,7 @@ class SIPAccount : public Account {
...
@@ -788,7 +789,7 @@ class SIPAccount : public Account {
*/
*/
std
::
pair
<
uint16_t
,
uint16_t
>
videoPortRange_
;
std
::
pair
<
uint16_t
,
uint16_t
>
videoPortRange_
;
#endif
#endif
static
bool
portsInUse_
[
1
<<
16
];
static
bool
portsInUse_
[
MAX_PORT
];
static
uint16_t
getRandomEvenNumber
(
const
std
::
pair
<
uint16_t
,
uint16_t
>
&
range
);
static
uint16_t
getRandomEvenNumber
(
const
std
::
pair
<
uint16_t
,
uint16_t
>
&
range
);
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment