@@ -64,38 +64,38 @@ static int verify_address(int type, const void *addr, unsigned int size)
6464
6565void free_name (const char * name )
6666{
67- kfree ((unsigned int )name );
67+ kfree2 ((unsigned int )name );
6868}
6969
7070/*
7171 * This function has two objectives:
7272 *
7373 * 1. verifies the memory address validity of the char pointer supplied by the
7474 * 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.
7676 */
77- int malloc_name (const char * filename , char * * name )
77+ int malloc_name (const char * string , char * * name )
7878{
7979 short int n , len ;
8080 char * b ;
8181 int errno ;
8282
8383 /* verifies only the pointer address */
84- if ((errno = verify_address (PROT_READ , filename , 0 ))) {
84+ if ((errno = verify_address (PROT_READ , string , 0 ))) {
8585 return errno ;
8686 }
8787
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 ))) {
9090 return - ENOMEM ;
9191 }
9292 * 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 )) {
9595 return 0 ;
9696 }
9797 b ++ ;
98- filename ++ ;
98+ string ++ ;
9999 }
100100
101101 free_name (* name );
0 commit comments