mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-05 17:12:51 +00:00
signature: don't allow empty emails
A signature is made up of a non-empty name and a non-empty email so let's validate that. This also brings us more in line with git, which also rejects ident with an empty email.
This commit is contained in:
parent
31e752b654
commit
76e3c43fb9
@ -70,9 +70,9 @@ int git_signature_new(git_signature **sig_out, const char *name, const char *ema
|
|||||||
if (p->name == NULL || p->email == NULL)
|
if (p->name == NULL || p->email == NULL)
|
||||||
return -1; /* oom */
|
return -1; /* oom */
|
||||||
|
|
||||||
if (p->name[0] == '\0') {
|
if (p->name[0] == '\0' || p->email[0] == '\0') {
|
||||||
git_signature_free(p);
|
git_signature_free(p);
|
||||||
return signature_error("Signature cannot have an empty name");
|
return signature_error("Signature cannot have an empty name or email");
|
||||||
}
|
}
|
||||||
|
|
||||||
p->when.time = time;
|
p->when.time = time;
|
||||||
|
@ -56,8 +56,8 @@ void test_commit_signature__create_empties(void)
|
|||||||
|
|
||||||
cl_git_fail(try_build_signature("", "emeric.fermas@gmail.com", 1234567890, 60));
|
cl_git_fail(try_build_signature("", "emeric.fermas@gmail.com", 1234567890, 60));
|
||||||
cl_git_fail(try_build_signature(" ", "emeric.fermas@gmail.com", 1234567890, 60));
|
cl_git_fail(try_build_signature(" ", "emeric.fermas@gmail.com", 1234567890, 60));
|
||||||
cl_git_pass(try_build_signature("nulltoken", "", 1234567890, 60));
|
cl_git_fail(try_build_signature("nulltoken", "", 1234567890, 60));
|
||||||
cl_git_pass(try_build_signature("nulltoken", " ", 1234567890, 60));
|
cl_git_fail(try_build_signature("nulltoken", " ", 1234567890, 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_commit_signature__create_one_char(void)
|
void test_commit_signature__create_one_char(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user