Skip to content

Potential NULL pointer dereference bug in callInternal() #247

Closed as not planned
@hariramshankar

Description

@hariramshankar

In the function callInternal(), client->client->dataReceived is dereferenced unconditionally before it is checked for NULL:
https://github.com/kubernetes-client/c/blob/master/kubernetes/src/generic.c#L62

char* callInternal(genericClient_t *client,
                   const char *path, list_t *queryParameters, list_t *headerParameters, list_t *formParameters, list_t *headerType, list_t *contentType, const char *body, const char *method)
{
    apiClient_invoke(client->client, path, queryParameters, headerParameters, formParameters, headerType, contentType, body, method);

    if (client->client->response_code == 401) {
        return NULL;
    }
    char* elementToReturn =  strndup((char*)client->client->dataReceived, client->client->dataReceivedLen); <<<<<<

    if (client->client->dataReceived) {
        free(client->client->dataReceived);
        client->client->dataReceived = NULL;
        client->client->dataReceivedLen = 0;
    }

    return elementToReturn;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions