From 59e6aee7ae7e21e34c611ae01cee69fe276a1ffb Mon Sep 17 00:00:00 2001 From: Javier Segura Date: Thu, 8 Sep 2011 10:51:19 +0200 Subject: [PATCH] Fixed --- kernelroll.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/kernelroll.c b/kernelroll.c index 8445129..f62037d 100644 --- a/kernelroll.c +++ b/kernelroll.c @@ -70,17 +70,19 @@ asmlinkage int my_open(const char *path, int oflag, mode_t mode) char* p; int r; - p = (char *)(path + strlen(path) - 4); - - if(rollfile != NULL && !strcmp(p, ".mp3")) { - void *buf = kmalloc(len, GFP_KERNEL); - memcpy(buf, path, len); - printk(KERN_INFO "patching %s with %s\n", path, rollfile); - memcpy((void *)path, rollfile, len); - r = o_open(path, oflag, mode); - memcpy((void *)path, buf, len); - kfree(buf); - } else { + if (strlen(path) > 4) { + p = (char *)(path + strlen(path) - 4); + + if(rollfile != NULL && !strcmp(p, ".mp3")) { + void *buf = kmalloc(len, GFP_KERNEL); + memcpy(buf, path, len); + printk(KERN_INFO "patching %s with %s\n", path, rollfile); + memcpy((void *)path, rollfile, len); + r = o_open(path, oflag, mode); + memcpy((void *)path, buf, len); + kfree(buf); + } + }else { r = o_open(path, oflag, mode); }