Commit b643501d by Carlos Martín Nieto

Merge pull request #3614 from pks-t/pks/coverity-fixes

Coverity fixes
parents c1b75f05 8a62bf11
......@@ -6,3 +6,22 @@
*/
#nodef GITERR_CHECK_ALLOC(ptr) if (ptr == NULL) { __coverity_panic__(); }
#nodef GITERR_CHECK_ALLOC_ADD(out, one, two) \
if (GIT_ADD_SIZET_OVERFLOW(out, one, two)) { __coverity_panic__(); }
#nodef GITERR_CHECK_ALLOC_ADD3(out, one, two, three) \
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), three)) { __coverity_panic__(); }
#nodef GITERR_CHECK_ALLOC_ADD4(out, one, two, three, four) \
if (GIT_ADD_SIZET_OVERFLOW(out, one, two) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), three) || \
GIT_ADD_SIZET_OVERFLOW(out, *(out), four)) { __coverity_panic__(); }
#nodef GITERR_CHECK_ALLOC_MULTIPLY(out, nelem, elsize) \
if (GIT_MULTIPLY_SIZET_OVERFLOW(out, nelem, elsize)) { __coverity_panic__(); }
#nodef GITERR_CHECK_VERSION(S,V,N) if (giterr__check_version(S,V,N) < 0) { __coverity_panic__(); }
#nodef LOOKS_LIKE_DRIVE_PREFIX(S) (strlen(S) >= 2 && git__isalpha((S)[0]) && (S)[1] == ':')
......@@ -261,6 +261,10 @@ int gitno_extract_url_parts(
*path = git__substrdup(_path, u.field_data[UF_PATH].len);
GITERR_CHECK_ALLOC(*path);
} else {
git__free(*port);
*port = NULL;
git__free(*host);
*host = NULL;
giterr_set(GITERR_NET, "invalid url, missing path");
return GIT_EINVALIDSPEC;
}
......
......@@ -79,10 +79,9 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
GITERR_CHECK_ALLOC(p);
p->name = extract_trimmed(name, strlen(name));
GITERR_CHECK_ALLOC(p->name);
p->email = extract_trimmed(email, strlen(email));
if (p->name == NULL || p->email == NULL)
return -1; /* oom */
GITERR_CHECK_ALLOC(p->email);
if (p->name[0] == '\0' || p->email[0] == '\0') {
git_signature_free(p);
......
......@@ -271,6 +271,7 @@ static int ok_pkt(git_pkt **out, const char *line, size_t len)
line += 3; /* skip "ok " */
if (!(ptr = strchr(line, '\n'))) {
giterr_set(GITERR_NET, "Invalid packet line");
git__free(pkt);
return -1;
}
len = ptr - line;
......@@ -314,6 +315,8 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
line = ptr + 1;
if (!(ptr = strchr(line, '\n'))) {
giterr_set(GITERR_NET, "Invalid packet line");
git__free(pkt->ref);
git__free(pkt);
return -1;
}
len = ptr - line;
......
......@@ -108,6 +108,7 @@ static int append_symref(const char **out, git_vector *symrefs, const char *ptr)
if (giterr_last()->klass != GITERR_NOMEMORY)
goto on_invalid;
git__free(mapping);
return error;
}
......@@ -120,6 +121,7 @@ static int append_symref(const char **out, git_vector *symrefs, const char *ptr)
on_invalid:
giterr_set(GITERR_NET, "remote sent invalid symref");
git_refspec__free(mapping);
git__free(mapping);
return -1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment