Re: Misc 2.5 Fixes: cp-user-eicon

Dipankar Sarma
2003-06-10T09:56:44Z

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);
}

_