]> Kevux Git Server - fll/commitdiff
Bugfix: The uid_t and gid_t should be initialized to -1 and not 0.
authorKevin Day <Kevin@kevux.org>
Sat, 8 Feb 2025 21:48:37 +0000 (15:48 -0600)
committerKevin Day <Kevin@kevux.org>
Sat, 8 Feb 2025 22:31:13 +0000 (16:31 -0600)
level_0/f_account/c/account/common.h
level_0/f_account/tests/unit/c/test-account-by_id.c
level_0/f_account/tests/unit/c/test-account-group_id_by_name.c
level_0/f_account/tests/unit/c/test-account-group_name_by_id.c
level_0/f_account/tests/unit/c/test-account-id_by_name.c
level_0/f_account/tests/unit/c/test-account-name_by_id.c
level_0/f_capability/tests/unit/c/test-capability-owner_set.c
level_0/f_capability/tests/unit/c/test-capability-user_set.c
level_0/f_file/tests/unit/c/test-file-group_read.c
level_3/fake/c/private-make-operate_process_type.c
level_3/fake/c/private-make-operate_validate_type.c

index 8e980a7ed484207699efdbae2379613473d7f9cd..c1d732ae510812f2c43898317c25f051e70ae394 100644 (file)
@@ -52,8 +52,8 @@ extern "C" {
   } f_account_t;
 
   #define f_account_t_initialize { \
-    0, \
-    0, \
+    -1, \
+    -1, \
     f_string_dynamic_t_initialize, \
     f_string_dynamic_t_initialize, \
     f_string_dynamic_t_initialize, \
@@ -62,8 +62,8 @@ extern "C" {
   }
 
   #define macro_f_account_t_clear(account) \
-    account.id_user = 0; \
-    account.id_group = 0; \
+    account.id_user = -1; \
+    account.id_group = -1; \
     macro_f_account_t_clear(account.home); \
     macro_f_account_t_clear(account.label); \
     macro_f_account_t_clear(account.name); \
