peres: Fix an off-by-one heap overflow in saveResource.
       Add missing checkings for NULL pointer.
Merge pull request #43 from jweyrich/peres-fixes

peres: Fix an off-by-one heap overflow in saveResource.
Fix portability issue regarding strlcat(). We now ship our own copy
of strlcat() from the OpenBSD implementation.
I renamed it to bsd_strlcat() with the intent of avoiding a couple of
preprocessor directives. To avoid other problems, always use our own
copy instead of the system's native.

A bit of history:
  The strlcpy() and strlcat() functions first appeared in
  OpenBSD 2.4, and made their appearance in FreeBSD 3.3.
  They are not defined by ANSI/ISO C nor POSIX, and are not present in
  GNU/Linux, but they're present in the Standard C Library (libc) of
  all BSD-based systems, and some UNIX variants. Solaris ships it's
  own version with slightly different semantics (see [1]) when `siz`
  is 0, or when there are NIL characters in `dst`.

See [2] for a detailed explanation.

[1] http://goo.gl/oa6pJ
[2] http://goo.gl/4uKQg
Merge pull request #44 from jweyrich/e7412359f3

Portability fix: Ship our own copy of strlcat() from the OpenBSD implementation.