Be more generous with the semaphore name array size. Large enough PIDs would

lead to overwriting its bounds.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36084 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2010-04-08 15:34:12 +00:00
parent c5a3a6bba8
commit aea8795346
25 changed files with 103 additions and 103 deletions

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2002, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -28,12 +28,12 @@
int main()
{
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
mysemp = sem_open(semname, O_CREAT, 0700, 1) ;
if (mysemp == SEM_FAILED) {
if (mysemp == SEM_FAILED) {
perror(ERROR_PREFIX "sem_open");
return PTS_UNRESOLVED;
}

View File

@ -1,7 +1,7 @@
/* Copyright (c) 2002, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -28,13 +28,13 @@
int main()
{
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
mysemp = sem_open(semname, O_CREAT, 0777, 1);
if (mysemp == SEM_FAILED ) {
if (mysemp == SEM_FAILED ) {
perror(ERROR_PREFIX "sem_open");
return PTS_UNRESOLVED;
}
@ -47,12 +47,12 @@ int main()
/* Make mysemp available for reuse */
mysemp = sem_open(semname, O_CREAT, 0777, 1);
if (mysemp == SEM_FAILED ) {
if (mysemp == SEM_FAILED ) {
perror(ERROR_PREFIX "sem_open");
return PTS_UNRESOLVED;
}
if ((sem_close(mysemp)) == 0) {
puts("TEST PASSED");
sem_unlink(semname);

View File

@ -1,13 +1,13 @@
/*
Copyright (c) 2002, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
/*
sem_close will have no effect on the state of the semaphore if
sem_close will have no effect on the state of the semaphore if
sem_unlink has been unsuccessful.
*/
@ -30,12 +30,12 @@
int main()
{
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
mysemp = sem_open(semname, O_CREAT, 0444, 1) ;
if (mysemp == SEM_FAILED) {
if (mysemp == SEM_FAILED) {
perror(ERROR_PREFIX "sem_open");
return PTS_UNRESOLVED;
}
@ -47,7 +47,7 @@ int main()
}
puts("TEST PASSED");
return PTS_PASS;
} else {
} else {
puts("TEST FAILED");
return PTS_FAIL;

View File

@ -1,14 +1,14 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
/*
* This test case will call sem_getvalue to update the location referenced
* by the semaphpre without effecting the state of the semaphore. The
* by the semaphpre without effecting the state of the semaphore. The
* updated value represents the actual semaphore value when it was called.
*/
@ -29,7 +29,7 @@
int main() {
char semname[20];
char semname[50];
sem_t *mysemp;
int val;
@ -44,7 +44,7 @@ int main() {
if( sem_getvalue(mysemp, &val) == -1 ) {
perror(ERROR_PREFIX "sem_getvalue");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
/*

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -26,7 +26,7 @@
int main() {
char semname[20];
char semname[50];
sem_t *mysemp;
int val;
@ -47,7 +47,7 @@ int main() {
if( sem_getvalue(mysemp, &val) < 0 ) {
perror(ERROR_PREFIX "sem_getvalue");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
/*

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -28,7 +28,7 @@
int main() {
char semname[20];
char semname[50];
sem_t *mysemp;
int val;

View File

@ -1,13 +1,13 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
/*
* This test case verifies that calling sem_getvalue doesn't change the
* This test case verifies that calling sem_getvalue doesn't change the
* state of the semaphore.
*/
@ -27,7 +27,7 @@
int main() {
char semname[20];
char semname[50];
sem_t *mysemp;
int val;
@ -43,7 +43,7 @@ int main() {
if( sem_getvalue(mysemp, &val) == -1 ) {
perror(ERROR_PREFIX "sem_getvalue");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
if ( sem_trywait(mysemp) == -1 ) {
@ -53,7 +53,7 @@ int main() {
if( sem_getvalue(mysemp, &val) == -1 ) {
perror(ERROR_PREFIX "sem_getvalue");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
/*

View File

@ -1,14 +1,14 @@
/*
Copyright (c) 2002-2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
/*
sem_open test case that attempts to open a new semaphoree, and then
try to un-lock it with sem_post. Making sure the semaphore is not locked.
sem_open test case that attempts to open a new semaphoree, and then
try to un-lock it with sem_post. Making sure the semaphore is not locked.
*/
#include <sys/types.h>
@ -28,7 +28,7 @@
int main()
{
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2002-2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
/*

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2002-2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
/*

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
int val;
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
@ -44,7 +44,7 @@ int main() {
if( sem_post(mysemp) == -1 ) {
perror(ERROR_PREFIX "sem_post");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
@ -58,7 +58,7 @@ int main() {
sem_close(mysemp);
sem_unlink(semname);
return PTS_PASS;
} else {
} else {
puts("TEST FAILED");
return PTS_FAIL;
}

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
int val;
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
@ -44,7 +44,7 @@ int main() {
if( sem_post(mysemp) == -1 ) {
perror(ERROR_PREFIX "sem_post");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
@ -58,7 +58,7 @@ int main() {
sem_close(mysemp);
sem_unlink(semname);
return PTS_PASS;
} else {
} else {
puts("TEST FAILED");
return PTS_FAIL;
}

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
@ -42,7 +42,7 @@ int main() {
if( sem_wait(mysemp) == -1 ) {
perror(ERROR_PREFIX "sem_post");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
if(( sem_post(mysemp)) == 0 ) {
@ -50,7 +50,7 @@ int main() {
sem_close(mysemp);
sem_unlink(semname);
return PTS_PASS;
} else {
} else {
puts("TEST FAILED: value of sem_post is not zero");
return PTS_FAIL;
}

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -28,7 +28,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
@ -44,7 +44,7 @@ int main() {
sem_close(mysemp);
sem_unlink(semname);
return PTS_PASS;
} else {
} else {
puts("TEST FAILED: value of sem_post is not returning zero");
return PTS_FAIL;
}

View File

@ -43,7 +43,7 @@ void sighdl(int sig)
}
int main() {
char semname[20];
char semname[50];
int val;
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
@ -59,7 +59,7 @@ int main() {
if( sem_post(gsemp) == -1 ) {
perror(ERROR_PREFIX "sem_post");
exit(PTS_UNRESOLVED);
exit(PTS_UNRESOLVED);
}
/* Checking if the value of the Semaphore incremented by one */

View File

@ -40,12 +40,12 @@ void handler(int signo)
{
if( sem_post(gsemp) == -1 ) {
perror(ERROR_PREFIX "sem_post");
exit(PTS_UNRESOLVED);
exit(PTS_UNRESOLVED);
}
}
int main() {
char semname[20];
char semname[50];
struct sigaction act;
int val;

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());

View File

@ -1,8 +1,8 @@
/*
Copyright (c) 2003, Intel Corporation. All rights reserved.
Created by: majid.awad REMOVE-THIS AT intel DOT com
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
This file is licensed under the GPL license. For the full content
of this license, see the COPYING file at the top level of this
source tree.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());

View File

@ -1,8 +1,8 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: majid.awad REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
int val;
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
@ -45,7 +45,7 @@ int main() {
/* Lock Semaphore */
if( sem_wait(mysemp) == -1 ) {
perror(ERROR_PREFIX "sem_wait");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
@ -60,7 +60,7 @@ int main() {
sem_close(mysemp);
sem_unlink(semname);
return PTS_PASS;
} else {
} else {
puts("TEST FAILED");
return PTS_FAIL;
}

View File

@ -1,13 +1,13 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: majid.awad REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/*
* Keep calling sem_wait until the sempahore is locked. That is
* Keep calling sem_wait until the sempahore is locked. That is
* decrementing the semaphore value by one until its zero or locked.
*/
@ -30,7 +30,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
int value = 10;
int val;
@ -49,7 +49,7 @@ int main() {
perror(ERROR_PREFIX "sem_getvalue");
return PTS_UNRESOLVED;
} else {
value--;
value--;
}
}
@ -63,7 +63,7 @@ int main() {
sem_unlink(semname);
sem_close(mysemp);
return PTS_PASS;
} else {
} else {
puts("TEST FAILED: Semaphore is not locked");
return PTS_FAIL;
}

View File

@ -1,13 +1,13 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: majid.awad REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/*
* sem_trywait shall try to lock the unlocked semaphore and decrement
* sem_trywait shall try to lock the unlocked semaphore and decrement
* the semaphore value by one.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
int val;
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());
@ -45,7 +45,7 @@ int main() {
/* Lock Semaphore by sem_trywait*/
if( sem_trywait(mysemp) == -1 ) {
perror(ERROR_PREFIX "sem_wait");
return PTS_UNRESOLVED;
return PTS_UNRESOLVED;
}
@ -60,7 +60,7 @@ int main() {
sem_unlink(semname);
sem_close(mysemp);
return PTS_PASS;
} else {
} else {
puts("TEST FAILED");
return PTS_FAIL;
}

View File

@ -1,13 +1,13 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: majid.awad REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/*
* sem_trywait shall try to lock the locked semaphore and decrement
* sem_trywait shall try to lock the locked semaphore and decrement
* the semaphore value by one.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());

View File

@ -1,12 +1,12 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: majid.awad REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/* This test case verifies that the semaphore shall be locked until the
/* This test case verifies that the semaphore shall be locked until the
* sem_post is executed and returns successfully.
* Lines: 39056-39057
*/
@ -28,9 +28,9 @@
int main()
{
{
sem_t *mysemp;
char semname[20];
char semname[50];
int val;
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());

View File

@ -1,13 +1,13 @@
/*
* Copyright (c) 2003, Intel Corporation. All rights reserved.
* Created by: majid.awad REMOVE-THIS AT intel DOT com
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* This file is licensed under the GPL license. For the full content
* of this license, see the COPYING file at the top level of this
* source tree.
*/
/*
* errno return EAGAIN: The semaphore can't be immediately locked by
* errno return EAGAIN: The semaphore can't be immediately locked by
* sem_trywait when its already locked.
*/
@ -29,7 +29,7 @@
int main() {
sem_t *mysemp;
char semname[20];
char semname[50];
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());

View File

@ -36,7 +36,7 @@ void handler(int signo)
int main()
{
sem_t *mysemp;
char semname[20];
char semname[50];
int pid, status;
sprintf(semname, "/" FUNCTION "_" TEST "_%ld", (long)getpid());