Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Ceterum censeo Applem delendam esse.
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 1 Mar 2016 10:41:15 +0000 (11:41 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 1 Mar 2016 10:41:15 +0000 (11:41 +0100)
src/smpi/smpi_bench.cpp

index 21f2fd0..bbc31dc 100644 (file)
@@ -489,8 +489,8 @@ void *smpi_shared_malloc(size_t size, const char *file, int line)
     if (res.second) {
       // The insertion did not take place.
       // Generate a shared memory name from the address of the shared_data:
     if (res.second) {
       // The insertion did not take place.
       // Generate a shared memory name from the address of the shared_data:
-      char shmname[256];
-      sprintf(shmname, "/shmalloc%p", &*data);
+      char shmname[32]; // cannot be longer than PSHMNAMLEN = 31 on Mac OS X (shm_open raises ENAMETOOLONG otherwise)
+      snprintf(shmname, 31, "/shmalloc%p", &*data);
       fd = shm_open(shmname, O_RDWR | O_CREAT | O_EXCL,
                     S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
       if (fd < 0) {
       fd = shm_open(shmname, O_RDWR | O_CREAT | O_EXCL,
                     S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
       if (fd < 0) {