Sophie

Sophie

distrib > Mandriva > 2009.0 > x86_64 > media > main-testing-src > by-pkgid > 097a12bbe051ea2436c51f094f5d588b > files > 40

glibc-2.8-1.20080520.5.3mnb2.src.rpm

From dbb6ab3ee03146cbd89cc52d5a18f666953327c6 Mon Sep 17 00:00:00 2001
From: Ulrich Drepper <drepper@redhat.com>
Date: Fri, 31 Oct 2008 17:29:46 +0000
Subject: [PATCH] [BZ #6947]

* sysdeps/unix/sysv/linux/ulimit.c (__ulimit): Handle UL_GETFSIZE
	return value in case rlimit is RLIM_INFINITY.

	[BZ #6947]
	* sysdeps/unix/sysv/linux/ulimit.c (__ulimit): Fix return value
	for UL_SETFSIZE.
---
 sysdeps/unix/sysv/linux/ulimit.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/ulimit.c b/sysdeps/unix/sysv/linux/ulimit.c
index 9c309c3..0b87599 100644
--- a/sysdeps/unix/sysv/linux/ulimit.c
+++ b/sysdeps/unix/sysv/linux/ulimit.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,92,1994-1998,2000,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991,92,1994-1998,2000,2001,2008
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -47,26 +48,32 @@ __ulimit (int cmd, ...)
       /* Get limit on file size.  */
       if (__getrlimit (RLIMIT_FSIZE, &limit) == 0)
 	/* Convert from bytes to 512 byte units.  */
-	result =  limit.rlim_cur / 512;
+	result =  (limit.rlim_cur == RLIM_INFINITY
+		   ? LONG_MAX : limit.rlim_cur / 512);
       break;
 
     case UL_SETFSIZE:
       /* Set limit on file size.  */
       {
 	long int newlimit = va_arg (va, long int);
+	long int newlen;
 
 	if ((rlim_t) newlimit > RLIM_INFINITY / 512)
 	  {
 	    limit.rlim_cur = RLIM_INFINITY;
 	    limit.rlim_max = RLIM_INFINITY;
+	    newlen = LONG_MAX;
 	  }
 	else
 	  {
 	    limit.rlim_cur = newlimit * 512;
 	    limit.rlim_max = newlimit * 512;
+	    newlen = newlimit;
 	  }
 
 	result = __setrlimit (RLIMIT_FSIZE, &limit);
+	if (result != -1)
+	  result = newlen;
       }
       break;