diff options
Diffstat (limited to 'contrib/cvs/src/logmsg.c')
-rw-r--r-- | contrib/cvs/src/logmsg.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/contrib/cvs/src/logmsg.c b/contrib/cvs/src/logmsg.c index 6d45ca3..cb08cdf 100644 --- a/contrib/cvs/src/logmsg.c +++ b/contrib/cvs/src/logmsg.c @@ -182,7 +182,6 @@ do_editor (dir, messagep, repository, changes) char *fname; struct stat pre_stbuf, post_stbuf; int retcode = 0; - char *p; if (noexec || reuse_log_message) return; @@ -216,7 +215,6 @@ do_editor (dir, messagep, repository, changes) { FILE *tfp; char buf[1024]; - char *p; size_t n; size_t nwrite; @@ -231,9 +229,9 @@ do_editor (dir, messagep, repository, changes) { while (!feof (tfp)) { + char *p = buf; n = fread (buf, 1, sizeof buf, tfp); nwrite = n; - p = buf; while (nwrite > 0) { n = fwrite (p, 1, nwrite, fp); @@ -315,7 +313,8 @@ do_editor (dir, messagep, repository, changes) if (*messagep) { - p = *messagep; + size_t message_len = post_stbuf.st_size + 1; + size_t offset = 0; while (1) { line_length = getline (&line, &line_chars_allocated, fp); @@ -327,8 +326,11 @@ do_editor (dir, messagep, repository, changes) } if (strncmp (line, CVSEDITPREFIX, CVSEDITPREFIXLEN) == 0) continue; - (void) strcpy (p, line); - p += line_length; + if (offset + line_length >= message_len) + expand_string (messagep, &message_len, + offset + line_length + 1); + (void) strcpy (*messagep + offset, line); + offset += line_length; } } if (fclose (fp) < 0) @@ -759,7 +761,7 @@ logfile_write (repository, filter, message, logfp, changes) } len = fmt_end - fmt_begin; - str_list_format = xmalloc (sizeof (char) * (len + 1)); + str_list_format = xmalloc (len + 1); strncpy (str_list_format, fmt_begin, len); str_list_format[len] = '\0'; |