]> Kevux Git Server - fll/commitdiff
Security: Wrong sizeof() type used in controller allocation functions.
authorKevin Day <Kevin@kevux.org>
Sat, 1 Jun 2024 22:06:59 +0000 (17:06 -0500)
committerKevin Day <Kevin@kevux.org>
Sat, 1 Jun 2024 22:06:59 +0000 (17:06 -0500)
The controller_pids_resize() should be using pid_t instead of controller_rule_t.

The processs is an aray of controller_process_t pointers.

level_3/controller/c/common/private-process.c

index aa70c855cd22cb071c9639317ff5f89078dac61f..9d9d7427c94974f873558e4fac8b9a8427d389b8 100644 (file)
@@ -29,7 +29,7 @@ extern "C" {
 #ifndef _di_controller_pids_resize_
   f_status_t controller_pids_resize(const f_array_length_t length, controller_pids_t * const pids) {
 
-    const f_status_t status = f_memory_resize(pids->size, length, sizeof(controller_rule_t), (void **) & pids->array);
+    const f_status_t status = f_memory_resize(pids->size, length, sizeof(pid_t), (void **) & pids->array);
     if (F_status_is_error(status)) return status;
 
     pids->size = length;
@@ -106,7 +106,7 @@ extern "C" {
       if (processs->array[i]) {
         controller_process_delete_simple(processs->array[i]);
 
-        f_memory_delete(1, sizeof(f_array_length_t *), (void **) & processs->array[i]);
+        f_memory_delete(1, sizeof(controller_process_t *), (void **) & processs->array[i]);
       }
     } // for
 
@@ -119,7 +119,7 @@ extern "C" {
       // The lock must be initialized, but only once, so initialize immediately upon allocation.
       for (; processs->size < length; ++processs->size) {
 
-        status = f_memory_new(1, sizeof(controller_process_t), (void **) &processs->array[processs->size]);
+        status = f_memory_new(1, sizeof(controller_process_t *), (void **) &processs->array[processs->size]);
 
         if (F_status_is_error_not(status)) {
           process = processs->array[processs->size];