File: 0003-Replace-incorrect-use-of-strncpy-with-memcpy.patch

package info (click to toggle)
powerpc-utils 1.3.8-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,008 kB
  • sloc: ansic: 17,187; sh: 3,662; perl: 980; makefile: 214
file content (35 lines) | stat: -rw-r--r-- 1,128 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Date: Sun, 8 Nov 2020 13:30:03 +0100
Subject: Replace incorrect use of strncpy() with memcpy()

---
 src/errinjct/ioa_bus_error.c | 2 +-
 src/serv_config.c            | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/errinjct/ioa_bus_error.c b/src/errinjct/ioa_bus_error.c
index 45262e5..cb61bd0 100644
--- a/src/errinjct/ioa_bus_error.c
+++ b/src/errinjct/ioa_bus_error.c
@@ -204,7 +204,7 @@ static uint32_t get_config_addr_from_reg(char *devpath)
 	uint32_t *be_caddr;
 	uint32_t caddr = 0;
 
-	strncpy(path, devpath, BUFSZ-5);
+	memcpy(path, devpath, BUFSZ-5);
 	strcat(path, "/reg");
 
 	buf = read_file(path, NULL);
diff --git a/src/serv_config.c b/src/serv_config.c
index 00ab672..2565533 100644
--- a/src/serv_config.c
+++ b/src/serv_config.c
@@ -707,7 +707,7 @@ retrieve_value(struct service_var *var, char *buf, size_t size) {
 				byte_to_string(param[2], buf, size);
 			}
 			else {
-				strncpy(buf, param+2, ((size>ret_size)?
+				memcpy(buf, param+2, ((size>ret_size)?
 					ret_size:size));
 				buf[ret_size] = '\0';
 			}