diff --git a/cmd/wmiifs.c b/cmd/wmiifs.c index 5431a03a..5c038c4d 100644 --- a/cmd/wmiifs.c +++ b/cmd/wmiifs.c @@ -100,6 +100,8 @@ xunbind(Bind *b) { cext_array_detach((void **)bind, b, &bindsz); nbind--; ixp_client_deinit(&b->client); + if(b->tx && b->tx->close) + b->tx->close(b->tx); free(b); } @@ -113,7 +115,7 @@ close_rx_conn(IXPConn *c) } static Bind * -xbind(char *address, unsigned int fid, IXPConn *tx) +xbind(char *address, unsigned int fid) { char addr[256]; Bind *b = cext_emallocz(sizeof(Bind)); @@ -124,7 +126,6 @@ xbind(char *address, unsigned int fid, IXPConn *tx) return nil; } b->rx = ixp_server_open_conn(&srv, b->client.fd, do_mnt_fcall, close_rx_conn); - b->tx = tx; bind = (Bind **)cext_array_attach((void **)bind, b, sizeof(Bind *), &bindsz); nbind++; return b; @@ -390,7 +391,7 @@ xwalk(IXPConn *c, Fcall *fcall) unsigned int i; Bind *b; - if(!(b = xbind(mnt->address, fcall->fid, c))) + if(!(b = xbind(mnt->address, fcall->fid))) return Enoserv; memcpy(&b->client.fcall, fcall, sizeof(Fcall)); @@ -408,6 +409,7 @@ xwalk(IXPConn *c, Fcall *fcall) xunbind(b); return Enofile; } + b->tx = c; return nil; } else { diff --git a/cmd/wmiikeys.c b/cmd/wmiikeys.c index 2a33a476..2b6f583e 100644 --- a/cmd/wmiikeys.c +++ b/cmd/wmiikeys.c @@ -637,6 +637,8 @@ xwrite(IXPConn *c, Fcall *fcall) destroy_key(k); } } + if(!fcall->count) + break; memcpy(fcallbuf, fcall->data, fcall->count); fcallbuf[fcall->count] = 0; if(fcall->offset) { @@ -656,6 +658,8 @@ xwrite(IXPConn *c, Fcall *fcall) memcpy(last, fcall->data, fcall->count); while(p2 - fcallbuf < fcall->count) { p1 = strchr(p2, '\n'); + if(!p1) + return "cannot grab, no \n supplied"; *p1 = 0; k = create_key(p2); key = (Key **)cext_array_attach((void **)key, k, sizeof(Key *), &keysz);