Bug 6947 - ulimit(UL_SETFSIZE) at linux does not comply with POSIX
Summary: ulimit(UL_SETFSIZE) at linux does not comply with POSIX
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.8
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-06 18:24 UTC by Alexey Khoroshilov
Modified: 2014-07-02 06:59 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Khoroshilov 2008-10-06 18:24:40 UTC
POSIX requirements to ulimit(UL_SETFSIZE) are as follows:

  UL_SETFSIZE
    Set the file size limit for output operations
    of the process to the value of the second argument,
    taken as a long, multiplied by 512.
    ...
    The return value shall be the integer part of
    the new file size limit divided by 512.


glibc implementation of this function for Linux 
libc/sysdeps/unix/sysv/linux/ulimit.c
returns just results of __setrlimit() call, which is 0 in the case of success.

The code demonstrating the problem is below.

#include <ulimit.h>
#include <stdio.h>
	
int main( int argc, char ** argv ) 
{
	long res;
	res=ulimit(UL_GETFSIZE); 
	printf("Result of ulimit(UL_GETFSIZE): %ld\n", res);

	res=ulimit(UL_SETFSIZE, 10000); 
	printf("Result of ulimit(UL_SETFSIZE, 10000): %ld\n", res);

	res=ulimit(UL_GETFSIZE); 
	printf("Result of ulimit(UL_GETFSIZE): %ld\n", res);

	return 0;
}
Comment 1 Ulrich Drepper 2008-10-31 17:30:03 UTC
Fixed in cvs.