libgit2/libgit2 — pull request #1619 by ethomson (2013-05-29 21:34:24+00:00)
Title: allow (ignore) bare slash in gitignore

If you have a forward slash (`/'`) by itself on a line, the `.gitignore` parser crashes.

When parsing lines, when we find a trailing `/`, we try to truncate it by decrementing the length of the string by one. (https://github.com/libgit2/libgit2/blob/development/src/attr_file.c#L403). However, in the case of a bare slash, this will set the strings length to uint32_t's max value.

We then try to `git_pool_strndup` uint32_t's max value bytes. At which point we try to `git_pool_malloc` one more byte (https://github.com/libgit2/libgit2/blob/development/src/pool.c#L197) for a total of zero bytes, which succeeds. At which point we try to `memcpy` uint32_t's max value of bytes into some region that was expected to contain 0 bytes.