@@ -64,38 +64,38 @@ static int verify_address(int type, const void *addr, unsigned int size)
64
64
65
65
void free_name (const char * name )
66
66
{
67
- kfree ((unsigned int )name );
67
+ kfree2 ((unsigned int )name );
68
68
}
69
69
70
70
/*
71
71
* This function has two objectives:
72
72
*
73
73
* 1. verifies the memory address validity of the char pointer supplied by the
74
74
* user and, at the same time, limits its length to PAGE_SIZE (4096) bytes.
75
- * 2. creates a copy of 'filename ' in the kernel data space before using it.
75
+ * 2. creates a copy of 'string ' in the kernel data space before using it.
76
76
*/
77
- int malloc_name (const char * filename , char * * name )
77
+ int malloc_name (const char * string , char * * name )
78
78
{
79
79
short int n , len ;
80
80
char * b ;
81
81
int errno ;
82
82
83
83
/* verifies only the pointer address */
84
- if ((errno = verify_address (PROT_READ , filename , 0 ))) {
84
+ if ((errno = verify_address (PROT_READ , string , 0 ))) {
85
85
return errno ;
86
86
}
87
87
88
- len = MIN (strlen (filename ) , PAGE_SIZE );
89
- if (!(b = (char * )kmalloc ( ))) {
88
+ len = MIN (strlen (string ) + 1 , PAGE_SIZE );
89
+ if (!(b = (char * )kmalloc2 ( len ))) {
90
90
return - ENOMEM ;
91
91
}
92
92
* name = b ;
93
- for (n = 0 ; n < ( len + 1 ) ; n ++ ) {
94
- if (!(* b = * filename )) {
93
+ for (n = 0 ; n < len ; n ++ ) {
94
+ if (!(* b = * string )) {
95
95
return 0 ;
96
96
}
97
97
b ++ ;
98
- filename ++ ;
98
+ string ++ ;
99
99
}
100
100
101
101
free_name (* name );
0 commit comments