Patchwork sln: use stat64

login
register
mail settings
Submitter Mike Frysinger
Date March 7, 2016, 1:21 a.m.
Message ID <1457313670-22660-1-git-send-email-vapier@gentoo.org>
Download mbox | patch
Permalink /patch/11226/
State New
Headers show

Comments

Mike Frysinger - March 7, 2016, 1:21 a.m.
From: Hongjiu Zhang <noctuorare@gmail.com>

When using sln on some filesystems which return 64-bit inodes, the stat
call might fail during install like so:
	.../elf/sln .../elf/symlink.list
	/lib32/libc.so.6: invalid destination: Value too large for defined data type
	/lib32/ld-linux.so.2: invalid destination: Value too large for defined data type
	Makefile:104: recipe for target 'install-symbolic-link' failed

Switch to using stat64 all the time to avoid this.

2016-03-06  Hongjiu Zhang  <noctuorare@gmail.com>

	* elf/sln.c (makesymlink): Change stat to stat64, and lstat to lstat64.
---
 elf/sln.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Florian Weimer - March 7, 2016, 3:54 p.m.
On 03/07/2016 02:21 AM, Mike Frysinger wrote:

> 2016-03-06  Hongjiu Zhang  <noctuorare@gmail.com>
> 
> 	* elf/sln.c (makesymlink): Change stat to stat64, and lstat to lstat64.

Should say “struct stat” instead of “stat”, to avoid confusion.
Otherwise good.

Thanks,
Florian
Joseph Myers - March 7, 2016, 4:41 p.m.
On Sun, 6 Mar 2016, Mike Frysinger wrote:

> 2016-03-06  Hongjiu Zhang  <noctuorare@gmail.com>
> 
> 	* elf/sln.c (makesymlink): Change stat to stat64, and lstat to lstat64.

This is [BZ #15333] (but that bug should not be closed as fixed unless 
there are no further issues of this form left).
Mike Frysinger - March 7, 2016, 6:25 p.m.
On 07 Mar 2016 16:41, Joseph Myers wrote:
> On Sun, 6 Mar 2016, Mike Frysinger wrote:
> > 2016-03-06  Hongjiu Zhang  <noctuorare@gmail.com>
> > 
> > 	* elf/sln.c (makesymlink): Change stat to stat64, and lstat to lstat64.
> 
> This is [BZ #15333] (but that bug should not be closed as fixed unless 
> there are no further issues of this form left).

thanks.  i've linked the ChangeLog entry to that bug.  i've also added
a list of programs/libraries that look suspicious so we can at least
have an end goal to close the bug.
-mike

Patch

diff --git a/elf/sln.c b/elf/sln.c
index 9d57be2..f52cb9f 100644
--- a/elf/sln.c
+++ b/elf/sln.c
@@ -164,11 +164,11 @@  makesymlinks (const char *file)
 static int
 makesymlink (const char *src, const char *dest)
 {
-  struct stat stats;
+  struct stat64 stats;
   const char *error;
 
   /* Destination must not be a directory. */
-  if (lstat (dest, &stats) == 0)
+  if (lstat64 (dest, &stats) == 0)
     {
       if (S_ISDIR (stats.st_mode))
 	{