Commit Graph

10 Commits

Author SHA1 Message Date
Eitan Adler
dae3a64fb9 userland: Fix several typos and minor errors
- duplicate words
- typos
- references to old versions of FreeBSD

Reviewed by:	imp, benno
2017-12-27 03:23:01 +00:00
Xin LI
df4110b6cf Follow calloc convention in other code, this is functionally identical
to its previous form.
2013-01-05 00:23:58 +00:00
Juli Mallett
38e62c6999 Handle maxsize==0 in such a way that we don't modify the string. 2005-12-30 23:22:50 +00:00
Colin Percival
5578bd8c99 Modify behaviour of xargs -I in order to:
1. Conform to IEEE Std 1003.1-2004, which state that "Constructed
arguments cannot grow larger than 255 bytes", and
2. Avoid a buffer overflow.

Unfortunately the standard doesn't indicate how xargs is supposed to
handle arguments which (with the appropriate substitutions) would grow
larger than 255 bytes; this solution handles those by making as many
substitutions as possible without overflowing the buffer.

OpenBSD's xargs resolves this in a different direction, by making
all the substitutions and then silently truncating the resulting string.

Since this change may break existing scripts which rely upon the buffer
overflow (255 bytes isn't really all that long...) it will not be MFCed.
2004-10-18 15:40:47 +00:00
Juli Mallett
5058dcb497 Check for results of repeated calls to strnsubst(), as well as for the
behaviour with NULL match string, as that has changed over time.
2002-06-22 12:58:42 +00:00
Juli Mallett
986d829b8f Allow the input line to be NULL, and teach strnsubst() that NULL means to use
a nil-string.
2002-05-30 19:24:08 +00:00
Juli Mallett
38dff9a439 Fix a bug whereby we were getting ~0 and comparing it to maxsize, i.e. if
s1 was 0 length, and replstr was 0 length, etc., we would end up subtracting
one from zero and seeing if it was greater than the size_t (unsigned) var
maxsize...  This would cause us to return a string consisting of essentially
only match, which is not the right behaviour if we have 0 length inpline.
2002-05-03 19:45:41 +00:00
Juli Mallett
299ea75ab7 *str is spelled 's1' inside the body of the code.
Make 'this' not a local variable, since it isn't necessary or complex enough
to warrant such.
2002-05-02 02:15:06 +00:00
Juli Mallett
0fa5e8dc42 Rework some of the -I support so I can't find a way to make xargs(1) core or
corrupt memory.  Simplifies the code in one or two places, also removes some
code that looks like it was bogus or incomplete.

Update strnsubst to have one or two extra conditions which maybe would make
it more efficient, or at least more versatile.  This is likely a no-op.
2002-05-02 02:06:03 +00:00
Juli Mallett
fc17b349c8 After 3 months...
Merge xargs(1) with that of xMach.

Bring in xargs(1) changes to add -L and -I as per the Single Unix Specification
version 3.  Proper exit status numbers are implemented, and the manual page has
been updated to reflect reality.

The code has been ANSIfied, and a new file has been added to xargs(1) to do the
substring substitution as SUSv3 requires.

Traditional behaviour should not be affected, use of -J should be deprecated
in favor of the more portable -I (though -J has been left, for now).

Submitted by:	me, tjr (the exit status stuff)
Obtained from:	xMach
2002-04-19 23:28:54 +00:00