]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Fix gcc 9.1 build error in vmblocktest.c
authorOliver Kurth <okurth@vmware.com>
Mon, 5 Aug 2019 18:21:59 +0000 (11:21 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 5 Aug 2019 18:21:59 +0000 (11:21 -0700)
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]

open-vm-tools/tests/testVmblock/vmblocktest.c

index b018301a974d59462201b087b79f9abbff39ec89..c45f1b5500ca75d037f063a95f1cdfe1b3fbe16d 100644 (file)
@@ -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) {