]> git.scripts.mit.edu Git - git.git/blobdiff - commit.c
apply: reject input that touches outside the working area
[git.git] / commit.c
index de16a3c0a2d6693173678247ba0755e4d7483a1c..57ebea2aee30b00e86a620f7efc793420f214185 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -196,19 +196,19 @@ struct commit_graft *read_graft_line(char *buf, int len)
 static int read_graft_file(const char *graft_file)
 {
        FILE *fp = fopen(graft_file, "r");
-       char buf[1024];
+       struct strbuf buf = STRBUF_INIT;
        if (!fp)
                return -1;
-       while (fgets(buf, sizeof(buf), fp)) {
+       while (!strbuf_getwholeline(&buf, fp, '\n')) {
                /* The format is just "Commit Parent1 Parent2 ...\n" */
-               int len = strlen(buf);
-               struct commit_graft *graft = read_graft_line(buf, len);
+               struct commit_graft *graft = read_graft_line(buf.buf, buf.len);
                if (!graft)
                        continue;
                if (register_commit_graft(graft, 1))
-                       error("duplicate graft data: %s", buf);
+                       error("duplicate graft data: %s", buf.buf);
        }
        fclose(fp);
+       strbuf_release(&buf);
        return 0;
 }