From patchwork Tue Nov 6 16:19:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2/2] pci: maxreadreq: ensure we don't overflow with strncpy From: Colin King X-Patchwork-Id: 197498 Message-Id: <1352218770-13472-3-git-send-email-colin.king@canonical.com> To: fwts-devel@lists.ubuntu.com Date: Tue, 6 Nov 2012 16:19:30 +0000 From: Colin Ian King Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin Acked-by: Alex Hung --- src/pci/maxreadreq/maxreadreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pci/maxreadreq/maxreadreq.c b/src/pci/maxreadreq/maxreadreq.c index a570b37..e5ace46 100644 --- a/src/pci/maxreadreq/maxreadreq.c +++ b/src/pci/maxreadreq/maxreadreq.c @@ -88,7 +88,8 @@ static int maxreadreq_test1(fwts_framework *fw) break; } snprintf(current_device, sizeof(current_device), "pci://00:%s", line); - strncpy(current_type, line+8, 511); + strncpy(current_type, line+8, sizeof(current_type)-1); + current_type[sizeof(current_type)-1] = '\0'; c = strchr(current_type, ':'); if (c) *c='\0';