[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

sem_unlink() succeeded on unlinking ENAMETOOLONG Error.



Latest posix test release from: http://posixtest.sourceforge.net/ 


Bug description:  sem_unlink() succeeded on unlinking ENAMETOOLONG Error.
	Sem_open() shall fail when attempting to create a named semaphore
with NAME_MAX+1.  When doing so, the semaphore doesn't get created, and when
doing sem_unlink on un-created semaphore, sem_unlink reports success.

Expected result:  sem_unlink() shall fail if the length of the name argument
is longer than {NAME_MAX};
	

NPTL Version:  0.24
GLIBC Version: glibc-2.3.1
Kernel Version: 2.5.59



Test Case:

/*
    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 
    source tree.
 */
/*
 * ERROR: ENAMETOOLONG: Trying to unlink a named semaphore which exceeds the
 * maximum of NAME_MAX.
 */

#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <semaphore.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <limits.h>
#include <string.h>
#include "posixtest.h"

#define TEST "5-1"
#define FUNCTION "sem_unlink"
#define ERROR_PREFIX "unexpected error: " FUNCTION " " TEST ": "


int main()
{
	sem_t   *mysemp;
	char semname[NAME_MAX];
    	int i;


	sprintf(semname, "" FUNCTION "_" TEST "_%d", getpid());

	for (i=0; i< NAME_MAX - 10 ; i++) {  /* Making the longer than 255
*/
		strcat(semname,"d");
	}

	mysemp = sem_open(semname, O_CREAT,0,1);
/*
	len = strlen(semname);
	printf("LENGTH %i\n", len);
*/
	sem_unlink(semname);
	if  (errno == ENAMETOOLONG ) 
	{
		puts("TEST PASSED");
		return PTS_PASS;
	} else {
		printf("TEST FAILED ERROR IS: %s\n", strerror(errno)); 
		return PTS_FAIL;
	}

}



----------------------------------------------------------------------------
--------------------------------------
~ MAJID

**These views are not necessarily those of my employer.**






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]