NetBSD Problem Report #46985
From www@NetBSD.org Wed Sep 19 18:48:52 2012
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
by www.NetBSD.org (Postfix) with ESMTP id 08B6C63C33D
for <gnats-bugs@gnats.NetBSD.org>; Wed, 19 Sep 2012 18:48:52 +0000 (UTC)
Message-Id: <20120919184851.64FF863B907@www.NetBSD.org>
Date: Wed, 19 Sep 2012 18:48:51 +0000 (UTC)
From: aran@100acres.us
Reply-To: aran@100acres.us
To: gnats-bugs@NetBSD.org
Subject: sem_post does not validate arguments
X-Send-Pr-Version: www-1.0
>Number: 46985
>Category: lib
>Synopsis: sem_post does not validate arguments
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Sep 19 18:50:00 +0000 2012
>Last-Modified: Wed Sep 19 19:10:02 +0000 2012
>Originator: Aran Clauson
>Release: NetBSD 6.99.11
>Organization:
>Environment:
NetBSD sanders 6.99.11 NetBSD 6.99.11 (SANDERS) #0: Mon Sep 17 14:11:22 PDT 2012 aran@sanders:/home/NetBSD/obj/sys/arch/amd64/compile/SANDERS amd64
>Description:
calling sem_post (NULL) crashes the program. The documentation says that it should return -1 with errno=EINVAL. The problem is that macro ERRORCHECK is undefined in src/lib/libpthread/sem.c. That macro is defined in pthread_int.h and that head used to be included by sem.c. However, at revision 1.22 of sem.c, the include was removed.
>How-To-Repeat:
compile and run
#include <semaphore.h>
int main ()
{
sem_post (NULL);
return 0;
}
>Fix:
inlcude pthread_int.h in sem.c
>Audit-Trail:
From: Aran Clauson <aran@100acres.us>
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org
Cc:
Subject: Re: lib/46985: sem_post does not validate arguments
Date: Wed, 19 Sep 2012 12:08:20 -0700 (PDT)
The following patch fixes the problem.
Index: lib/libpthread/sem.c
===================================================================
RCS file: /cvsroot/src/lib/libpthread/sem.c,v
retrieving revision 1.24
diff -u -r1.24 sem.c
--- lib/libpthread/sem.c 10 Mar 2012 18:01:10 -0000 1.24
+++ lib/libpthread/sem.c 19 Sep 2012 19:07:55 -0000
@@ -71,6 +71,7 @@
#include <stdarg.h>
#include "pthread.h"
+#include "pthread_int.h"
struct _sem_st {
unsigned int ksem_magic;
(Contact us)
$NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.