Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linux-davinci-2.6.23
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
linux
linux-davinci-2.6.23
Commits
0ba7a3ba
Commit
0ba7a3ba
authored
Sep 09, 2005
by
Arnaldo Carvalho de Melo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CCID3] Avoid unsigned integer overflows in usecs_div
Signed-off-by:
Arnaldo Carvalho de Melo
<
acme@mandriva.com
>
parent
e104411b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
3 deletions
+13
-3
net/dccp/ccids/ccid3.c
net/dccp/ccids/ccid3.c
+13
-3
No files found.
net/dccp/ccids/ccid3.c
View file @
0ba7a3ba
...
@@ -43,12 +43,22 @@
...
@@ -43,12 +43,22 @@
#include "ccid3.h"
#include "ccid3.h"
/*
/*
* Reason for maths with 10 here is to avoid 32 bit overflow when a is big.
* Reason for maths here is to avoid 32 bit overflow when a is big.
* With this we get close to the limit.
*/
*/
static
inline
u32
usecs_div
(
const
u32
a
,
const
u32
b
)
static
inline
u32
usecs_div
(
const
u32
a
,
const
u32
b
)
{
{
const
u32
tmp
=
a
*
(
USEC_PER_SEC
/
10
);
const
u32
div
=
a
<
(
UINT_MAX
/
(
USEC_PER_SEC
/
10
))
?
10
:
return
b
>
20
?
tmp
/
(
b
/
10
)
:
tmp
;
a
<
(
UINT_MAX
/
(
USEC_PER_SEC
/
50
))
?
50
:
a
<
(
UINT_MAX
/
(
USEC_PER_SEC
/
100
))
?
100
:
a
<
(
UINT_MAX
/
(
USEC_PER_SEC
/
500
))
?
500
:
a
<
(
UINT_MAX
/
(
USEC_PER_SEC
/
1000
))
?
1000
:
a
<
(
UINT_MAX
/
(
USEC_PER_SEC
/
5000
))
?
5000
:
a
<
(
UINT_MAX
/
(
USEC_PER_SEC
/
10000
))
?
10000
:
a
<
(
UINT_MAX
/
(
USEC_PER_SEC
/
50000
))
?
50000
:
100000
;
const
u32
tmp
=
a
*
(
USEC_PER_SEC
/
div
);
return
(
b
>=
2
*
div
)
?
tmp
/
(
b
/
div
)
:
tmp
;
}
}
static
int
ccid3_debug
;
static
int
ccid3_debug
;
...
...
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