#9201 Covscan issues detected in ipa-otpd
Opened by frenaud. Modified

After running covscan against ipa 4.10, the following issues were detected that require inspection:

Error: OVERRUN (CWE-119):
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:341: identity_transfer: Passing "10240UL" as argument 3 to function "read", which returns that argument. [Note: The source code implementation of the function has been overridden by a builtin model.]
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:341: assignment: Assigning: "io" = "read(verto_get_fd(ev), buf, 10240UL)". The value of "io" is now 10240.
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:348: overrun-local: Overrunning array "buf" of 10240 bytes at byte offset 10240 using index "io" (which evaluates to 10240).
#  346|   
#  347|       if (io >= 0) {
#  348|->         buf[io] = '\0';
#  349|           otpd_log_req(child_ctx->item->req, "Received: [%s]", buf);
#  350|       }
Error: RESOURCE_LEAK (CWE-772): [#def32] [important]
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:447: alloc_fn: Storage is returned from allocation function "calloc".
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:447: var_assign: Assigning: "saved_item" = storage returned from "calloc(288UL, 1UL)".
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:456: leaked_storage: Variable "saved_item" going out of scope leaks the storage it points to.
#  454|           if (saved_item->oauth2.device_code_reply == NULL) {
#  455|               otpd_log_req((*item)->req, "Failed to copy device code reply");
#  456|->             return EINVAL;
#  457|           }
#  458|           krb5_free_data_contents(NULL, &data_state);
Error: RESOURCE_LEAK (CWE-772): [#def34] [important]
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:461: alloc_fn: Storage is returned from allocation function "calloc".
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:461: var_assign: Assigning: "child_ctx" = storage returned from "calloc(56UL, 1UL)".
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:613: leaked_storage: Variable "child_ctx" going out of scope leaks the storage it points to.
#  611|       }
#  612|   
#  613|->     return ret;
#  614|   }
Error: RESOURCE_LEAK (CWE-772): [#def35] [important]
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:447: alloc_fn: Storage is returned from allocation function "calloc".
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:447: var_assign: Assigning: "saved_item" = storage returned from "calloc(288UL, 1UL)".
freeipa-4.10.0/daemons/ipa-otpd/oauth2.c:613: leaked_storage: Variable "saved_item" going out of scope leaks the storage it points to.
#  611|       }
#  612|   
#  613|->     return ret;
#  614|   }
Error: PRINTF_ARGS (CWE-686): [#def37]
freeipa-4.10.0/daemons/ipa-otpd/stdio.c:169: invalid_type: Argument "item->sent" to format specifier "%d" was expected to have type "int" but has type "unsigned long".
#  167|       /* Send the packet. */
#  168|       data = krad_packet_encode(item->rsp);
#  169|->     otpd_log_req(item->req, "sent: %d data: %d", item->sent, data->length);
#  170|       i = write(verto_get_fd(ev), data->data + item->sent,
#  171|                 data->length - item->sent);
Error: PRINTF_ARGS (CWE-686): [#def38]
freeipa-4.10.0/daemons/ipa-otpd/stdio.c:195: invalid_type: Argument "item->sent" to format specifier "%d" was expected to have type "int" but has type "unsigned long".
#  193|       /* If the packet was completely sent, free the response. */
#  194|       item->sent += i;
#  195|->     otpd_log_req(item->req, "..sent: %d data: %d", item->sent, data->length);
#  196|       if (item->sent == data->length) {
#  197|           otpd_log_req(item->req, "response sent: %s",

Metadata