Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jean-Baptiste Kempf
libaacs
Commits
bdd3f429
Commit
bdd3f429
authored
Apr 28, 2015
by
npzacs
Browse files
Limit file read size
parent
28af032c
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/file/file_posix.c
View file @
bdd3f429
...
...
@@ -31,6 +31,7 @@
#include
"util/logging.h"
#include
<stdio.h>
#include
<inttypes.h>
#include
<stdlib.h>
static
void
file_close_linux
(
AACS_FILE_H
*
file
)
...
...
@@ -64,6 +65,11 @@ static int64_t file_tell_linux(AACS_FILE_H *file)
static
int64_t
file_read_linux
(
AACS_FILE_H
*
file
,
uint8_t
*
buf
,
int64_t
size
)
{
if
(
size
<=
0
||
size
>=
BD_MAX_SSIZE
)
{
BD_DEBUG
(
DBG_FILE
|
DBG_CRIT
,
"Ignoring invalid read of size %"
PRId64
" (%p)
\n
"
,
size
,
(
void
*
)
file
);
return
0
;
}
return
fread
(
buf
,
1
,
size
,
(
FILE
*
)
file
->
internal
);
}
...
...
src/util/macro.h
View file @
bdd3f429
...
...
@@ -30,4 +30,6 @@
#define X_FREE(X) ( free(X), X = NULL )
#define BD_MAX_SSIZE ((int64_t)(((size_t)-1)>>1))
#endif
/* MACRO_H_ */
Write
Preview
Supports
Markdown
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