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

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

 



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@xxxxxxx>
---
 builtin-run.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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)
-- 
2.17.1




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux