fdthread: stop being an asshole and NUL terminate the input #778

This commit is contained in:
nick black 2020-07-09 03:27:06 -04:00
parent 3ef1a3a07d
commit ea183c0d66
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -31,7 +31,7 @@ static void
fdthread(ncfdplane* ncfp, int pidfd){
struct pollfd pfds[2];
memset(pfds, 0, sizeof(pfds));
char* buf = malloc(BUFSIZ);
char* buf = malloc(BUFSIZ + 1);
int pevents;
pfds[0].fd = ncfp->fd;
pfds[0].events = POLLIN;
@ -47,6 +47,7 @@ fdthread(ncfdplane* ncfp, int pidfd){
if(r == 0){
break;
}
buf[r] = '\0';
if( (r = ncfp->cb(ncfp, buf, r, ncfp->curry)) ){
break;
}