From owner-svn-src-all@FreeBSD.ORG Wed Feb 11 07:26:55 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id CADD0C54 for ; Wed, 11 Feb 2015 07:26:55 +0000 (UTC) Received: from mail-yh0-f48.google.com (mail-yh0-f48.google.com [209.85.213.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8E5CB362 for ; Wed, 11 Feb 2015 07:26:55 +0000 (UTC) Received: by mail-yh0-f48.google.com with SMTP id t59so648783yho.7 for ; Tue, 10 Feb 2015 23:26:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=ofmANMu2bYiHvpfvcT2C9oF7Yji8vwW5f+rupiwHfV8=; b=L95XuzJyBcDGbOoVmCiKkA2MDN7ywVO/vckP5lra7WqbnhApBmoklz9F2oRflecE1f e7NklClUHb1XGE1wI2GKW6nguNPu2eS789TH8S+Cn5uxHzvFOMFRTYbllhM47FCU1Kxe VdcTWOrWX3A3KzOFCZCu5vgbx06c3Lip+7AtSodMSdsJ0OX+f3vAqQSWgY6+xqwT22u3 23aTYgLTp+Ws5L2OVjhjyTvv8wV63cLHIC/I1P7nDEemfv9Qj3KIsVa6+EwUSJp7/QTW HlIE6QSFig2r+HjWejUna5FAoyKoPjwaaLRj+Q49WsNKlu11H8vM7MST4ZlaqfGzkDjA 3HSQ== X-Gm-Message-State: ALoCoQkwOkIlJXIac5CtaMIHpE3h+ZZJqXA1lYof24Y9164nWt0jPu4KAk3/Q4lAok48d3Ovx2lK MIME-Version: 1.0 X-Received: by 10.170.191.211 with SMTP id i202mr836247yke.32.1423638077436; Tue, 10 Feb 2015 23:01:17 -0800 (PST) Received: by 10.170.56.134 with HTTP; Tue, 10 Feb 2015 23:01:17 -0800 (PST) In-Reply-To: <201502110058.t1B0wGYZ032751@svn.freebsd.org> References: <201502110058.t1B0wGYZ032751@svn.freebsd.org> Date: Wed, 11 Feb 2015 08:01:17 +0100 Message-ID: Subject: Re: svn commit: r278545 - head/sys/kern From: Oliver Pinter To: Rui Paulo Content-Type: text/plain; charset=UTF-8 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Feb 2015 07:26:56 -0000 On Wed, Feb 11, 2015 at 1:58 AM, Rui Paulo wrote: > Author: rpaulo > Date: Wed Feb 11 00:58:15 2015 > New Revision: 278545 > URL: https://svnweb.freebsd.org/changeset/base/278545 > > Log: > Restore the data array in coredump(), but use a different style to > calculate the length. > > Requested by: kib > > Modified: > head/sys/kern/kern_sig.c > > Modified: head/sys/kern/kern_sig.c > ============================================================================== > --- head/sys/kern/kern_sig.c Tue Feb 10 23:48:06 2015 (r278544) > +++ head/sys/kern/kern_sig.c Wed Feb 11 00:58:15 2015 (r278545) > @@ -3261,9 +3261,11 @@ coredump(struct thread *td) > void *rl_cookie; > off_t limit; > int compress; > - char data[MAXPATHLEN * 2 + 16]; /* space for devctl notification */ > + char *data = NULL; > char *fullpath, *freepath = NULL; > size_t len; > + static const char comm_name[] = "comm="; > + static const char core_name[] = "core="; > > #ifdef COMPRESS_USER_CORES > compress = compress_user_cores; > @@ -3357,25 +3359,31 @@ close: > */ > if (coredump_devctl == 0) > goto out; > + len = MAXPATHLEN * 2 + sizeof(comm_name) - 1 + > + sizeof(' ') + sizeof(core_name) - 1; > + data = malloc(len, M_TEMP, M_WAITOK); > + if (data == NULL) > + goto out; This check is pointless, as you can see in man 9 malloc: M_WAITOK Indicates that it is OK to wait for resources. If the request cannot be immediately fulfilled, the current process is put to sleep to wait for resources to be released by other processes. The malloc(), realloc(), and reallocf() functions cannot return NULL if M_WAITOK is specified. > if (vn_fullpath_global(td, p->p_textvp, &fullpath, &freepath) != 0) > goto out; > if (!coredump_sanitise_path(fullpath)) > goto out; > - snprintf(data, sizeof(data), "comm=%s ", fullpath); > + snprintf(data, len, "%s%s ", comm_name, fullpath); > free(freepath, M_TEMP); > freepath = NULL; > if (vn_fullpath_global(td, vp, &fullpath, &freepath) != 0) > goto out; > if (!coredump_sanitise_path(fullpath)) > goto out; > - strlcat(data, "core=", sizeof(data)); > - len = strlcat(data, fullpath, sizeof(data)); > + strlcat(data, core_name, len); > + strlcat(data, fullpath, len); > devctl_notify("kernel", "signal", "coredump", data); > out: > #ifdef AUDIT > audit_proc_coredump(td, name, error); > #endif > free(freepath, M_TEMP); > + free(data, M_TEMP); > free(name, M_TEMP); > return (error); > } > _______________________________________________ > svn-src-head@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org"