Date: Fri, 13 Oct 2000 13:04:39 +0900 (KST) From: <smcho@tsp.korea.ac.kr> To: FreeBSD-gnats-submit@freebsd.org Cc: freebsd-bugs@freebsd.org Subject: smget(2) assumes the size in pages Message-ID: <Pine.BSO.4.10.10010131255420.20037-100000@tsp.korea.ac.kr>
next in thread | raw e-mail | index | archive | help
>Submitter-Id: current-users
>Originator: smcho@tsp.korea.ac.kr
>Organization:
>Confidential: no
>Synopsis: shmget(2) takes 'size' in pages as opposed to bytes.
>Severity: serious
>Priority: high
>Category: kern
>Release: FreeBSD 3.5.1-RELEASE i386
>Class: sw-bug
>Environment:
All branches supporting SYSV shared memory.
>Description:
shmget(2) is described to take the second argument as 'the desired
size of the new segment in bytes', but in reality, it takes the
second argument as the size in _pages_.
>How-To-Repeat:
Read the source:
sys/kern/sysv_shm.c
lib/libc/gen/shmget.c
>Fix:
Attached is a patch to lib/libc/gen/shmget.c
*** /usr/src/lib/libc/gen/shmget.c.orig Thu Oct 12 20:43:52 2000
--- /usr/src/lib/libc/gen/shmget.c Thu Oct 12 20:47:36 2000
***************
*** 5,10 ****
--- 5,11 ----
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
+ #include <sys/param.h>
#if __STDC__
int shmget(key_t key, int size, int shmflg)
***************
*** 15,19 ****
int shmflg;
#endif
{
! return (shmsys(3, key, size, shmflg));
}
--- 16,25 ----
int shmflg;
#endif
{
! int page = size / PAGE_SIZE;
!
! if (size % PAGE_SIZE > 0)
! page++;
!
! return (shmsys(3, key, page, shmflg));
}
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSO.4.10.10010131255420.20037-100000>
