libixp

git clone git://oldgit.suckless.org/libixp/
Log | Files | Refs | LICENSE

commit 1cd1e0ea108a56ccbf4b97f5e46a391f7ff8a76d
parent a4a509c226b422fcecf84f1e7f739e04251a912a
Author: Kris Maglione <kris@suckless.org>
Date:   Sat, 31 Oct 2009 18:06:30 -0400

Fix ixp_srvutils bug in corner case. Closes issue #150.

Diffstat:
include/ixp.h | 2+-
include/ixp_srvutil.h | 2+-
libixp/srv_util.c | 14++++++++++----
3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/ixp.h b/include/ixp.h @@ -7,7 +7,7 @@ #include <sys/types.h> #include <sys/select.h> -#define IXP_API 105 +#define IXP_API 116 /* Gunk */ #if defined(IXP_NEEDAPI) && IXP_API < IXP_NEEDAPI diff --git a/include/ixp_srvutil.h b/include/ixp_srvutil.h @@ -55,7 +55,7 @@ void ixp_pending_flush(Ixp9Req*); void ixp_pending_pushfid(IxpPending*, IxpFid*); void ixp_pending_respond(Ixp9Req*); void ixp_pending_write(IxpPending*, char*, long); -void ixp_srv_clonefiles(IxpFileId*); +IxpFileId* ixp_srv_clonefiles(IxpFileId*); void ixp_srv_data2cstring(Ixp9Req*); void ixp_srv_freefile(IxpFileId*); void ixp_srv_readbuf(Ixp9Req*, char*, uint); diff --git a/libixp/srv_util.c b/libixp/srv_util.c @@ -75,10 +75,17 @@ ixp_srv_freefile(IxpFileId *f) { * Increase the reference count of every IxpFileId linked * to 'f'. */ -void +IxpFileId* ixp_srv_clonefiles(IxpFileId *f) { - for(; f; f=f->next) + IxpFileId *r; + + r = emalloc(sizeof *r); + memcpy(r, f, sizeof *r); + r->tab.name = estrdup(r->tab.name); + r->nref = 1; + for(f=f->next; f; f=f->next) assert(f->nref++); + return r; } void @@ -404,8 +411,7 @@ ixp_srv_walkandclone(Ixp9Req *req, IxpLookupFn lookup) { IxpFileId *file, *tfile; int i; - file = req->fid->aux; - ixp_srv_clonefiles(file); + file = ixp_srv_clonefiles(req->fid->aux); for(i=0; i < req->ifcall.twalk.nwname; i++) { if(!strcmp(req->ifcall.twalk.wname[i], "..")) { if(file->next) {