From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 52291 invoked by alias); 12 Oct 2018 15:58:44 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 52274 invoked by uid 89); 12 Oct 2018 15:58:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-123.2 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=mails, our X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Oct 2018 15:58:42 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MIxmm-1fw5cI0c2s-00KN43 for ; Fri, 12 Oct 2018 17:58:40 +0200 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MIxmm-1fw5cI0c2s-00KN43 for ; Fri, 12 Oct 2018 17:58:40 +0200 Received: by calimero.vinschen.de (Postfix, from userid 500) id 83C0AA8045E; Fri, 12 Oct 2018 17:58:39 +0200 (CEST) Date: Fri, 12 Oct 2018 15:58:00 -0000 From: Corinna Vinschen To: cygwin-apps@cygwin.com Subject: Re: [PATCH setup] Avoid stringop-overflow warning with gcc8 Message-ID: <20181012155839.GG7872@calimero.vinschen.de> Reply-To: cygwin-apps@cygwin.com Mail-Followup-To: cygwin-apps@cygwin.com References: <20181012154349.46104-1-jon.turney@dronecode.org.uk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="i3lJ51RuaGWuFYNw" Content-Disposition: inline In-Reply-To: <20181012154349.46104-1-jon.turney@dronecode.org.uk> User-Agent: Mutt/1.9.2 (2017-12-15) X-SW-Source: 2018-10/txt/msg00025.txt.bz2 --i3lJ51RuaGWuFYNw Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1573 On Oct 12 16:43, Jon Turney wrote: > desktop.cc: In function 'void start_menu(const string&, const string&, co= nst string&, const string&)': > desktop.cc:110:11: error: 'char* strncat(char*, const char*, size_t)' spe= cified bound 260 equals destination size [-Werror=3Dstringop-overflow=3D] >=20 > I think strlcat() was meant here, which MinGW doesn't have. In it's > absence, open-code it's equivalent. >=20 > (SHGetSpecialFolderLocation() returns a pathname of length at most MAX_PA= TH, > and make_link() is limited to accepting a pathname of length MAX_PATH, so= we > want to append our folder name, while truncating the result to MAX_PATH.) > --- > desktop.cc | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) >=20 > diff --git a/desktop.cc b/desktop.cc > index 927c02f..d003e91 100644 > --- a/desktop.cc > +++ b/desktop.cc > @@ -107,7 +107,8 @@ start_menu (const std::string& title, const std::stri= ng& target, > issystem ? CSIDL_COMMON_PROGRAMS : > CSIDL_PROGRAMS, &id); > SHGetPathFromIDList (id, path); > - strncat (path, "/Cygwin", MAX_PATH); > + strncat (path, "/Cygwin", MAX_PATH - strlen(path)); Shouldn't that be strncat (path, "/Cygwin", MAX_PATH - strlen(path) - 1); ? "If src contains n or more bytes, strncat() writes n+1 bytes to dest (n from src plus the terminating null byte). Therefore, the size of dest must be at least strlen(dest)+n+1." Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --i3lJ51RuaGWuFYNw Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlvAxK8ACgkQ9TYGna5E T6A3pBAAm+oes6AhR3AajzMvT7UFW9+ZMp+jfYPuaMCf0fQ08CLm519NLERujEiD azIg/yX/uXnT/YW3s743uk1wh0xwsJ9Gx9shC/o4GPgVpwxaNuNNwR6wNPW//GbR SoBwtDTyqsGEgGHcq1CUU1xmBHuOB3YjsMDwKbCZpxvY6ywMpU1MxH8b74tHHtEA dF15hHgkxMDAsVmAdoQim3paipLswc3NQi5OHbsQSUKNl0jW9q4NkVbcDlswFk71 jMBVhiIW1V3S9p0PBBSgaCrxV9aOZO9wG6Dbqkq8CNNRfbddPQFpzlAQf+ap1iwn zuL9wJts3Ww3O7RYPB1wMW0iGPiieLfeDIzGzIh1QDFhbJGH6H6fUGfpNHEBttC/ CCOjpQFctgkJqqhoPgkmWjf2PRSTXNLGPBm4eRFhDnhxyn4sP3erXZj10cjNhTp2 LC0U4QKDQkjPeTu0zj6cdnG/centyWtnMeMVHUcUaTyVXkr21JlYV/XbKJaf5wS8 evZXbo8nj5oREvtK9bORGLkzmKhWQ6Djci7IhCUCk+ea1taxO0aLLQs7yLSy4pnt Tohya8K+XNj94giTbUUDjlPrKV0/ysZRx/bkCr/LB8QFQus0wbHsN3iJNqMCisbd Og4YJ6hoA1evwrtadQ8tNN26GVCeXxLNsndV5i3KQoHnfTdOiTE= =0NL2 -----END PGP SIGNATURE----- --i3lJ51RuaGWuFYNw--