File realpath-ssize-max-overflow.patch of Package glibc.8004

2018-05-09  Paul Pluzhnikov  <ppluzhnikov@google.com>

	[BZ #22786]
	* stdlib/canonicalize.c (__realpath): Fix overflow in path length
	computation.

Index: glibc-2.19/stdlib/canonicalize.c
===================================================================
--- glibc-2.19.orig/stdlib/canonicalize.c
+++ glibc-2.19/stdlib/canonicalize.c
@@ -181,7 +181,7 @@ __realpath (const char *name, char *reso
 		extra_buf = __alloca (path_max);
 
 	      len = strlen (end);
-	      if ((long int) (n + len) >= path_max)
+	      if (path_max - n <= len)
 		{
 		  __set_errno (ENAMETOOLONG);
 		  goto error;
openSUSE Build Service is sponsored by