siva-msft / libgit2

Other
0 stars 1 forks source link

Potential issue in src/diff.c: Unchecked return from initialization function #13

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

Code extract:

    /* if ignore_submodules not explicitly set, check diff config */
    if (diff->opts.ignore_submodules <= 0) {
        const git_config_entry *entry;
        git_config__lookup_entry(&entry, cfg, "diff.ignoresubmodules", true); <------ HERE

        if (entry && git_submodule_parse_ignore(

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