diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index 16f27ee231..2a84a5df00 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -522,13 +522,13 @@ Check_AtSys(struct vcache *avc, const char *aname, if (AFS_EQ_ATSYS(aname)) { state->offset = 0; - state->name = osi_AllocLargeSpace(MAXSYSNAME); - state->allocked = 1; + state->name_size = MAXSYSNAME; + state->name = osi_AllocLargeSpace(state->name_size); state->index = afs_getsysname(areq, avc, state->name, &num, sysnamelist); } else { state->offset = -1; - state->allocked = 0; + state->name_size = 0; state->index = 0; state->name = (char *)aname; } @@ -545,7 +545,7 @@ Next_AtSys(struct vcache *avc, struct vrequest *areq, return 0; /* No list */ /* Check for the initial state of aname != "@sys" in Check_AtSys */ - if (state->offset == -1 && state->allocked == 0) { + if (state->offset == -1 && state->name_size == 0) { char *tname; /* Check for .*@sys */ @@ -557,7 +557,7 @@ Next_AtSys(struct vcache *avc, struct vrequest *areq, tname = osi_AllocLargeSpace(AFS_LRALLOCSIZ); strncpy(tname, state->name, state->offset); state->name = tname; - state->allocked = 1; + state->name_size = AFS_LRALLOCSIZ; num = 0; state->index = afs_getsysname(areq, avc, state->name + state->offset, &num, diff --git a/src/afs/afs.h b/src/afs/afs.h index 544e5d22e4..0e85cc037d 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -127,8 +127,13 @@ extern afs_int32 afs_rx_idledead_rep; struct sysname_info { char *name; + /* + * 'name_size' represents the number of bytes allocated in 'name'. If 0, + * 'name' points to existing memory, and shouldn't be freed. + */ + size_t name_size; short offset; - signed char index, allocked; + signed char index; }; /* flags to use with AFSOP_CACHEINIT */ diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c index ded774e6f2..1ee1a66eb4 100644 --- a/src/afs/afs_pioctl.c +++ b/src/afs/afs_pioctl.c @@ -2194,7 +2194,7 @@ DECL_PIOCTL(PFlush) * * \return 0 on success; non-zero otherwise. * - * \notes The caller must free asys->name (checking if asys->allocked == 1). + * \notes The caller must free asys->name if asys->name_size != 0. */ static int afs_LookupName(struct vcache *avc, struct vrequest *areq, char *aname, @@ -2324,7 +2324,7 @@ DECL_PIOCTL(PNewStatMount) ReleaseWriteLock(&tvc->lock); afs_PutVCache(tvc); out: - if (sysState.allocked) + if (sysState.name_size != 0) osi_FreeLargeSpace(sysState.name); return code; } @@ -3428,7 +3428,7 @@ DECL_PIOCTL(PRemoveMount) ReleaseWriteLock(&avc->lock); code = 0; out: - if (sysState.allocked) + if (sysState.name_size != 0) osi_FreeLargeSpace(bufp); return code; } @@ -4917,7 +4917,7 @@ DECL_PIOCTL(PFlushMount) ReleaseWriteLock(&tvc->lock); afs_PutVCache(tvc); out: - if (sysState.allocked) + if (sysState.name_size != 0) osi_FreeLargeSpace(sysState.name); return code; } @@ -5688,7 +5688,7 @@ DECL_PIOCTL(PGetLiteralFID) tfid.Fid.Volume = avc->f.fid.Fid.Volume; code = afs_pd_putBytes(aout, &tfid, sizeof(tfid)); out: - if (sysState.allocked) { + if (sysState.name_size != 0) { osi_FreeLargeSpace(sysState.name); } return code;