From owner-svn-src-head@freebsd.org Sat Jan 26 22:24:16 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E8BD014B0AA8; Sat, 26 Jan 2019 22:24:15 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8DD2B7021E; Sat, 26 Jan 2019 22:24:15 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7F4D926670; Sat, 26 Jan 2019 22:24:15 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x0QMOFe4034235; Sat, 26 Jan 2019 22:24:15 GMT (envelope-from se@FreeBSD.org) Received: (from se@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x0QMOFca034234; Sat, 26 Jan 2019 22:24:15 GMT (envelope-from se@FreeBSD.org) Message-Id: <201901262224.x0QMOFca034234@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: se set sender to se@FreeBSD.org using -f From: Stefan Esser Date: Sat, 26 Jan 2019 22:24:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r343482 - head/lib/libfigpar X-SVN-Group: head X-SVN-Commit-Author: se X-SVN-Commit-Paths: head/lib/libfigpar X-SVN-Commit-Revision: 343482 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8DD2B7021E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_SHORT(-0.98)[-0.977,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jan 2019 22:24:16 -0000 Author: se Date: Sat Jan 26 22:24:15 2019 New Revision: 343482 URL: https://svnweb.freebsd.org/changeset/base/343482 Log: Slightly improve previous commit that silenced a Clang Scan warning. The strdup() call does not take advantage of the known length of the source string. Replace by malloc() and memcpy() utilizimng the pre- calculated string length. Submitted by: cperciva Reported by: rgrimes MFC after: 2 weeks Modified: head/lib/libfigpar/string_m.c Modified: head/lib/libfigpar/string_m.c ============================================================================== --- head/lib/libfigpar/string_m.c Sat Jan 26 21:35:51 2019 (r343481) +++ head/lib/libfigpar/string_m.c Sat Jan 26 22:24:15 2019 (r343482) @@ -119,9 +119,10 @@ replaceall(char *source, const char *find, const char /* If replace is longer than find, we'll need to create a temp copy */ if (rlen > flen) { - temp = strdup(source); + temp = malloc(slen + 1); if (temp == NULL) /* could not allocate memory */ return (-1); + memcpy(temp, source, slen + 1); } else temp = source;