From cba7922706a3ce4114e2a955e4a1fe987a869ea9 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Thu, 25 Oct 2007 13:25:42 +0000 Subject: [PATCH] Fix strncpy()/strncat() usage in check_for_driver(). From Johannes Meixner at SuSE. --- ChangeLog | 2 ++ backend/as6e.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5bf0ae433..b28b9fec5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2007-10-25 Julien Blache * sanei/sanei_ab306.c: Fix boundary checking after the for() loop in sanei_ab306_open(). From Johannes Meixner at SuSE. + * backend/as6e.c: Fix strncpy()/strncat() usage in + check_for_driver(). From Johannes Meixner at SuSE. 2007-10-25 Pierre Willenbrock * backend/genesys_gl841.c: Hopefully removed the remaining hardcoded diff --git a/backend/as6e.c b/backend/as6e.c index 65cc95f86..73cedfb53 100644 --- a/backend/as6e.c +++ b/backend/as6e.c @@ -811,9 +811,11 @@ check_for_driver (const char *devname) dir[count - offset] = path[count]; count++; } - strncpy (fullname, dir, NAMESIZE); - strncat (fullname, "/", NAMESIZE); - strncat (fullname, devname, NAMESIZE); + /* use sizeof(fullname)-1 to make sure there is at least one padded null byte */ + strncpy (fullname, dir, sizeof(fullname)-1); + /* take into account that fullname already contains non-null bytes */ + strncat (fullname, "/", sizeof(fullname)-strlen(fullname)-1); + strncat (fullname, devname, sizeof(fullname)-strlen(fullname)-1); if (!stat (fullname, &statbuf)) { modes = statbuf.st_mode;