* lib/canonicalize-lgpl.c (__realpath): Declare n as ssize_t, not int.
+2016-10-14 Bruno Haible <bruno@clisp.org>
+ Pádraig Brady <P@draigBrady.com>
+
+ canonicalize-lgpl: Support the case path_max > INT_MAX.
+ * lib/canonicalize-lgpl.c (__realpath): Declare n as ssize_t, not int.
+ Fix overflow check, for platforms where 'size_t' is larger than 'long'.
+
2016-10-13 Jim Meyering <meyering@fb.com>
getprogname: IBM z/OS: avoid NULL-dereference
#else
struct stat st;
#endif
- int n;
/* Skip sequence of multiple path-separators. */
while (ISSLASH (*start))
{
char *buf;
size_t len;
+ ssize_t n;
if (++num_links > MAXSYMLINKS)
{
}
len = strlen (end);
- if ((long int) (n + len) >= path_max)
+ /* Check that n + len + 1 doesn't overflow and is <= path_max. */
+ if (n >= SIZE_MAX - len || n + len >= path_max)
{
freea (buf);
__set_errno (ENAMETOOLONG);