From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120513 invoked by alias); 12 Oct 2018 15:44:07 -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 120251 invoked by uid 89); 12 Oct 2018 15:44:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_LAZY_DOMAIN_SECURITY,KAM_NUMSUBJECT,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*r:9.0.019, 1077, Hx-languages-length:1226, 2170 X-HELO: rgout0703.bt.lon5.cpcloud.co.uk Received: from rgout0703.bt.lon5.cpcloud.co.uk (HELO rgout0703.bt.lon5.cpcloud.co.uk) (65.20.0.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 12 Oct 2018 15:44:04 +0000 X-OWM-Source-IP: 31.51.205.159 (GB) X-OWM-Env-Sender: jonturney@btinternet.com X-VadeSecure-score: verdict=clean score=0/300, class=clean X-SNCR-VADESECURE: CLEAN Received: from localhost.localdomain (31.51.205.159) by rgout07.bt.lon5.cpcloud.co.uk (9.0.019.26-1) (authenticated as jonturney@btinternet.com) id 5B9AED2F0289407B; Fri, 12 Oct 2018 16:44:02 +0100 From: Jon Turney To: cygwin-apps@cygwin.com Cc: Jon Turney Subject: [PATCH setup] Avoid stringop-overflow warning with gcc8 Date: Fri, 12 Oct 2018 15:44:00 -0000 Message-Id: <20181012154349.46104-1-jon.turney@dronecode.org.uk> X-SW-Source: 2018-10/txt/msg00024.txt.bz2 desktop.cc: In function 'void start_menu(const string&, const string&, const string&, const string&)': desktop.cc:110:11: error: 'char* strncat(char*, const char*, size_t)' specified bound 260 equals destination size [-Werror=stringop-overflow=] I think strlcat() was meant here, which MinGW doesn't have. In it's absence, open-code it's equivalent. (SHGetSpecialFolderLocation() returns a pathname of length at most MAX_PATH, 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(-) 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::string& target, issystem ? CSIDL_COMMON_PROGRAMS : CSIDL_PROGRAMS, &id); SHGetPathFromIDList (id, path); - strncat (path, "/Cygwin", MAX_PATH); + strncat (path, "/Cygwin", MAX_PATH - strlen(path)); + path[MAX_PATH-1] = 0; LogBabblePrintf ("Program directory for program link: %s", path); make_link (path, title, target, arg, iconpath); } -- 2.17.0