diff options
author | Tilman Schmidt <tilman@imap.cc> | 2014-10-11 15:46:29 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-14 23:05:33 +0400 |
commit | ee7ff5fed25711a26da7826071e6ede8af049ad2 (patch) | |
tree | b3335735c602a3dc1ac1ec1b5dbb580225c30f90 | |
parent | 1bdc07ebabefd19b56d1d36584a401ff6085fa71 (diff) | |
download | linux-ee7ff5fed25711a26da7826071e6ede8af049ad2.tar.xz |
isdn/gigaset: make sure controller name is null terminated
In gigaset_isdn_regdev, the name field may not have a null terminator
if the source string's length is equal to the buffer size.
Fix by zero filling the structure and excluding the last byte of the
name field from the copy.
Spotted with Coverity.
Signed-off-by: Tilman Schmidt <tilman@imap.cc>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/isdn/gigaset/capi.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c index a2eabe97deea..044392cba262 100644 --- a/drivers/isdn/gigaset/capi.c +++ b/drivers/isdn/gigaset/capi.c @@ -2358,7 +2358,7 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) struct gigaset_capi_ctr *iif; int rc; - iif = kmalloc(sizeof(*iif), GFP_KERNEL); + iif = kzalloc(sizeof(*iif), GFP_KERNEL); if (!iif) { pr_err("%s: out of memory\n", __func__); return -ENOMEM; @@ -2367,7 +2367,7 @@ int gigaset_isdn_regdev(struct cardstate *cs, const char *isdnid) /* prepare controller structure */ iif->ctr.owner = THIS_MODULE; iif->ctr.driverdata = cs; - strncpy(iif->ctr.name, isdnid, sizeof(iif->ctr.name)); + strncpy(iif->ctr.name, isdnid, sizeof(iif->ctr.name) - 1); iif->ctr.driver_name = "gigaset"; iif->ctr.load_firmware = NULL; iif->ctr.reset_ctr = NULL; |