<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src-test2/lib/libc/gen/wordexp.3, branch stable/10</title>
<subtitle>FreeBSD source tree</subtitle>
<id>https://cgit-dev.freebsd.org/src-test2/atom?h=stable%2F10</id>
<link rel='self' href='https://cgit-dev.freebsd.org/src-test2/atom?h=stable%2F10'/>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/'/>
<updated>2015-10-25T17:17:50Z</updated>
<entry>
<title>MFC r288430: wordexp: Rewrite to make WRDE_NOCMD reliable.</title>
<updated>2015-10-25T17:17:50Z</updated>
<author>
<name>Jilles Tjoelker</name>
<email>jilles@FreeBSD.org</email>
</author>
<published>2015-10-25T17:17:50Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=34f1642d10875e5882308729926ebc82c8294f47'/>
<id>urn:sha1:34f1642d10875e5882308729926ebc82c8294f47</id>
<content type='text'>
Shell syntax is too complicated to detect command substitution and unquoted
operators reliably without implementing much of sh's parser. Therefore, have
sh do this detection.

While changing sh's support anyway, also read input from a pipe instead of
arguments to avoid {ARG_MAX} limits and improve privacy, and output count
and length using 16 instead of 8 digits.

The basic concept is:
execl("/bin/sh", "sh", "-c", "freebsd_wordexp ${1:+\"$1\"} -f "$2",
    "", flags &amp; WRDE_NOCMD ? "-p" : "", &lt;pipe with words&gt;);

The WRDE_BADCHAR error is still implemented in libc. POSIX requires us to
fail strings containing unquoted braces with code WRDE_BADCHAR. Since this
is normally not a syntax error in sh, there is still a need for checking
code in libc, we_check().

The new we_check() is an optimistic check that all the characters
  &lt;newline&gt; | &amp; ; &lt; &gt; ( ) { }
are quoted. To avoid duplicating too much sh logic, such characters are
permitted when quoting characters are seen, even if the quoting characters
may themselves be quoted. This code reports all WRDE_BADCHAR errors; bad
characters that get past it and are a syntax error in sh return WRDE_SYNTAX.

Although many implementations of WRDE_NOCMD erroneously allow some command
substitutions (and ours even documented this), there appears to be code that
relies on its security (codesearch.debian.net shows quite a few uses).
Passing untrusted data to wordexp() still exposes a denial of service
possibility and a fairly large attack surface.

This is also a MFC of r286830 to reduce conflicts. I changed the code
somewhat to avoid changes from r286941; in particular, WRDE_BADVAL can still
only be returned if WRDE_UNDEF was passed.

Relnotes:	yes
Security:	fixes command execution with wordexp(untrusted, WRDE_NOCMD)
</content>
</entry>
<entry>
<title>Correct usage example.</title>
<updated>2006-04-18T21:37:24Z</updated>
<author>
<name>Ceri Davies</name>
<email>ceri@FreeBSD.org</email>
</author>
<published>2006-04-18T21:37:24Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=c499f23b6e6fd363ea4fa1cb41aebf7ee2a1eb43'/>
<id>urn:sha1:c499f23b6e6fd363ea4fa1cb41aebf7ee2a1eb43</id>
<content type='text'>
PR:		docs/95059
Submitted by:	Jos Backus
MFC after:	4 days
</content>
</entry>
<entry>
<title>Document incorrect handling of multibyte characters due to limitations</title>
<updated>2004-07-28T15:43:33Z</updated>
<author>
<name>Tim J. Robbins</name>
<email>tjr@FreeBSD.org</email>
</author>
<published>2004-07-28T15:43:33Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=f825dd29c275c9168a69c27759302a47483c51a8'/>
<id>urn:sha1:f825dd29c275c9168a69c27759302a47483c51a8</id>
<content type='text'>
of sh(1).
</content>
</entry>
<entry>
<title>Fix typo: WRDE_DOOFS -&gt; WRDE_DOOFFS.</title>
<updated>2004-06-30T13:55:08Z</updated>
<author>
<name>Tim J. Robbins</name>
<email>tjr@FreeBSD.org</email>
</author>
<published>2004-06-30T13:55:08Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=b7114d4a9cc6a801adfec73c679493547b1d06e6'/>
<id>urn:sha1:b7114d4a9cc6a801adfec73c679493547b1d06e6</id>
<content type='text'>
Noticed by:	Stoned Elipot
</content>
</entry>
<entry>
<title>mdoc(7): Use the new feature of the .In macro.</title>
<updated>2003-09-08T19:57:22Z</updated>
<author>
<name>Ruslan Ermilov</name>
<email>ru@FreeBSD.org</email>
</author>
<published>2003-09-08T19:57:22Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=fe08efe680f6705e0c60beabe3e39629c655e743'/>
<id>urn:sha1:fe08efe680f6705e0c60beabe3e39629c655e743</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Assorted mdoc(7) fixes.</title>
<updated>2003-06-01T19:19:59Z</updated>
<author>
<name>Ruslan Ermilov</name>
<email>ru@FreeBSD.org</email>
</author>
<published>2003-06-01T19:19:59Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=0e35e492fcbda3368c44c083ea1a21edbe11d997'/>
<id>urn:sha1:0e35e492fcbda3368c44c083ea1a21edbe11d997</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Document return type of wordfree() (void). Reduce the space between</title>
<updated>2003-03-13T11:18:53Z</updated>
<author>
<name>Tim J. Robbins</name>
<email>tjr@FreeBSD.org</email>
</author>
<published>2003-03-13T11:18:53Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=be074a2dd8247f5cba52b17af013d6fe9bd20731'/>
<id>urn:sha1:be074a2dd8247f5cba52b17af013d6fe9bd20731</id>
<content type='text'>
struct member names and the corresponding comments so the lines don't
wrap on 80-column terminals.
</content>
</entry>
<entry>
<title>It is no longer necessary to include sys/types.h before wordexp.h.</title>
<updated>2003-01-03T12:04:36Z</updated>
<author>
<name>Tim J. Robbins</name>
<email>tjr@FreeBSD.org</email>
</author>
<published>2003-01-03T12:04:36Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=7d3125b3acd7a42c69005b1ce20dfb93e13944ef'/>
<id>urn:sha1:7d3125b3acd7a42c69005b1ce20dfb93e13944ef</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Fix a small typo.</title>
<updated>2002-12-27T08:28:53Z</updated>
<author>
<name>Tim J. Robbins</name>
<email>tjr@FreeBSD.org</email>
</author>
<published>2002-12-27T08:28:53Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=cd203b8ead6ef0ecabae58e779d3e1e9f91c70d0'/>
<id>urn:sha1:cd203b8ead6ef0ecabae58e779d3e1e9f91c70d0</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Add an implementation of the POSIX wordexp() and wordfree() functions,</title>
<updated>2002-12-26T14:34:18Z</updated>
<author>
<name>Tim J. Robbins</name>
<email>tjr@FreeBSD.org</email>
</author>
<published>2002-12-26T14:34:18Z</published>
<link rel='alternate' type='text/html' href='https://cgit-dev.freebsd.org/src-test2/commit/?id=faea1495bf19ed23bfec20c5c3257759d4e0e9eb'/>
<id>urn:sha1:faea1495bf19ed23bfec20c5c3257759d4e0e9eb</id>
<content type='text'>
which perform shell-style word expansion on strings. This is still a
little rough around the edges.

PR:		13420
</content>
</entry>
</feed>
