Skip to content

Commit

Permalink
isdn: fix information leak
Browse files Browse the repository at this point in the history
The main motivation of this patch changing strcpy() to strlcpy().
We strcpy() to copy a 48 byte buffers into a 49 byte buffers.  So at
best the last byte has leaked information, or maybe there is an
overflow?  Anyway, this patch closes the information leaks by zeroing
the memory and the calls to strlcpy() prevent overflows.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dan Carpenter authored and David S. Miller committed Aug 5, 2010
1 parent ce9e76c commit 4b030d4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/isdn/sc/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ int sc_ioctl(int card, scs_ioctl *data)
pr_debug("%s: SCIOGETSPID: ioctl received\n",
sc_adapter[card]->devicename);

spid = kmalloc(SCIOC_SPIDSIZE, GFP_KERNEL);
spid = kzalloc(SCIOC_SPIDSIZE, GFP_KERNEL);
if (!spid) {
kfree(rcvmsg);
return -ENOMEM;
Expand All @@ -194,7 +194,7 @@ int sc_ioctl(int card, scs_ioctl *data)
kfree(rcvmsg);
return status;
}
strcpy(spid, rcvmsg->msg_data.byte_array);
strlcpy(spid, rcvmsg->msg_data.byte_array, SCIOC_SPIDSIZE);

/*
* Package the switch type and send to user space
Expand Down Expand Up @@ -266,12 +266,12 @@ int sc_ioctl(int card, scs_ioctl *data)
return status;
}

dn = kmalloc(SCIOC_DNSIZE, GFP_KERNEL);
dn = kzalloc(SCIOC_DNSIZE, GFP_KERNEL);
if (!dn) {
kfree(rcvmsg);
return -ENOMEM;
}
strcpy(dn, rcvmsg->msg_data.byte_array);
strlcpy(dn, rcvmsg->msg_data.byte_array, SCIOC_DNSIZE);
kfree(rcvmsg);

/*
Expand Down Expand Up @@ -337,7 +337,7 @@ int sc_ioctl(int card, scs_ioctl *data)
pr_debug("%s: SCIOSTAT: ioctl received\n",
sc_adapter[card]->devicename);

bi = kmalloc (sizeof(boardInfo), GFP_KERNEL);
bi = kzalloc(sizeof(boardInfo), GFP_KERNEL);
if (!bi) {
kfree(rcvmsg);
return -ENOMEM;
Expand Down

0 comments on commit 4b030d4

Please sign in to comment.