From 18fe3f95e7538365b4ba8b703b404117ed9507d4 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 20 Aug 2020 22:34:04 -0500 Subject: [PATCH] Bugfix: file change role invalid parameter on < -1. Having tests for "< -1" resulted in false positives for invalid parameters. It appears that the uid_t and gid_t types are unsigned. The value -1 is simply a special case use. --- level_0/f_file/c/file.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index b57f85a..9a61073 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -1513,8 +1513,7 @@ extern "C" { f_return_status f_file_role_change(const f_string path, const uid_t uid, const gid_t gid, const bool dereference) { #ifndef _di_level_0_parameter_checking_ if (path == 0) return F_status_set_error(F_parameter); - if (uid < 0 && gid < 0) return F_status_set_error(F_parameter); - if (uid < -1 || gid < -1) return F_status_set_error(F_parameter); + if (uid == -1 && gid == -1) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ return private_f_file_role_change(path, uid, gid, dereference); @@ -1525,8 +1524,7 @@ extern "C" { f_return_status f_file_role_change_at(const int at_id, const f_string path, const uid_t uid, const gid_t gid, const int flag) { #ifndef _di_level_0_parameter_checking_ if (path == 0) return F_status_set_error(F_parameter); - if (uid < 0 && gid < 0) return F_status_set_error(F_parameter); - if (uid < -1 || gid < -1) return F_status_set_error(F_parameter); + if (uid == -1 && gid == -1) return F_status_set_error(F_parameter); #endif // _di_level_0_parameter_checking_ return private_f_file_role_change_at(at_id, path, uid, gid, flag); -- 1.8.3.1