sem_new.c (234057) | sem_new.c (241046) |
---|---|
1/* 2 * Copyright (C) 2010 David Xu <davidxu@freebsd.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * | 1/* 2 * Copyright (C) 2010 David Xu <davidxu@freebsd.org>. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 12 unchanged lines hidden (view full) --- 21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 24 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 25 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 26 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 27 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/lib/libc/gen/sem_new.c 234057 2012-04-09 14:17:22Z jilles $ | 29 * $FreeBSD: head/lib/libc/gen/sem_new.c 241046 2012-09-29 11:54:34Z jilles $ |
30 */ 31 32#include "namespace.h" 33#include <sys/types.h> 34#include <sys/queue.h> 35#include <sys/mman.h> 36#include <sys/stat.h> 37#include <errno.h> --- 155 unchanged lines hidden (view full) --- 193 strcpy(ni->name, name); 194 195 strcpy(path, SEM_PREFIX); 196 if (strlcat(path, name, sizeof(path)) >= sizeof(path)) { 197 errno = ENAMETOOLONG; 198 goto error; 199 } 200 | 30 */ 31 32#include "namespace.h" 33#include <sys/types.h> 34#include <sys/queue.h> 35#include <sys/mman.h> 36#include <sys/stat.h> 37#include <errno.h> --- 155 unchanged lines hidden (view full) --- 193 strcpy(ni->name, name); 194 195 strcpy(path, SEM_PREFIX); 196 if (strlcat(path, name, sizeof(path)) >= sizeof(path)) { 197 errno = ENAMETOOLONG; 198 goto error; 199 } 200 |
201 fd = _open(path, flags|O_RDWR, mode); | 201 fd = _open(path, flags|O_RDWR|O_CLOEXEC, mode); |
202 if (fd == -1) 203 goto error; 204 if (flock(fd, LOCK_EX) == -1) 205 goto error; 206 if (_fstat(fd, &sb)) { 207 flock(fd, LOCK_UN); 208 goto error; 209 } --- 236 unchanged lines hidden --- | 202 if (fd == -1) 203 goto error; 204 if (flock(fd, LOCK_EX) == -1) 205 goto error; 206 if (_fstat(fd, &sb)) { 207 flock(fd, LOCK_UN); 208 goto error; 209 } --- 236 unchanged lines hidden --- |