siva-msft / libgit2

Other
0 stars 1 forks source link

Potential issue in src/config_cache.c: Unchecked return from initialization function #12

Open monocle-ai opened 4 years ago

monocle-ai commented 4 years ago

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 : src/config_cache.c Enclosing Function : git_config__cvar Function : git_config__lookup_entry https://github.com/siva-msft/libgit2/blob/53d0ba4625cc355f03d925ec26fc92310dd89fee/src/config_cache.c#L89 Issue in: entry

Code extract:

    struct map_data *data = &_cvar_maps[(int)cvar];
    const git_config_entry *entry;

    git_config__lookup_entry(&entry, config, data->cvar_name, false); <------ HERE

    if (!entry)

How can I fix it? Correct reference usage found in src/remote.c at line 752. https://github.com/siva-msft/libgit2/blob/53d0ba4625cc355f03d925ec26fc92310dd89fee/src/remote.c#L752 Code extract:

    }

    /* http.proxy config setting */
    if ((error = git_config__lookup_entry(&ce, cfg, "http.proxy", false)) < 0) <------ HERE
        return error;
    if (ce && ce->value) {
siva-msft commented 4 years ago

rvnc.. calls get_entry