History log of /freebsd-10.3-release/usr.bin/xargs/strnsubst.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 296373 04-Mar-2016 marius

- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
builds.
- Update newvers.sh to reflect RC1.
- Update __FreeBSD_version to reflect 10.3.
- Update default pkg(8) configuration to use the quarterly branch.

Approved by: re (implicit)

# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


# 245050 05-Jan-2013 delphij

Follow calloc convention in other code, this is functionally identical
to its previous form.


# 153917 30-Dec-2005 jmallett

Handle maxsize==0 in such a way that we don't modify the string.


# 136664 18-Oct-2004 cperciva

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.


# 98616 22-Jun-2002 jmallett

Check for results of repeated calls to strnsubst(), as well as for the
behaviour with NULL match string, as that has changed over time.


# 97619 30-May-2002 jmallett

Allow the input line to be NULL, and teach strnsubst() that NULL means to use
a nil-string.


# 95996 03-May-2002 jmallett

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.


# 95900 02-May-2002 jmallett

*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.


# 95898 02-May-2002 jmallett

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.


# 95080 19-Apr-2002 jmallett

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