=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/logmsg.c,v retrieving revision 1.60 retrieving revision 1.61 diff -u -r1.60 -r1.61 --- src/usr.bin/cvs/logmsg.c 2017/05/28 16:57:01 1.60 +++ src/usr.bin/cvs/logmsg.c 2020/10/19 19:51:20 1.61 @@ -1,4 +1,4 @@ -/* $OpenBSD: logmsg.c,v 1.60 2017/05/28 16:57:01 joris Exp $ */ +/* $OpenBSD: logmsg.c,v 1.61 2020/10/19 19:51:20 naddy Exp $ */ /* * Copyright (c) 2007 Joris Vink * @@ -100,6 +100,7 @@ struct cvs_filelist *cf; struct stat st1, st2; char *fpath, *logmsg, repo[PATH_MAX]; + char *f, path[PATH_MAX]; struct stat st; struct trigger_list *line_list; struct trigger_line *line; @@ -165,28 +166,46 @@ if (added != NULL && !RB_EMPTY(added)) { fprintf(fp, "%s Added Files:", CVS_LOGMSG_PREFIX); - RB_FOREACH(cf, cvs_flisthead, added) - fprintf(fp, "\n%s \t%s ", CVS_LOGMSG_PREFIX, - dir != NULL ? basename(cf->file_path) : - cf->file_path); + RB_FOREACH(cf, cvs_flisthead, added) { + f = cf->file_path; + if (dir != NULL) { + if (strlcpy(path, f, sizeof(path)) >= + sizeof(path)) + fatal("cvs_logmsg_create: truncation"); + f = basename(path); + } + fprintf(fp, "\n%s \t%s ", CVS_LOGMSG_PREFIX, f); + } fputs("\n", fp); } if (removed != NULL && !RB_EMPTY(removed)) { fprintf(fp, "%s Removed Files:", CVS_LOGMSG_PREFIX); - RB_FOREACH(cf, cvs_flisthead, removed) - fprintf(fp, "\n%s \t%s ", CVS_LOGMSG_PREFIX, - dir != NULL ? basename(cf->file_path) : - cf->file_path); + RB_FOREACH(cf, cvs_flisthead, removed) { + f = cf->file_path; + if (dir != NULL) { + if (strlcpy(path, f, sizeof(path)) >= + sizeof(path)) + fatal("cvs_logmsg_create: truncation"); + f = basename(path); + } + fprintf(fp, "\n%s \t%s ", CVS_LOGMSG_PREFIX, f); + } fputs("\n", fp); } if (modified != NULL && !RB_EMPTY(modified)) { fprintf(fp, "%s Modified Files:", CVS_LOGMSG_PREFIX); - RB_FOREACH(cf, cvs_flisthead, modified) - fprintf(fp, "\n%s \t%s ", CVS_LOGMSG_PREFIX, - dir != NULL ? basename(cf->file_path) : - cf->file_path); + RB_FOREACH(cf, cvs_flisthead, modified) { + f = cf->file_path; + if (dir != NULL) { + if (strlcpy(path, f, sizeof(path)) >= + sizeof(path)) + fatal("cvs_logmsg_create: truncation"); + f = basename(path); + } + fprintf(fp, "\n%s \t%s ", CVS_LOGMSG_PREFIX, f); + } fputs("\n", fp); }