Re: Misc 2.5 Fixes: cp-user-eicon

Dipankar Sarma (dipankar@in.ibm.com)
Tue, 10 Jun 2003 15:40:35 +0530


Use copy_to_user, not memcpy with user buffers

drivers/isdn/eicon/linchr.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)

diff -puN drivers/isdn/eicon/linchr.c~cp-user-eicon drivers/isdn/eicon/linchr.c
--- linux-2.5.70-ds/drivers/isdn/eicon/linchr.c~cp-user-eicon 2003-06-08 03:30:31.000000000 +0530
+++ linux-2.5.70-ds-dipankar/drivers/isdn/eicon/linchr.c 2003-06-08 03:30:31.000000000 +0530
@@ -153,17 +153,17 @@ ssize_t do_read(struct file *pFile, char
klog_t *pHeadItem;

if (BufferSize < sizeof(klog_t))
- {
- printk(KERN_WARNING "Divas: Divalog buffer specifed a size that is too small (%d - %d required)\n",
- BufferSize, sizeof(klog_t));
return -EIO;
- }

pHeadItem = (klog_t *) DivasLogFifoRead();

if (pHeadItem)
{
- memcpy(pClientLogBuffer, pHeadItem, sizeof(klog_t));
+ if(copy_to_user(pClientLogBuffer, pHeadItem, sizeof(klog_t)))
+ {
+ kfree(pHeadItem);
+ return -EFAULT;
+ }
kfree(pHeadItem);
return sizeof(klog_t);
}

_
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/