Bail out of the process early if the coredumpfile limit is 0.

PR:	kern/14540
Reviewed by:	Nate Williams
This commit is contained in:
Sean Eric Fagan 1999-10-30 18:55:11 +00:00
parent 66a84ea766
commit 35a2598f80

View File

@ -1595,11 +1595,17 @@ coredump(p)
return (EFAULT);
/*
* Note that this layout means that limit checking is done
* AFTER the corefile name is created. This could happen
* other ways as well, so I'm not too worried about it, but
* it is potentially confusing.
* Note that the bulk of limit checking is done after
* the corefile is created. The exception is if the limit
* for corefiles is 0, in which case we don't bother
* creating the corefile at all. This layout means that
* a corefile is truncated instead of not being created,
* if it is larger than the limit.
*/
limit = p->p_rlimit[RLIMIT_CORE].rlim_cur;
if (limit == 0)
return 0;
name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p);
error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR);
@ -1620,8 +1626,6 @@ coredump(p)
VOP_SETATTR(vp, &vattr, cred, p);
p->p_acflag |= ACORE;
limit = p->p_rlimit[RLIMIT_CORE].rlim_cur;
error = p->p_sysent->sv_coredump ?
p->p_sysent->sv_coredump(p, vp, limit) :
ENOSYS;