Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

The commit msg should be pretty evident #5

Open
wants to merge 1 commit into from

1 participant

Daniel Pañeda
Daniel Pañeda

Avoid problems with short file names & not crash when rolling file parameter is not provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 09, 2011
Daniel Pañeda Avoid problems with short file names & not crash when rolling file pa…
…rameter is not provided
ff7714a
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 3 deletions. Show diff stats Hide diff stats

  1. 7  kernelroll.c
7  kernelroll.c
@@ -66,13 +66,14 @@ unsigned long **find_sys_call_table(void)
66 66
 asmlinkage int (*o_open)(const char *path, int oflag, mode_t mode); 
67 67
 asmlinkage int my_open(const char *path, int oflag, mode_t mode) 
68 68
 {
69  
-    int len = strlen(rollfile) + 1;
70 69
     char* p;
71 70
     int r;
72 71
 
73  
-    p = (char *)(path + strlen(path) - 4);
  72
+    int pathlen = strlen(path);
  73
+    p = (char *)(path + pathlen - 4);
74 74
 
75  
-    if(rollfile != NULL && !strcmp(p, ".mp3")) {
  75
+    if(rollfile != NULL && pathlen > 3 && !strcmp(p, ".mp3")) {
  76
+        int len = strlen(rollfile) + 1;
76 77
         void *buf = kmalloc(len, GFP_KERNEL);
77 78
         memcpy(buf, path, len);
78 79
         printk(KERN_INFO "patching %s with %s\n", path, rollfile);
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.