This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ #16274] Fix shm_open.


Hi,

during second revision of patch I added a explicit null check but for
some reason got these backwards.

As result of testsuite stayed same I assumed it was ok but did not
expected that actual test is:

  /* Create the shared memory object.  */
  fd = shm_open ("/shm-test", O_RDWR | O_CREAT | O_TRUNC | O_EXCL,
0600);
  if (fd == -1)
    {
      /* We don't regard this as a bug.  Simply don't run the test.  It
could
         means there is no such implementation or the object is already
in
         use in which case we don't want to disturb.  */
      perror ("failed to create a shared memory object: shm_open");
      return 0;
    }

which succeeded.


	[BZ #16274]
	sysdeps/unix/sysv/linux/shm_open.c (shm_open): Fix implementation.

diff --git a/sysdeps/unix/sysv/linux/shm_open.c b/sysdeps/unix/sysv/linux/shm_open.c
index 482b49c..7bb2874 100644
--- a/sysdeps/unix/sysv/linux/shm_open.c
+++ b/sysdeps/unix/sysv/linux/shm_open.c
@@ -151,7 +151,7 @@ shm_open (const char *name, int oflag, mode_t mode)
   namelen = strlen (name);
 
   /* Validate the filename.  */
-  if (name[0] == '\0' || namelen > NAME_MAX || strchr (name, '/') == NULL)
+  if (name[0] == '\0' || namelen > NAME_MAX || strchr (name, '/') != NULL)
     {
       __set_errno (EINVAL);
       return -1;
@@ -241,7 +241,7 @@ shm_unlink (const char *name)
   namelen = strlen (name);
 
   /* Validate the filename.  */
-  if (name[0] == '\0' || namelen > NAME_MAX || strchr (name, '/') == NULL)
+  if (name[0] == '\0' || namelen > NAME_MAX || strchr (name, '/') != NULL)
     {
       __set_errno (ENOENT);
       return -1;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]