libsepol: Check for embedded NUL when reading from policy file
PATCH 1/1 libsepol: Check for embedded NUL when reading from policy file
Check that data read from a policy file does not have an embedded NUL to protect against maliciously crafted polcies.
Signed-off-by James Carter <[email protected]>
--- libsepol/src/services.c | 6 ++++++ 1 file changed, 6 insertions(+)
libsepol/src/services.c +6 -0
@@ -1799,6 +1799,12 @@ int str_read(char **strp, struct policy_file *fp, size_t len)if (rc)return rc; +/* Check for an embedded NUL character */ +if (memchr (str,'\0' , len)) { + errno =EINVAL ; +return -1 ; + } + str[len] ='\0' ;return 0 ; }
Signature · 1 line
2.55.0
Quoted 3 lines · James Carter
Check that data read from a policy file does not have an embedded NUL to protect against maliciously crafted polcies.
policies
Quoted 2 lines
Signed-off-by James Carter <[email protected]>
Otherwise,
Acked-by Stephen Smalley <[email protected]>
Quoted 24 lines
--- libsepol/src/services.c | 6 ++++++ 1 file changed, 6 insertions(+)libsepol/src/services.c +6
-1@@ -1799,6 +1799,12 @@ int str_read(char **strp, struct policy_file *fp, size_t len)if (rc)return rc; +/* Check for an embedded NUL character */ +if (memchr (str,'\0' , len)) { + errno =EINVAL ; +return -1 ; + } + str[len] ='\0' ;return 0 ; } --2.55.0
Stephen Smalley
maintainerQuoted 6 lines · Stephen Smalley
Quoted 3 lines · James Carter
Check that data read from a policy file does not have an embedded NUL to protect against maliciously crafted polcies.
Quoted 7 lines
policies
Quoted 2 lines
Signed-off-by James Carter <[email protected]>Otherwise,
Acked-by Stephen Smalley <[email protected]>
Merged.
Quoted 25 lines
Quoted 25 lines
--- libsepol/src/services.c | 6 ++++++ 1 file changed, 6 insertions(+)libsepol/src/services.c +6
-1@@ -1799,6 +1799,12 @@ int str_read(char **strp, struct policy_file *fp, size_t len)if (rc)return rc; +/* Check for an embedded NUL character */ +if (memchr (str,'\0' , len)) { + errno =EINVAL ; +return -1 ; + } + str[len] ='\0' ;return 0 ; } --2.55.0