From 5e6b9141c11ebfd809acb69c7c672c6612334359 Mon Sep 17 00:00:00 2001 From: Marek Pola Date: Thu, 5 Feb 2015 14:22:34 +0100 Subject: [PATCH] prevent ioctl_init() to write outside buffer The strncpy operation does not write a 0 termination if the name is larger than the target buffer. Ensure that zero termination is always written using safe strlcpy function. Change-Id: Idb68cdff7cd1a860c1dfac7494fa99f3d382cb91 --- cryptfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cryptfs.c b/cryptfs.c index aaa2b86..f45a200 100644 --- a/cryptfs.c +++ b/cryptfs.c @@ -326,7 +326,7 @@ static void ioctl_init(struct dm_ioctl *io, size_t dataSize, const char *name, u io->version[2] = 0; io->flags = flags; if (name) { - strncpy(io->name, name, sizeof(io->name)); + strlcpy(io->name, name, sizeof(io->name)); } }