diff options
author | peter <peter@FreeBSD.org> | 2004-06-10 19:05:38 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2004-06-10 19:05:38 +0000 |
commit | 8416bda1d23bda4666a5b880a9d78eccaa640036 (patch) | |
tree | 7d97944b58f1e30ab542f9c3d6720b69314cec4d /contrib/cvs/src/wrapper.c | |
parent | 3d101ef985844544d089e129157a94a0640fd246 (diff) | |
download | FreeBSD-src-8416bda1d23bda4666a5b880a9d78eccaa640036.zip FreeBSD-src-8416bda1d23bda4666a5b880a9d78eccaa640036.tar.gz |
Import cvs-1.11.17 onto vendor branch.
Diffstat (limited to 'contrib/cvs/src/wrapper.c')
-rw-r--r-- | contrib/cvs/src/wrapper.c | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/contrib/cvs/src/wrapper.c b/contrib/cvs/src/wrapper.c index 8d7a8ef..548b3a5 100644 --- a/contrib/cvs/src/wrapper.c +++ b/contrib/cvs/src/wrapper.c @@ -237,6 +237,30 @@ wrap_unparse_rcs_options (line, first_call_p) #endif /* SERVER_SUPPORT || CLIENT_SUPPORT */ /* + * Remove fmt str specifier other than %% or %s. And allow + * only max_s %s specifiers + */ +wrap_clean_fmt_str(char *fmt, int max_s) +{ + while (*fmt) { + if (fmt[0] == '%' && fmt[1]) + { + if (fmt[1] == '%') + fmt++; + else + if (fmt[1] == 's' && max_s > 0) + { + max_s--; + fmt++; + } else + *fmt = ' '; + } + fmt++; + } + return; +} + +/* * Open a file and read lines, feeding each line to a line parser. Arrange * for keeping a temporary list of wrappers at the end, if the "temp" * argument is set. @@ -556,9 +580,8 @@ wrap_tocvs_process_file(fileName) args = xmalloc (strlen (e->tocvsFilter) + strlen (fileName) + strlen (buf)); - /* FIXME: sprintf will blow up if the format string contains items other - than %s, or contains too many %s's. We should instead be parsing - e->tocvsFilter ourselves and giving a real error. */ + + wrap_clean_fmt_str(e->tocvsFilter, 2); sprintf (args, e->tocvsFilter, fileName, buf); run_setup (args); run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL|RUN_REALLY ); @@ -590,9 +613,8 @@ wrap_fromcvs_process_file(fileName) args = xmalloc (strlen (e->fromcvsFilter) + strlen (fileName)); - /* FIXME: sprintf will blow up if the format string contains items other - than %s, or contains too many %s's. We should instead be parsing - e->fromcvsFilter ourselves and giving a real error. */ + + wrap_clean_fmt_str(e->fromcvsFilter, 1); sprintf (args, e->fromcvsFilter, fileName); run_setup (args); run_exec(RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL ); |