baseline

yet another open-source distributed versioning control system
Log | Files | Refs

commit d4ba95eb7cef624af58b1f84f26bb4d9f3aab669
parent f7ccd9777e8a664d9f769772895ff9f202e311cd
Author: Mohamed Aslan <maslan@sce.carleton.ca>
Date:   Mon, 30 Jun 2014 14:37:40 -0400

use calloc() instead of malloc() so that we can safely call strlcat() right after

Diffstat:
Mhelper.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/helper.c b/helper.c @@ -62,7 +62,8 @@ baseline_helper_commit_build(struct dircache_ctx *dc_ctx, const char *dir_id, co if ((mfp = fopen(msg_file, "r")) == NULL) return NULL; /* FIXME: loading the whole message file in memory */ - if ((comm->message = (char *)malloc(s.st_size)) == NULL) + /* use calloc() so that we can safely call strlcat() afterwards */ + if ((comm->message = (char *)calloc(1, s.st_size)) == NULL) return NULL; while (getline(&line, &size, mfp) != -1) strlcat(comm->message, line, s.st_size);