]> asedeno.scripts.mit.edu Git - git.git/blobdiff - commit.c
Merge branch 'maint'
[git.git] / commit.c
index f1ba972d9abcb218b9aae0680a753edeb3666bc3..bee066fa3227c876022424bd0e6238c1053e1231 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -638,7 +638,9 @@ static char *get_header(const struct commit *commit, const char *key)
                        next = NULL;
                } else
                        next = eol + 1;
-               if (!strncmp(line, key, key_len) && line[key_len] == ' ') {
+               if (eol - line > key_len &&
+                   !strncmp(line, key, key_len) &&
+                   line[key_len] == ' ') {
                        int len = eol - line - key_len;
                        char *ret = xmalloc(len);
                        memcpy(ret, line + key_len + 1, len - 1);
@@ -718,14 +720,6 @@ static char *logmsg_reencode(const struct commit *commit,
        return out;
 }
 
-static char *xstrndup(const char *text, int len)
-{
-       char *result = xmalloc(len + 1);
-       memcpy(result, text, len);
-       result[len] = '\0';
-       return result;
-}
-
 static void fill_person(struct interp *table, const char *msg, int len)
 {
        int start, end, tz = 0;
@@ -1069,6 +1063,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt,
                        int sz;
                        char header[512];
                        const char *header_fmt =
+                               "MIME-Version: 1.0\n"
                                "Content-Type: text/plain; charset=%s\n"
                                "Content-Transfer-Encoding: 8bit\n";
                        sz = snprintf(header, sizeof(header), header_fmt,