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 e1b8ed0..a5e16b7 100644 --- a/contrib/cvs/src/logmsg.c +++ b/contrib/cvs/src/logmsg.c @@ -184,7 +184,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; @@ -218,7 +217,6 @@ do_editor (dir, messagep, repository, changes) { FILE *tfp; char buf[1024]; - char *p; size_t n; size_t nwrite; @@ -233,9 +231,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); @@ -317,7 +315,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); @@ -329,8 +328,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) @@ -816,7 +818,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'; |