Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential security issue in lib/connect.c: Unchecked return from initialization function #5411

Closed
monocle-ai opened this issue May 18, 2020 · 0 comments

Comments

@monocle-ai
Copy link

@monocle-ai monocle-ai commented May 18, 2020

What is a Conditionally Uninitialized Variable? The return value of a function that is potentially used to initialize a local variable is not checked. Therefore, reading the local variable may result in undefined behavior.

1 instance of this defect were found in the following locations:

Instance 1
File : lib/connect.c
Function: Curl_printable_address

Curl_printable_address(conn->tempaddr[i], ipaddress, MAX_IPADR_LEN);

Code extract:

#ifndef CURL_DISABLE_VERBOSE_STRINGS
        char ipaddress[MAX_IPADR_LEN];
        char buffer[STRERROR_LEN];
        Curl_printable_address(conn->tempaddr[i], ipaddress, MAX_IPADR_LEN); <------ HERE
#endif
        infof(data, "connect to %s port %ld failed: %s\n",

How can I fix it?
Correct reference usage found in lib/socks.c at line 785.

if(Curl_printable_address(hp, dest, sizeof(dest))) {

Code extract:

      return CURLE_COULDNT_RESOLVE_HOST;
    }

    if(Curl_printable_address(hp, dest, sizeof(dest))) { <------ HERE
      size_t destlen = strlen(dest);
      msnprintf(dest + destlen, sizeof(dest) - destlen, ":%d", remote_port);
bagder added a commit that referenced this issue May 18, 2020
It was not used much anyway and instead we let it store a blank buffer
in case of failure.

Reported-by: MonocleAI
Fixes #5411
@bagder bagder closed this in 67521b5 May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

1 participant
You can’t perform that action at this time.