index 317ba1125da4796a5988d6f6727d3e333886f913..9c0e3e29e471f0713ba0895c0f441380bf7f798b 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 void test__f_account_by_id__fails(void **state) {
 
   const long size = 20;
-  uid_t uid = 0;
+  uid_t uid = -1;
   f_account_t account = f_account_t_initialize;
 
   int errnos[] = {
@@ -49,7 +49,7 @@ void test__f_account_by_id__not_found(void **state) {
 
   const long size = 20;
   struct passwd password;
-  uid_t uid = 0;
+  uid_t uid = -1;
   f_account_t account = f_account_t_initialize;
 
   {
index 1700f455b7efbd1206ecbb5eb1f51e9fc022d817..932754eafdb9f84fe579309c0229301a59c2d47c 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 void test__f_account_group_id_by_name__fails(void **state) {
 
   const long size = 20;
-  gid_t gid = 0;
+  gid_t gid = -1;
 
   f_string_t name_string = "name";
   f_string_static_t name = f_string_static_t_initialize;
@@ -51,7 +51,7 @@ void test__f_account_group_id_by_name__not_found(void **state) {
 
   const long size = 20;
   struct group group_data;
-  gid_t gid = 0;
+  gid_t gid = -1;
 
   f_string_t name_string = "name";
   f_string_static_t name = f_string_static_t_initialize;
@@ -87,7 +87,7 @@ void test__f_account_group_id_by_name__works(void **state) {
   struct group group_data;
   struct group pointer;
   char *pointers[] = { "gr_mem", 0 };
-  gid_t gid = 0;
+  gid_t gid = -1;
 
   f_string_static_t name = f_string_static_t_initialize;
 
index 30093137113568be89874d37f68e26925a8e26e2..d599a1095e801876130f01fee820aa1457ad6d9d 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 void test__f_account_group_name_by_id__fails(void **state) {
 
   const long size = 20;
-  gid_t gid = 0;
+  gid_t gid = -1;
   f_string_dynamic_t name = f_string_dynamic_t_initialize;
 
   int errnos[] = {
@@ -49,7 +49,7 @@ void test__f_account_group_name_by_id__not_found(void **state) {
 
   const long size = 20;
   struct group group_data;
-  gid_t gid = 0;
+  gid_t gid = -1;
   f_string_dynamic_t name = f_string_dynamic_t_initialize;
 
   {
@@ -81,7 +81,7 @@ void test__f_account_group_name_by_id__works(void **state) {
   struct group group_data;
   struct group pointer;
   char *pointers[] = { "gr_mem", 0 };
-  gid_t gid = 0;
+  gid_t gid = -1;
   f_string_dynamic_t name = f_string_dynamic_t_initialize;
 
   group_data.gr_gid = 1;
index 2d710322ce65518f0b32abe62a7d1b4aa0b626ee..8eeaaf36a2537dd3aa11135541be928fd0e5114e 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 void test__f_account_id_by_name__fails(void **state) {
 
   const long size = 20;
-  uid_t uid = 0;
+  uid_t uid = -1;
 
   f_string_t name_string = "name";
   f_string_static_t name = f_string_static_t_initialize;
@@ -51,7 +51,7 @@ void test__f_account_id_by_name__not_found(void **state) {
 
   const long size = 20;
   struct passwd password;
-  uid_t uid = 0;
+  uid_t uid = -1;
 
   f_string_t name_string = "name";
   f_string_static_t name = f_string_static_t_initialize;
@@ -86,7 +86,7 @@ void test__f_account_id_by_name__works(void **state) {
   const long size = 20;
   struct passwd password;
   struct passwd pointer;
-  uid_t uid = 0;
+  uid_t uid = -1;
 
   f_string_static_t name = f_string_static_t_initialize;
 
index e8bf6d9a589fff023fc95e39beb0fe659e3f05ec..ef3f012896ddc5c56064116f4c7fd05ad7d88bfb 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 void test__f_account_name_by_id__fails(void **state) {
 
   const long size = 20;
-  uid_t uid = 0;
+  uid_t uid = -1;
   f_string_dynamic_t name = f_string_dynamic_t_initialize;
 
   int errnos[] = {
@@ -49,7 +49,7 @@ void test__f_account_name_by_id__not_found(void **state) {
 
   const long size = 20;
   struct passwd password;
-  uid_t uid = 0;
+  uid_t uid = -1;
   f_string_dynamic_t name = f_string_dynamic_t_initialize;
 
   {
@@ -80,7 +80,7 @@ void test__f_account_name_by_id__works(void **state) {
   const long size = 20;
   struct passwd password;
   struct passwd pointer;
-  uid_t uid = 0;
+  uid_t uid = -1;
   f_string_dynamic_t name = f_string_dynamic_t_initialize;
 
   password.pw_uid = 1;
index 74334f2defca15e723de276ff3c75408c0386d60..c45f6959a62cf1fe2cf29b47864a5146074497d3 100644 (file)
@@ -9,7 +9,7 @@ void test__f_capability_owner_set__fails(void **state) {
 
   #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
     const f_capability_t capability = f_capability_t_initialize;
-    const uid_t id;
+    const uid_t id = -1;
 
     int errnos[] = {
       EACCES,
@@ -50,7 +50,7 @@ void test__f_capability_owner_set__fails(void **state) {
 void test__f_capability_owner_set__works(void **state) {
 
   const f_capability_t capability = f_capability_t_initialize;
-  const uid_t id = 0;
+  const uid_t id = -1;
 
   #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
     printf("[  WARN    ] f_capability_owner_set() is not implemented and cannot be fully tested.\n");
index 038eba37afd94fdb860d36d152fb81c44b292dd1..0de3ae268d2a047588f9d090f310c0eded7c3d78 100644 (file)
@@ -7,7 +7,7 @@ extern "C" {
 
 void test__f_capability_user_set__works(void **state) {
 
-  const uid_t uid = 0;
+  const uid_t uid = -1;
 
   #if defined(_di_libcap_) || defined(_libcap_legacy_only_)
     printf("[  WARN    ] f_capability_user_set() is not implemented and cannot be fully tested.\n");
@@ -29,7 +29,7 @@ void test__f_capability_user_set__works(void **state) {
 void test__f_capability_user_set__fails(void **state) {
 
   #if !defined(_di_libcap_) && !defined(_libcap_legacy_only_)
-    const uid_t uid = 0;
+    const uid_t uid = -1;
 
     int errnos[] = {
       EINVAL,
index 516de7cce6bcb74e07c31e4ddefa928193a36f82..7c7f5e9ddc6a8474520adcd846cb829a4b0d1867 100644 (file)
@@ -35,7 +35,7 @@ void test__f_file_group_read__fails(void **state) {
 
   for (int i = 0; i < 9; ++i) {
 
-    gid_t id = 0;
+    gid_t id = -1;
 
     will_return(__wrap_stat, true);
     will_return(__wrap_stat, errnos[i]);
@@ -58,7 +58,7 @@ void test__f_file_group_read__parameter_checking(void **state) {
 void test__f_file_group_read__returns_data_not(void **state) {
 
   {
-    gid_t id = 0;
+    gid_t id = -1;
 
     const f_status_t status = f_file_group_read(f_string_empty_s, F_false, &id);
 
@@ -71,7 +71,7 @@ void test__f_file_group_read__works(void **state) {
   const f_string_static_t path = macro_f_string_static_t_initialize("test", 0, 4);
 
   {
-    gid_t id = 0;
+    gid_t id = -1;
 
     struct stat statistics;
 
index cf9bf1a1353193baeadf7d9cf6938bce4c4d27e4..2a081f7bf04d7ee6e8860f78e2acc0d3c798ae14 100644 (file)
@@ -545,7 +545,7 @@ extern "C" {
 
     f_status_t status = F_none;
 
-    gid_t id = 0;
+    gid_t id = -1;
     bool dereference = F_true;
     f_array_length_t i = 0;
 
@@ -958,7 +958,7 @@ extern "C" {
   f_status_t fake_make_operate_process_type_if_group(fake_make_data_t * const data_make, const bool if_not, fake_state_process_t *state_process) {
 
     f_status_t status = F_none;
-    uid_t id = 0;
+    uid_t id = -1;
     f_array_length_t i = if_not ? 2 : 1;
     bool dereference = F_true;
 
@@ -1105,7 +1105,7 @@ extern "C" {
   f_status_t fake_make_operate_process_type_if_owner(fake_make_data_t * const data_make, const bool if_not, fake_state_process_t *state_process) {
 
     f_status_t status = F_none;
-    uid_t id = 0;
+    uid_t id = -1;
     f_array_length_t i = if_not ? 2 : 1;
     bool dereference = F_true;
 
@@ -1558,7 +1558,7 @@ extern "C" {
 #ifndef _di_fake_make_operate_process_type_owners_
   f_status_t fake_make_operate_process_type_owners(fake_make_data_t * const data_make, const bool all) {
 
-    uid_t id = 0;
+    uid_t id = -1;
     bool dereference = F_true;
     f_array_length_t i = 0;
 
index 2b7c71c6006741ead7171f0d5debd5304b84aa5d..6b7c2650aa9123a1d12ef2eb62282b0bc21aa3c1 100644 (file)
@@ -535,7 +535,7 @@ extern "C" {
             i = ++k;
           }
           else if (state_process->condition == fake_make_operation_if_type_if_group_e || state_process->condition == fake_make_operation_if_type_if_not_group_e) {
-            gid_t id = 0;
+            gid_t id = -1;
 
             if (F_status_is_error(fake_make_get_id_group(data_make->data, data_make->error, data_make->cache_arguments.array[k++], &id))) {
               return F_status_set_error(F_failure);
@@ -598,7 +598,7 @@ extern "C" {
             if (type_file & 0x80) return F_status_set_error(F_failure);
           }
           else if (state_process->condition == fake_make_operation_if_type_if_owner_e || state_process->condition == fake_make_operation_if_type_if_not_owner_e) {
-            uid_t id = 0;
+            uid_t id = -1;
 
             if (F_status_is_error(fake_make_get_id_owner(data_make->data, data_make->error, data_make->cache_arguments.array[k++], &id))) {
               return F_status_set_error(F_failure);