summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Youngman <jay@gnu.org>2013-09-24 00:28:05 +0100
committerJames Youngman <jay@gnu.org>2013-09-24 00:28:05 +0100
commitcdd390b492d7e9db18a1e9aa88e42525ce4022e5 (patch)
tree10b7494e2328432a348898c46497caaf523c048b
parent4f45698bc3a7b547debd135ab5969f1ec1b65ea0 (diff)
downloadfindutils-cdd390b492d7e9db18a1e9aa88e42525ce4022e5.tar.gz
Fix bug #39162: -printf reads beyond arguments terminated by \
* find/print.c (insert_fprintf): If a \ is found at the end of a format string, issue a warning (and render it as-is). * NEWS: Mention this bugfix.
-rw-r--r--ChangeLog5
-rw-r--r--NEWS4
-rw-r--r--find/print.c8
3 files changed, 16 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d1df39d..06c3c94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2013-09-23 James Youngman <jay@gnu.org>
+ Fix bug #39162: -printf reads beyond arguments terminated by \
+ * find/print.c (insert_fprintf): If a \ is found at the end of a
+ format string, issue a warning (and render it as-is).
+ * NEWS: Mention this bugfix.
+
Update version number to 4.5.13-git.
* configure.ac: Update version number to 4.5.13-git.
* NEWS: Likewise.
diff --git a/NEWS b/NEWS
index 6157ee3..f72696e 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,10 @@ GNU findutils NEWS - User visible changes. -*- outline -*- (allout)
* Major changes in release 4.5.13-git, 2013-MM-DD
+** Bug Fixes
+
+#39162: -printf reads beyond arguments terminated by \
+
** Translations
Updated translations: Estonian, Polish, Ukranian.
diff --git a/find/print.c b/find/print.c
index 5d35172..ae1b8c3 100644
--- a/find/print.c
+++ b/find/print.c
@@ -341,7 +341,13 @@ insert_fprintf (struct format_val *vec,
else if (*fmt_editpos == '\\')
{
size_t readpos = 1;
- if (is_octal_char(fmt_editpos[readpos]))
+ if (!fmt_editpos[readpos])
+ {
+ error (0, 0, _("warning: escape `\\' followed by nothing at all"));
+ --readpos;
+ /* (*fmt_editpos) is already '\\' and that's a reasonable result. */
+ }
+ else if (is_octal_char(fmt_editpos[readpos]))
{
size_t consumed = 0;
*fmt_editpos = parse_octal_escape(fmt_editpos + readpos, &consumed);