libsepol/cil: Add check for too large of file size
PATCH v2 1/1 libsepol/cil: Add check for too large of file size
In cil_add_file() add a check for a file size that is too large.
Signed-off-by James Carter <[email protected]>
---
v2: Add '\n' to end of log message
libsepol/cil/src/cil.c | 5 +++++ 1 file changed, 5 insertions(+)
libsepol/cil/src/cil.c +5 -0
@@ -549,6 +549,11 @@ int cil_add_file(cil_db_t *db, const char *name, const char *data, size_t size)cil_log (CIL_INFO ,"Parsing %s\n" , name); +if (size >SIZE_MAX -2 ) { +cil_log (CIL_ERR ,"File size is too large\n" ); +return SEPOL_ERR ; + } + buffer =cil_malloc (size +2 );memcpy (buffer, data, size);memset (buffer + size,0 ,2 );
Signature · 1 line
2.54.0
Quoted 4 lines · James Carter
In
cil_add_file()add a check for a file size that is too large.Signed-off-by James Carter <[email protected]>
Acked-by Stephen Smalley <[email protected]>
Quoted 26 lines
---
v2: Add '\n' to end of log messagelibsepol/cil/src/cil.c | 5 +++++ 1 file changed, 5 insertions(+)libsepol/cil/src/cil.c +5
-1@@ -549,6 +549,11 @@ int cil_add_file(cil_db_t *db, const char *name, const char *data, size_t size)cil_log (CIL_INFO ,"Parsing %s\n" , name); +if (size >SIZE_MAX -2 ) { +cil_log (CIL_ERR ,"File size is too large\n" ); +return SEPOL_ERR ; + } + buffer =cil_malloc (size +2 );memcpy (buffer, data, size);memset (buffer + size,0 ,2 ); --2.54.0
Quoted 9 lines · Stephen Smalley
Quoted 4 lines · James Carter
In
cil_add_file()add a check for a file size that is too large.Signed-off-by James Carter <[email protected]>Acked-by Stephen Smalley <[email protected]>
Merged.
Jim
Quoted 26 lines
Quoted 26 lines
---
v2: Add '\n' to end of log messagelibsepol/cil/src/cil.c | 5 +++++ 1 file changed, 5 insertions(+)libsepol/cil/src/cil.c +5
-1@@ -549,6 +549,11 @@ int cil_add_file(cil_db_t *db, const char *name, const char *data, size_t size)cil_log (CIL_INFO ,"Parsing %s\n" , name); +if (size >SIZE_MAX -2 ) { +cil_log (CIL_ERR ,"File size is too large\n" ); +return SEPOL_ERR ; + } + buffer =cil_malloc (size +2 );memcpy (buffer, data, size);memset (buffer + size,0 ,2 ); --2.54.0