mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-23 02:04:46 +00:00
Fix memory leak bug in the path parsing code which never released it's
buffer in certain error conditions. Sync up the code to that in NetBSD where applicable. Reviewed by: Gary Jennejohn <garyj@munich.netsurf.de> Submitted by: Michael Smith <msmith@atrad.adelaide.edu.au> Obtained from: NetBSD sources
This commit is contained in:
parent
d8a8289c5a
commit
d0dc9fdb98
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=17450
|
@ -27,7 +27,7 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
|
* from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
|
||||||
* $Id$
|
* $Id: linux_util.c,v 1.1 1996/03/02 19:38:02 peter Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -146,18 +146,18 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
|
if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
|
if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
|
||||||
!= 0) {
|
!= 0) {
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vat.va_fsid == vatroot.va_fsid &&
|
if (vat.va_fsid == vatroot.va_fsid &&
|
||||||
vat.va_fileid == vatroot.va_fileid) {
|
vat.va_fileid == vatroot.va_fileid) {
|
||||||
error = ENOENT;
|
error = ENOENT;
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -170,10 +170,14 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag)
|
||||||
free(buf, M_TEMP);
|
free(buf, M_TEMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
done:
|
|
||||||
vrele(nd.ni_vp);
|
vrele(nd.ni_vp);
|
||||||
if (!cflag)
|
if (!cflag)
|
||||||
vrele(ndroot.ni_vp);
|
vrele(ndroot.ni_vp);
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
bad:
|
||||||
|
vrele(ndroot.ni_vp);
|
||||||
|
vrele(nd.ni_vp);
|
||||||
|
free(buf, M_TEMP);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
|
* from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
|
||||||
* $Id$
|
* $Id: linux_util.c,v 1.1 1996/03/02 19:38:02 peter Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
@ -146,18 +146,18 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
|
if ((error = VOP_GETATTR(nd.ni_vp, &vat, p->p_ucred, p)) != 0) {
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
|
if ((error = VOP_GETATTR(ndroot.ni_vp, &vatroot, p->p_ucred, p))
|
||||||
!= 0) {
|
!= 0) {
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vat.va_fsid == vatroot.va_fsid &&
|
if (vat.va_fsid == vatroot.va_fsid &&
|
||||||
vat.va_fileid == vatroot.va_fileid) {
|
vat.va_fileid == vatroot.va_fileid) {
|
||||||
error = ENOENT;
|
error = ENOENT;
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -170,10 +170,14 @@ linux_emul_find(p, sgp, prefix, path, pbuf, cflag)
|
||||||
free(buf, M_TEMP);
|
free(buf, M_TEMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
done:
|
|
||||||
vrele(nd.ni_vp);
|
vrele(nd.ni_vp);
|
||||||
if (!cflag)
|
if (!cflag)
|
||||||
vrele(ndroot.ni_vp);
|
vrele(ndroot.ni_vp);
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
|
bad:
|
||||||
|
vrele(ndroot.ni_vp);
|
||||||
|
vrele(nd.ni_vp);
|
||||||
|
free(buf, M_TEMP);
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue