From: Michael Orlitzky Date: Wed, 28 Mar 2018 01:03:01 +0000 (-0400) Subject: src/libadacl.c: use asprintf() instead of snprintf() for paths. X-Git-Tag: v0.4.0~8 X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=d8b55a1ea987e0ac8915bd5b2597d85f2d81c85d;hp=d8b55a1ea987e0ac8915bd5b2597d85f2d81c85d;p=apply-default-acl.git src/libadacl.c: use asprintf() instead of snprintf() for paths. When constructing a path, there is an ancient problem: how do you ensure that your path-name buffer is large enough, and what do you do if it isn't? The existing solution was to use the PATH_MAX constant from limits.h, which is often a big number, but need not actually be defined. If a path exceeded PATH_MAX bytes, we would fail. Now the GNU/BSD extension asprintf() is used instead. The path-name buffer is constructed on-the-fly to be as large as necessary, and if allocation fails, an error is returned. This solution is a little cleaner, and is not too much less portable considering that we only work on Linux anyway. ---