diff mbox series

[kvmtool,1/3] builtin-run: Replace strncpy calls with strlcpy

Message ID 20190204163458.188070-2-andre.przywara@arm.com (mailing list archive)
State New, archived
Headers show
Series Fix more GCC 8 strncpy warnings | expand

Commit Message

Andre Przywara Feb. 4, 2019, 4:34 p.m. UTC
There are two uses of strncpy in builtin-run.c, where we don't make
proper use of strncpy, so that GCC 8.x complains and aborts compilation.

Replace those two calls with strlcpy(), which does the right thing in
our case.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 builtin-run.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/builtin-run.c b/builtin-run.c
index 463a481f..f8dc6c72 100644
--- a/builtin-run.c
+++ b/builtin-run.c
@@ -300,7 +300,7 @@  static const char *find_kernel(void)
 			k++;
 			continue;
 		}
-		strncpy(kernel, *k, PATH_MAX);
+		strlcpy(kernel, *k, PATH_MAX);
 		return kernel;
 	}
 
@@ -418,7 +418,7 @@  static void resolve_program(const char *src, char *dst, size_t len)
 			die("Pathname too long: %s -> %s\n", src, resolved_path);
 
 	} else
-		strncpy(dst, src, len);
+		strlcpy(dst, src, len);
 }
 
 static void kvm_run_write_sandbox_cmd(struct kvm *kvm, const char **argv, int argc)