summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-04-28 10:35:45 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-04-28 10:35:45 +0000
commitdfca03df0761c526bba84af0baa37ac9dbb5b42d (patch)
tree8aa342f6a8217dd2489a2a02f10f0f8ac32c59e3 /src
parent3d480e3f202fc895fc7d36bcf94c654765f647dd (diff)
downloadskalibs-dfca03df0761c526bba84af0baa37ac9dbb5b42d.tar.xz
Fix NSIG definition (max+1 instead of max)
Diffstat (limited to 'src')
-rw-r--r--src/include/skalibs/nsig.h2
-rw-r--r--src/libstddjb/selfpipe_finish.c2
-rw-r--r--src/libstddjb/selfpipe_trapset.c4
-rw-r--r--src/libstddjb/sig_stack.c8
4 files changed, 8 insertions, 8 deletions
diff --git a/src/include/skalibs/nsig.h b/src/include/skalibs/nsig.h
index a75f66d..2cecda9 100644
--- a/src/include/skalibs/nsig.h
+++ b/src/include/skalibs/nsig.h
@@ -5,7 +5,7 @@
#include <skalibs/nonposix.h>
#include <signal.h>
-#define SKALIBS_NSIG 64
+#define SKALIBS_NSIG 65
#ifndef NSIG
# define NSIG SKALIBS_NSIG
diff --git a/src/libstddjb/selfpipe_finish.c b/src/libstddjb/selfpipe_finish.c
index 5d9b3fd..0635efb 100644
--- a/src/libstddjb/selfpipe_finish.c
+++ b/src/libstddjb/selfpipe_finish.c
@@ -25,7 +25,7 @@ void selfpipe_finish (void)
void selfpipe_finish (void)
{
- sig_restoreto(&selfpipe_caught, NSIG) ;
+ sig_restoreto(&selfpipe_caught, NSIG-1) ;
sigemptyset(&selfpipe_caught) ;
fd_close(selfpipe[1]) ;
fd_close(selfpipe[0]) ;
diff --git a/src/libstddjb/selfpipe_trapset.c b/src/libstddjb/selfpipe_trapset.c
index ed09b50..33ac861 100644
--- a/src/libstddjb/selfpipe_trapset.c
+++ b/src/libstddjb/selfpipe_trapset.c
@@ -37,7 +37,7 @@ int selfpipe_trapset (sigset_t const *set)
{
unsigned int i = 1 ;
if (selfpipe_fd < 0) return (errno = EBADF, -1) ;
- for (; i <= NSIG ; i++)
+ for (; i < NSIG ; i++)
{
int h = sigismember(set, i) ;
if (h < 0) continue ;
@@ -50,7 +50,7 @@ int selfpipe_trapset (sigset_t const *set)
if (sig_restore(i) < 0) break ;
}
}
- if (i <= NSIG)
+ if (i < NSIG)
{
int e = errno ;
sig_restoreto(set, i) ;
diff --git a/src/libstddjb/sig_stack.c b/src/libstddjb/sig_stack.c
index c414a88..5897f63 100644
--- a/src/libstddjb/sig_stack.c
+++ b/src/libstddjb/sig_stack.c
@@ -7,12 +7,12 @@
#include <skalibs/sig.h>
#include <skalibs/nsig.h>
-static struct skasigaction skasigstack[NSIG][SIGSTACKSIZE] ;
-static unsigned int sigsp[NSIG] ;
+static struct skasigaction skasigstack[NSIG-1][SIGSTACKSIZE] ;
+static unsigned int sigsp[NSIG-1] ;
int sig_pusha (int sig, struct skasigaction const *ssa)
{
- if ((sig <= 0) || (sig > NSIG)) return (errno = EINVAL, -1) ;
+ if ((sig <= 0) || (sig >= NSIG)) return (errno = EINVAL, -1) ;
if (sigsp[sig-1] >= SIGSTACKSIZE) return (errno = ENOBUFS, -1) ;
if (skasigaction(sig, ssa, &skasigstack[sig-1][sigsp[sig-1]]) == -1)
return -1 ;
@@ -21,7 +21,7 @@ int sig_pusha (int sig, struct skasigaction const *ssa)
int sig_pop (int sig)
{
- if ((sig <= 0) || (sig > NSIG)) return (errno = EINVAL, -1) ;
+ if ((sig <= 0) || (sig >= NSIG)) return (errno = EINVAL, -1) ;
if (!sigsp[sig-1]) return (errno = EFAULT, -1);
if (skasigaction(sig, &skasigstack[sig-1][sigsp[sig-1]-1], 0) == -1)
return -1 ;