]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/blame.c
avoid sprintf and strcpy with flex arrays
[thirdparty/git.git] / builtin / blame.c
index e253ac0dcb858c9911bf3dbf9dcb11dbcbfbfc84..e70fb6dac3bd24ce4ea8abf355c1c50c9a669329 100644 (file)
@@ -459,12 +459,13 @@ static void queue_blames(struct scoreboard *sb, struct origin *porigin,
 static struct origin *make_origin(struct commit *commit, const char *path)
 {
        struct origin *o;
-       o = xcalloc(1, sizeof(*o) + strlen(path) + 1);
+       size_t pathlen = strlen(path) + 1;
+       o = xcalloc(1, sizeof(*o) + pathlen);
        o->commit = commit;
        o->refcnt = 1;
        o->next = commit->util;
        commit->util = o;
-       strcpy(o->path, path);
+       memcpy(o->path, path, pathlen); /* includes NUL */
        return o;
 }