From: Oliver Kurth Date: Fri, 2 Aug 2019 18:07:19 +0000 (-0700) Subject: Fix gcc 9.1 build error in vmblocktest.c X-Git-Tag: stable-11.1.0~294 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=553d128348f311080e156519e9ac26a518c8579d;p=thirdparty%2Fopen-vm-tools.git Fix gcc 9.1 build error in vmblocktest.c GCC 9.1 in Ubuntu eoan (19.10) failed to build open-vm-tools: error: '__builtin_strncpy' specified bound 4096 equals destination size [-Werror=stringop-truncation] --- diff --git a/open-vm-tools/tests/testVmblock/vmblocktest.c b/open-vm-tools/tests/testVmblock/vmblocktest.c index b018301a9..c45f1b550 100644 --- a/open-vm-tools/tests/testVmblock/vmblocktest.c +++ b/open-vm-tools/tests/testVmblock/vmblocktest.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2006-2017 VMware, Inc. All rights reserved. + * Copyright (C) 2006-2017,2019 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -233,7 +233,8 @@ main(int argc, } create_file: - strncpy(buf, files[i].blockerName, sizeof buf); + strncpy(buf, files[i].blockerName, sizeof buf - 1); + buf[sizeof buf - 1] = '\0'; strncat(buf, FILENAME, sizeof buf - strlen(files[i].blockerName)); err = stat(buf, &statbuf); if (!err) {