[Bug 270867] xargs -E is not working properly

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 15 Apr 2023 16:17:13 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=270867

Yuri Pankov <yuripv@FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yuripv@FreeBSD.org

--- Comment #1 from Yuri Pankov <yuripv@FreeBSD.org> ---
Apparently foundeof check is passing the wrong length to strncmp(), we should
be using the eofstr's one, not the current argument's:

diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c
index 21455e7be26..89f75a4c386 100644
--- a/usr.bin/xargs/xargs.c
+++ b/usr.bin/xargs/xargs.c
@@ -349,7 +349,7 @@ arg1:               if (insingle || indouble) {
                }
 arg2:
                foundeof = *eofstr != '\0' &&
-                   strncmp(argp, eofstr, p - argp) == 0;
+                   strncmp(argp, eofstr, strlen(eofstr)) == 0;

                /* Do not make empty args unless they are quoted */
                if ((argp != p || wasquoted) && !foundeof) {

-- 
You are receiving this mail because:
You are the assignee for the bug.