diff options
author | rsc <devnull@localhost> | 2006-05-04 18:02:48 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-05-04 18:02:48 +0000 |
commit | 886a6f6c535f081e5d845db7ba79b16f2b68ef97 (patch) | |
tree | b0c5dea37fda1f3b8e833b12196f2c898e775847 /src/libsunrpc | |
parent | e77222a4ecdf427c2eed2eb44251b8841ef81b3c (diff) | |
download | plan9port-886a6f6c535f081e5d845db7ba79b16f2b68ef97.tar.gz plan9port-886a6f6c535f081e5d845db7ba79b16f2b68ef97.tar.bz2 plan9port-886a6f6c535f081e5d845db7ba79b16f2b68ef97.zip |
rpc fixes (vandebo)
Diffstat (limited to 'src/libsunrpc')
-rw-r--r-- | src/libsunrpc/nfs3.c | 8 | ||||
-rw-r--r-- | src/libsunrpc/rpc.c | 3 | ||||
-rw-r--r-- | src/libsunrpc/server.c | 16 |
3 files changed, 20 insertions, 7 deletions
diff --git a/src/libsunrpc/nfs3.c b/src/libsunrpc/nfs3.c index ee5f9850..836f0bf2 100644 --- a/src/libsunrpc/nfs3.c +++ b/src/libsunrpc/nfs3.c @@ -2938,6 +2938,11 @@ nfs3entrysize(Nfs3Entry *x) a = 0 + 4 + 8 + sunstringsize(x->name) + 8; return a; } +static int +sunstringvpack(uchar *a, uchar *ea, uchar **pa, char **s, u32int n) +{ + return sunvaropaquepack(a, ea, pa, (uchar**)&s, &n, -1); +} int nfs3entrypack(uchar *a, uchar *ea, uchar **pa, Nfs3Entry *x) { @@ -2946,7 +2951,7 @@ nfs3entrypack(uchar *a, uchar *ea, uchar **pa, Nfs3Entry *x) one = 1; if(sunuint1pack(a, ea, &a, &one) < 0) goto Err; if(sunuint64pack(a, ea, &a, &x->fileid) < 0) goto Err; - if(sunstringpack(a, ea, &a, &x->name, -1) < 0) goto Err; + if(sunstringvpack(a, ea, &a, &x->name, x->namelen) < 0) goto Err; if(sunuint64pack(a, ea, &a, &x->cookie) < 0) goto Err; *pa = a; return 0; @@ -2963,6 +2968,7 @@ nfs3entryunpack(uchar *a, uchar *ea, uchar **pa, Nfs3Entry *x) if(sunuint1unpack(a, ea, &a, &one) < 0 || one != 1) goto Err; if(sunuint64unpack(a, ea, &a, &x->fileid) < 0) goto Err; if(sunstringunpack(a, ea, &a, &x->name, -1) < 0) goto Err; + x->namelen = strlen(x->name); if(sunuint64unpack(a, ea, &a, &x->cookie) < 0) goto Err; *pa = a; return 0; diff --git a/src/libsunrpc/rpc.c b/src/libsunrpc/rpc.c index 4c324429..bf042317 100644 --- a/src/libsunrpc/rpc.c +++ b/src/libsunrpc/rpc.c @@ -140,6 +140,7 @@ sunrpcsize(SunRpc *rpc) case SunRpcMismatch: case SunProgMismatch: a += 3*4; + break; default: a += 4; } @@ -439,7 +440,7 @@ sunstringunpack(uchar *a, uchar *ea, uchar **pa, char **s, u32int max) goto Err; /* slide string down over length to make room for NUL */ memmove(dat-1, dat, n); - dat[-1+n] = 0; + dat[n-1] = 0; *s = (char*)(dat-1); return 0; Err: diff --git a/src/libsunrpc/server.c b/src/libsunrpc/server.c index 81358587..43b0f773 100644 --- a/src/libsunrpc/server.c +++ b/src/libsunrpc/server.c @@ -144,11 +144,12 @@ if(srv->chatty) fprint(2, "sun msg %p count %d\n", m, m->count); static SunProg* sunfindprog(SunSrv *srv, SunMsg *m, SunRpc *rpc, Channel **pc) { - int i, vlo, vhi; + int i, vlo, vhi, any; SunProg *pg; - vlo = 0x7fffffff; - vhi = -1; + vlo = 0; + vhi = 0; + any = 0; for(i=0; i<srv->nprog; i++){ pg = srv->prog[i]; @@ -159,10 +160,15 @@ sunfindprog(SunSrv *srv, SunMsg *m, SunRpc *rpc, Channel **pc) return pg; } /* right program, wrong version: record range */ - if(pg->vers < vlo) + if(!any++){ vlo = pg->vers; - if(pg->vers > vhi) vhi = pg->vers; + }else{ + if(pg->vers < vlo) + vlo = pg->vers; + if(pg->vers > vhi) + vhi = pg->vers; + } } if(vhi == -1){ if(srv->chatty) |