summaryrefslogtreecommitdiff
path: root/src/libs6
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2016-01-07 00:17:50 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2016-01-07 00:17:50 +0000
commitbb97405b8709827702891e50b1f4775842f2b48c (patch)
tree186f828e0ec1cf139a579571dc0226802399413a /src/libs6
parent928bea7eec8bcfe1abbf8ac2fe01a65fe31a9ed0 (diff)
downloads6-bb97405b8709827702891e50b1f4775842f2b48c.tar.xz
- fix stupid, stupid s6-ftrigrd crash (thx jjk)
- rc for 2.2.4.3
Diffstat (limited to 'src/libs6')
-rw-r--r--src/libs6/s6-ftrigrd.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/libs6/s6-ftrigrd.c b/src/libs6/s6-ftrigrd.c
index 7a32662..e0bc704 100644
--- a/src/libs6/s6-ftrigrd.c
+++ b/src/libs6/s6-ftrigrd.c
@@ -39,7 +39,6 @@ struct ftrigio_s
uint16 id ; /* given by client */
} ;
#define FTRIGIO_ZERO { .xindex = 0, .trig = FTRIG1_ZERO, .b = BUFFER_INIT(0, -1, 0, 0), .buf = "", .sa = STRALLOC_ZERO, .options = 0, .id = 0 }
-static ftrigio_t const ftrigio_zero = FTRIGIO_ZERO ;
static ftrigio_t a[FTRIGR_MAX] ;
static unsigned int n = 0 ;
@@ -49,7 +48,6 @@ static void ftrigio_deepfree (ftrigio_t *p)
ftrig1_free(&p->trig) ;
stralloc_free(&p->sa) ;
regfree(&p->re) ;
- *p = ftrigio_zero ;
}
static void cleanup (void)
@@ -130,8 +128,12 @@ static int parse_protocol (unixmessage_t const *m, void *context)
{
register unsigned int i = 0 ;
for (; i < n ; i++) if (a[i].id == id) break ;
- if (i < n) remove(i) ;
- answer(0) ;
+ if (i < n)
+ {
+ remove(i) ;
+ answer(0) ;
+ }
+ else answer(EINVAL) ;
break ;
}
case 'L' : /* subscribe to path and match re */
@@ -156,8 +158,6 @@ static int parse_protocol (unixmessage_t const *m, void *context)
answer(ENFILE) ;
break ;
}
- a[n].options = options ;
- a[n].id = id ;
r = regcomp(&a[n].re, m->s + 16 + pathlen, REG_EXTENDED) ;
if (r)
{
@@ -170,12 +170,10 @@ static int parse_protocol (unixmessage_t const *m, void *context)
answer(errno) ;
break ;
}
- if (!buffer_init(&a[n].b, &buffer_read, a[n].trig.fd, a[n].buf, FTRIGRD_BUFSIZE))
- {
- ftrigio_deepfree(a + n) ;
- answer(errno) ;
- break ;
- }
+ buffer_init(&a[n].b, &buffer_read, a[n].trig.fd, a[n].buf, FTRIGRD_BUFSIZE) ;
+ a[n].options = options ;
+ a[n].id = id ;
+ a[n].sa = stralloc_zero ;
n++ ;
answer(0) ;
break ;