Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
ca86e91d
Commit
ca86e91d
authored
Feb 22, 2015
by
Michael Niedermayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/trasher: Check fseek returns
Fixes CID733726 Signed-off-by:
Michael Niedermayer
<
michaelni@gmx.at
>
parent
c3b6454d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
+12
-6
trasher.c
tools/trasher.c
+12
-6
No files found.
tools/trasher.c
View file @
ca86e91d
...
...
@@ -30,6 +30,15 @@ static uint32_t ran(void)
return
state
=
state
*
1664525
+
1013904223
;
}
static
void
checked_seek
(
FILE
*
stream
,
int64_t
offset
,
int
whence
)
{
offset
=
fseek
(
stream
,
offset
,
whence
);
if
(
offset
<
0
)
{
fprintf
(
stderr
,
"seek failed
\n
"
);
exit
(
1
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
FILE
*
f
;
...
...
@@ -49,17 +58,14 @@ int main(int argc, char **argv)
maxburst
=
atoi
(
argv
[
3
]);
state
=
atoi
(
argv
[
4
]);
f
seek
(
f
,
0
,
SEEK_END
);
checked_
seek
(
f
,
0
,
SEEK_END
);
length
=
ftell
(
f
);
f
seek
(
f
,
0
,
SEEK_SET
);
checked_
seek
(
f
,
0
,
SEEK_SET
);
while
(
count
--
)
{
int
burst
=
1
+
ran
()
*
(
uint64_t
)
(
abs
(
maxburst
)
-
1
)
/
UINT32_MAX
;
int
pos
=
ran
()
*
(
uint64_t
)
length
/
UINT32_MAX
;
if
(
fseek
(
f
,
pos
,
SEEK_SET
)
<
0
)
{
fprintf
(
stderr
,
"seek failed
\n
"
);
return
1
;
}
checked_seek
(
f
,
pos
,
SEEK_SET
);
if
(
maxburst
<
0
)
burst
=
-
maxburst
;
...
...
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