From owner-freebsd-bugs Thu Oct 12 21: 9: 7 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from tsp.korea.ac.kr (tsp.korea.ac.kr [163.152.18.252]) by hub.freebsd.org (Postfix) with ESMTP id ACB0F37B66C; Thu, 12 Oct 2000 21:08:49 -0700 (PDT) Received: from localhost (smcho@localhost) by tsp.korea.ac.kr (8.9.3/8.9.3) with ESMTP id NAA30630; Fri, 13 Oct 2000 13:04:39 +0900 (KST) Date: Fri, 13 Oct 2000 13:04:39 +0900 (KST) From: To: FreeBSD-gnats-submit@freebsd.org Cc: freebsd-bugs@freebsd.org Subject: smget(2) assumes the size in pages Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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 #include #include + #include #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