History log of /external/toybox/toys/posix/basename.c
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
d74b562f508475192b6783b0b2d4dae4e5c2fa93 09-May-2017 Rob Landley <rob@landley.net> Move strend() to lib/lib.c
/external/toybox/toys/posix/basename.c
e223cca4f66bf2e201b21869304dc63befbbf9be 20-Mar-2016 Samuel Holland <samuel@sholland.org> basename: fix segfault on null input; add tests

When passed an empty string, glibc's basename() returns a pointer to the
string "." in read-only memory. If an empty suffix is given, it fits
the condition of being shorter than the path, so we try to overwrite the
null byte and crash. Fix this by just ignoring empty suffixes; they
don't do anything anyway.
/external/toybox/toys/posix/basename.c
9215cbc062f85cd285d8906a0b36941fa44d06c7 25-Aug-2015 Rob Landley <rob@landley.net> Static analysis from Hyejin Kim found possible pointer underflow.

Now that the kernel's 128k environment size has been lifted, it might be
possible to feed in a gigabyte of suffix so argv[2] is enough larger than
argv[1] that char *s decrements past NULL and points to arbitrary high
memory (I.E. strlen(suffix) > (long)base), at which point the base > s
test is defeated and we strcmp() against a wild pointer.

Which is read only anyway and on 64 bit you probably couldn't hit any
interesting addresses, but the fix is easy enough: compare strlen values
instead of pointers. So do that instead.
/external/toybox/toys/posix/basename.c
90e8605ea587c4ebd00de77e3c71551b6e26b7c0 05-Jan-2013 Rob Landley <rob@landley.net> Make basename use basename().
/external/toybox/toys/posix/basename.c
7aa651a6a4496d848f86de9b1e6b3a003256a01f 14-Nov-2012 Rob Landley <rob@landley.net> Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.

The actual code should be the same afterward, this is just cosmetic refactoring.
/external/toybox/toys/posix/basename.c
3a9241add947cb6d24b5de7a8927517426a78795 25-Aug-2012 Rob Landley <rob@landley.net> Move commands into "posix", "lsb", and "other" menus/directories.
/external/toybox/toys/posix/basename.c