From 3fc57727741615c84f6e1e4340dfbdda467815ab Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sun, 13 Jan 2019 21:37:33 -0600 Subject: Better support patching files with tabs in the name. Patch dates are optional these days, and I should properly work back from the end and only peel off properly formatted tab+date, but "tab followed by digit" is probably good enough and nobody's ever complained about just tab. And we still don't support patching filenames with newlines in them...) --- toys/posix/patch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toys/posix/patch.c b/toys/posix/patch.c index f12f9183..8c93fdfd 100644 --- a/toys/posix/patch.c +++ b/toys/posix/patch.c @@ -327,7 +327,7 @@ void patch_main(void) finish_oldfile(); // Trim date from end of filename (if any). We don't care. - for (s = patchline+4; *s && *s!='\t'; s++) + for (s = patchline+4; *s && (*s!='\t' || !isdigit(s[1])); s++) if (*s=='\\' && s[1]) s++; i = atoi(s); if (i>1900 && i<=1970) *name = xstrdup("/dev/null"); -- cgit v1.2.3