From: Simon Wilkinson Date: Mon, 6 Apr 2009 23:50:15 +0000 (+0000) Subject: linux-avoid-returning-invalid-pointers-on-error-20090402 X-Git-Tag: openafs-devel-1_5_61~358 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=160619505de3dbf70f0f0c4a813098113eb42129;p=packages%2Fo%2Fopenafs.git linux-avoid-returning-invalid-pointers-on-error-20090402 LICENSE IPL10 FIXES 124580 avoid returning a positive error as it will look like a pointer. --- diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c index 2fe6222f0..67e7bad36 100644 --- a/src/afs/LINUX/osi_vnodeops.c +++ b/src/afs/LINUX/osi_vnodeops.c @@ -50,6 +50,10 @@ RCSID #define pageoff(pp) pp->offset #endif +#ifndef MAX_ERRNO +#define MAX_ERRNO 1000L +#endif + #if defined(AFS_LINUX26_ENV) #define LockPage(pp) lock_page(pp) #define UnlockPage(pp) unlock_page(pp) @@ -1184,8 +1188,10 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp) if (code == ENOENT) return ERR_PTR(0); #endif - else - return ERR_PTR(-code); + else if ((code >= 0) && (code <= MAX_ERRNO)) + return ERR_PTR(-code); + else + return ERR_PTR(-EIO); #else if (code == ENOENT) code = 0; @@ -1525,7 +1531,10 @@ afs_linux_follow_link(struct dentry *dp, struct dentry *basep, if (code < 0) { dput(basep); - res = ERR_PTR(code); + if (code < -MAX_ERRNO) + res = ERR_PTR(-EIO); + else + res = ERR_PTR(code); } else { name[code] = '\0'; res = lookup_dentry(name, basep, follow); diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c index 2c2bd3c12..eeac33b2d 100644 --- a/src/afs/VNOPS/afs_vnop_lookup.c +++ b/src/afs/VNOPS/afs_vnop_lookup.c @@ -1182,7 +1182,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp) afs_PutVolume(volp, READ_LOCK); /* If we did the InlineBulk RPC pull out the return code */ - if (inlinebulk) { + if (inlinebulk && code == 0) { if ((&statsp[0])->errorCode) { afs_Analyze(tcp, (&statsp[0])->errorCode, &adp->f.fid, areqp, AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL);