| t@@ -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)
{
t@@ -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;
t@@ -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; |
| t@@ -140,6 +140,7 @@ sunrpcsize(SunRpc *rpc)
case SunRpcMismatch:
case SunProgMismatch:
a += 3*4;
+ break;
default:
a += 4;
}
t@@ -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: |
| t@@ -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; inprog; i++){
pg = srv->prog[i];
t@@ -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) |