From 0a2aecae2cc43c02c9a84111afd3f3a7dbb11568 Mon Sep 17 00:00:00 2001 From: jmallett Date: Sat, 31 Dec 2005 09:06:45 +0000 Subject: Check the entire length of the current argument for the EOF string with -E, but don't expect a proper ASCII string to exist right here right now, don't use strcmp(3) which checks for a NUL. As we're still building the argument up, the next character might be garbage. It would probably be just as safe to temporarily write a NUL there, but if we've reached the end of argument memory that might not be the best idea, I think. It's unclear. Doing it this way seems to meet the most with the original intent. PR: 85696 Prodded by: stefanf --- usr.bin/xargs/xargs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'usr.bin') diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index b4a8b83..58ac847 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -304,7 +304,7 @@ arg1: if (insingle || indouble) errx(1, "unterminated quote"); arg2: foundeof = *eofstr != '\0' && - strcmp(argp, eofstr) == 0; + strncmp(argp, eofstr, p - argp) == 0; /* Do not make empty args unless they are quoted */ if ((argp != p || wasquoted) && !foundeof) { -- cgit v1.1