summaryrefslogtreecommitdiff
path: root/src/libs6
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2024-04-25 12:59:03 +0000
committerLaurent Bercot <ska@appnovation.com>2024-04-25 12:59:03 +0000
commita2f093bca2089bd6b3a7211e895a38e86ed8569d (patch)
tree0d4687001c26300fa84447f64f82bb0b81bca867 /src/libs6
parent8839644def2c898730e21160e73bd3d265d1198b (diff)
downloads6-a2f093bca2089bd6b3a7211e895a38e86ed8569d.tar.xz
bugfix: bad length computation in s6-ftrigrd
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libs6')
-rw-r--r--src/libs6/s6-ftrigrd.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/libs6/s6-ftrigrd.c b/src/libs6/s6-ftrigrd.c
index f5f4864..202ea31 100644
--- a/src/libs6/s6-ftrigrd.c
+++ b/src/libs6/s6-ftrigrd.c
@@ -28,7 +28,7 @@
#include <skalibs/posixishard.h>
#define FTRIGRD_MAXREADS 32
-#define FTRIGRD_BUFSIZE 17
+#define FTRIGRD_BUFSIZE 16
#define dienomem() strerr_diefu1sys(111, "stralloc_catb")
@@ -184,9 +184,10 @@ int main (void)
{
PROG = "s6-ftrigrd" ;
- if (ndelay_on(0) < 0) strerr_diefu2sys(111, "ndelay_on ", "0") ;
- if (ndelay_on(1) < 0) strerr_diefu2sys(111, "ndelay_on ", "1") ;
- if (!sig_ignore(SIGPIPE)) strerr_diefu1sys(111, "ignore SIGPIPE") ;
+ if (ndelay_on(0) == -1 || ndelay_on(1) == -1)
+ strerr_diefu1sys(111, "make fds nonblocking") ;
+ if (!sig_altignore(SIGPIPE))
+ strerr_diefu1sys(111, "ignore SIGPIPE") ;
{
tain deadline ;
@@ -198,9 +199,9 @@ int main (void)
for (;;)
{
- iopause_fd x[3 + genalloc_len(ftrigio, &g)] ;
size_t n = genalloc_len(ftrigio, &g) ;
size_t i = 0 ;
+ iopause_fd x[3 + n] ;
x[0].fd = 0 ; x[0].events = IOPAUSE_EXCEPT | IOPAUSE_READ ;
x[1].fd = 1 ; x[1].events = IOPAUSE_EXCEPT | (textmessage_sender_isempty(textmessage_sender_1) ? 0 : IOPAUSE_WRITE) ;
@@ -208,8 +209,9 @@ int main (void)
x[2].events = IOPAUSE_EXCEPT | (textmessage_sender_isempty(textmessage_sender_x) ? 0 : IOPAUSE_WRITE) ;
for (; i < n ; i++)
{
- genalloc_s(ftrigio, &g)[i].xindex = 3 + i ;
- x[3+i].fd = genalloc_s(ftrigio, &g)[i].trig.fd ;
+ ftrigio *p = genalloc_s(ftrigio, &g) + i ;
+ p->xindex = 3+i ;
+ x[3+i].fd = p->trig.fd ;
x[3+i].events = IOPAUSE_READ ;
}
@@ -228,7 +230,7 @@ int main (void)
return 1 ;
/* scan listening ftrigs */
- for (i = 0 ; i < n ; i++)
+ for (i = 0 ; i < genalloc_len(ftrigio, &g) ; i++)
{
ftrigio *p = genalloc_s(ftrigio, &g) + i ;
if (x[p->xindex].revents & IOPAUSE_READ)