[PATCH 1/2] cyclictest: Fix compiler warning about srncpy output truncated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Clark Williams <williams@xxxxxxxxxx>

Fix compiler warning about strncpy output truncated before terminating
nul copying as many bytes from a string as its length

Signed-off-by: Clark Williams <williams@xxxxxxxxxx>
Signed-off-by: John Kacur <jkacur@xxxxxxxxxx>
Extracted from a patch from Clark
---
 src/cyclictest/cyclictest.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 68b3836405c1..1bd63fd93dce 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -1257,7 +1257,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
 		case 'F':
 		case OPT_FIFO:
 			use_fifo = 1;
-			strncpy(fifopath, optarg, strlen(optarg));
+			strncpy(fifopath, optarg, strnlen(optarg, MAX_PATH-1));
 			break;
 		case 'H':
 		case OPT_HISTOFALL:
@@ -1267,7 +1267,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
 			histogram = atoi(optarg); break;
 		case OPT_HISTFILE:
 			use_histfile = 1;
-			strncpy(histfile, optarg, strlen(optarg));
+			strncpy(histfile, optarg, strnlen(optarg, MAX_PATH-1));
 			break;
 		case 'i':
 		case OPT_INTERVAL:
-- 
2.20.1




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux