Am Do., 13. März 2025 um 13:57 Uhr schrieb 김민종 <[email protected]>:
> Thank you very much for your reply.
>
> While applying the automated software testing tool to the patch, I found the 
> following command that causes abnormal termination.
> I know this command is rarely used, but I am reporting it to you just in case.
>
> $ echo -e "-\n\n-\na \n" | ./patch $'\x00\xff\xff'
> patch: pch.c:2396: do_ed_script: Assertion `! inerrno' failed.
> Aborted
>
> In this case, I think the program should output the following message:
> patch: **** Only garbage was found in the patch input.

Current versions of patch no longer fail with an assertion in this case.

They interpret the "a " line as an ed append command and so they pass
the rest of the patch to ed, which then fails. This results in the
following output (ignore the []):

[] ?
[] src/patch: **** /usr/bin/ed FAILED

Here, the "?" means that ed is unhappy about the input.

A single "a" is a valid ed command, but in the output GNU diff
generates for ed-style diffs, "a" is always prefixed with a line
number. So we could probably require a line number in front of "a"
commands.

In reality, the effect would probably just be that fuzz testers would
generate a command like "3a" instead of just "a", which would again
fail in the exact same way.

Thanks,
Andreas

Reply via email to