Return an error on invalid selabel_open(3) options, e.g. an option for a different backend was used. Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx> --- libselinux/src/label_backends_android.c | 7 +++++++ libselinux/src/label_db.c | 8 ++++++++ libselinux/src/label_file.c | 7 +++++++ libselinux/src/label_media.c | 7 +++++++ libselinux/src/label_x.c | 7 +++++++ 5 files changed, 36 insertions(+) diff --git a/libselinux/src/label_backends_android.c b/libselinux/src/label_backends_android.c index cd3875fc..7ddacdbe 100644 --- a/libselinux/src/label_backends_android.c +++ b/libselinux/src/label_backends_android.c @@ -157,6 +157,13 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, case SELABEL_OPT_PATH: path = opts[n].value; break; + case SELABEL_OPT_UNUSED: + case SELABEL_OPT_VALIDATE: + case SELABEL_OPT_DIGEST: + break; + default: + errno = EINVAL; + return -1; } if (!path) diff --git a/libselinux/src/label_db.c b/libselinux/src/label_db.c index 3f803037..2daf1770 100644 --- a/libselinux/src/label_db.c +++ b/libselinux/src/label_db.c @@ -268,6 +268,14 @@ db_init(const struct selinux_opt *opts, unsigned nopts, case SELABEL_OPT_PATH: path = opts[nopts].value; break; + case SELABEL_OPT_UNUSED: + case SELABEL_OPT_VALIDATE: + case SELABEL_OPT_DIGEST: + break; + default: + free(catalog); + errno = EINVAL; + return NULL; } } diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c index 4778f8f8..315298b3 100644 --- a/libselinux/src/label_file.c +++ b/libselinux/src/label_file.c @@ -812,6 +812,13 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, case SELABEL_OPT_BASEONLY: baseonly = !!opts[n].value; break; + case SELABEL_OPT_UNUSED: + case SELABEL_OPT_VALIDATE: + case SELABEL_OPT_DIGEST: + break; + default: + errno = EINVAL; + return -1; } #if !defined(BUILD_HOST) && !defined(ANDROID) diff --git a/libselinux/src/label_media.c b/libselinux/src/label_media.c index b3443b47..4c987988 100644 --- a/libselinux/src/label_media.c +++ b/libselinux/src/label_media.c @@ -85,6 +85,13 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, case SELABEL_OPT_PATH: path = opts[n].value; break; + case SELABEL_OPT_UNUSED: + case SELABEL_OPT_VALIDATE: + case SELABEL_OPT_DIGEST: + break; + default: + errno = EINVAL; + return -1; } /* Open the specification file. */ diff --git a/libselinux/src/label_x.c b/libselinux/src/label_x.c index e15190ca..f332dcb6 100644 --- a/libselinux/src/label_x.c +++ b/libselinux/src/label_x.c @@ -112,6 +112,13 @@ static int init(struct selabel_handle *rec, const struct selinux_opt *opts, case SELABEL_OPT_PATH: path = opts[n].value; break; + case SELABEL_OPT_UNUSED: + case SELABEL_OPT_VALIDATE: + case SELABEL_OPT_DIGEST: + break; + default: + errno = EINVAL; + return -1; } /* Open the specification file. */ -- 2.43.0