Subject: | invalid shmid should set errno |
Awfully sorry about this... but I realized my shmat() patch was a bit lacking.
Namely, it didn't set the errno in the case of invalid shmid.
Patch against 2.05 attached. Tested in OS X, FreeBSD, Linux, and Solaris. The SETERRNO() defining might be paranoia, but cannot remember when it was added.
Subject: | 0001-Need-to-set-the-errno-in-case-of-bogus-shmid.patch |
From aa1ba210ebbcb926c69ff6898007ae19e78c8bdd Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Wed, 17 Feb 2016 21:09:26 -0500
Subject: [PATCH] Need to set the errno in case of bogus shmid.
---
cpan/IPC-SysV/SysV.xs | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/cpan/IPC-SysV/SysV.xs b/cpan/IPC-SysV/SysV.xs
index 121a164..88e4042 100644
--- a/cpan/IPC-SysV/SysV.xs
+++ b/cpan/IPC-SysV/SysV.xs
@@ -114,6 +114,10 @@ static void assert_data_length(const char *name, int got, int expected)
}
}
+#ifndef SETERRNO
+# define SETERRNO(errcode,vmserrcode) (errno = (errcode))
+#endif
+
#include "const-c.inc"
@@ -398,6 +402,7 @@ shmat(id, addr, flag)
ST(0) = shm == (void *) -1 ? &PL_sv_undef
: sv_2mortal(newSVpvn((char *) &shm, sizeof(void *)));
} else {
+ SETERRNO(EINVAL,LIB_INVARG);
ST(0) = &PL_sv_undef;
}
XSRETURN(1);
--
2.7.1