Don’t be fooled by "\000" in file name

* src/util.c (parse_c_string): Don’t be tricked by perverse
C-style quoted strings containing backslash, '0', '0', '0'.
* tests/quoted-filenames: Test this.
This commit is contained in:
Paul Eggert 2024-09-17 10:33:00 -07:00
parent 8492a6a212
commit 79dd5e762c
2 changed files with 24 additions and 0 deletions

View File

@ -1439,6 +1439,8 @@ parse_c_string (char const *str, char const **endp)
if (c < '0' || c > '7')
goto fail;
acc |= (c - '0');
if (!acc)
goto fail;
c = acc;
break;
}

View File

@ -31,3 +31,25 @@ ncheck 'patch -s -p0 < d.diff'
check 'cat " "' <<EOF
two
EOF
cat > e.diff <<\EOF
*** /dev/null Sat Sep 14 08:47:53 2024
--- "f\000g" Tue Sep 17 10:21:17 2024
***************
*** 0 ****
--- 1 ----
+
EOF
check 'patch -f < e.diff; echo status: $?' <<EOF
can't find file to patch at input line 3
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|*** /dev/null Sat Sep 14 08:47:53 2024
|--- "f\000g" Tue Sep 17 10:21:17 2024
--------------------------
No file to patch. Skipping patch.
1 out of 1 hunk ignored
status: 1
EOF