libsepol/cil: Add check for too large of file size
PATCH 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]>
--- 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" ); +return SEPOL_ERR ; + } + buffer =cil_malloc (size +2 );memcpy (buffer, data, size);memset (buffer + size,0 ,2 );
Signature · 1 line
2.54.0
Quoted 13 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]>--- libsepol/cil/src/cil.c | 5 +++++ 1 file changed, 5 insertions(+)libsepol/cil/src/cil.c +0
-0
libsepol/cil/src/cil.c int cil_add_file(cil_db_t *db, const char *name, const char *data, size_t size) · line 553
Quoted 5 lines
libsepol/cil/src/cil.c +2
-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" );
Missing newline but otherwise
Acked-by Stephen Smalley <[email protected]>
Quoted 10 lines
libsepol/cil/src/cil.c +3
-1+return SEPOL_ERR ; + } + buffer =cil_malloc (size +2 );memcpy (buffer, data, size);memset (buffer + size,0 ,2 ); --2.54.0