commit 99118ec69f40736c64eb36def53de3f9b00501d4 from: spoollord date: Fri Jan 18 20:33:39 2019 UTC Fix small issue in subscribe packet parsing commit - 34d398546c3bf3df39aa8f0323799adf56f13003 commit + 99118ec69f40736c64eb36def53de3f9b00501d4 blob - ce75703120b885f23fef4917aeb99bdb685793de blob + 78b15f20fb71ed8451fbc116e70d4b1641c47a1e --- thingsd/client.c +++ thingsd/client.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "thingsd.h" @@ -148,7 +149,6 @@ clt_rd(struct bufferevent *bev, void *arg) if (pkt[0] == 0x7E && pkt[1] == 0x7E && pkt[2] == 0x7E) { memmove(pkt, pkt+3, len+3+1); parse_buf(clt, pkt); - free(pkt); if (clt->subscribed) bufferevent_enable(clt->bev, EV_READ|EV_WRITE); } blob - 4f77ed6d9eea124869a69f768f8075fae15b76be blob + e35a1bc34553038c986f518b74b7879e8090b555 --- thingsd/parse.y +++ thingsd/parse.y @@ -140,6 +140,9 @@ subthgs : THING '{' STRING ',' STRING '}' optcomma { /* check for duplicate name and subscriptions */ TAILQ_FOREACH(clt, &pthgsd->clts, entry) { + log_info("%s:%s", clt->name, my_name); + if (clt->name == NULL || my_name == NULL) + continue; if (strcmp(clt->name, my_name) == 0) { if (my_fd != clt->fd) { fail = true; @@ -449,15 +452,14 @@ int pushback_index = 0; int lgetc(int quotec) { - int c, next; + int c = 0, next; if (parsebuf) { /* Read character from the parsebuffer instead of file input */ if (parseindex >= 0) { c = parsebuf[parseindex++]; if (c != '\0') - return (c); - parsebuf = NULL; + return(c); } else parseindex++; } @@ -769,6 +771,7 @@ parse_buf(struct clt *pclt, u_char *pkt) yyparse(); errors = file->errors; popbuff(); + free(pkt); return (errors ? -1 : 0); }