[lkml]   [2001]   [Nov]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: more devfs fun
Alexander Viro writes:
> It just gets better and better...

Sorry, Al. You're wrong on this one...

> in get_removable_partition()
> if (strcmp (de->name, "disc") == 0) return check_disc_changed (de);
> with
> if ( name && (namelen < 1) ) namelen = strlen (name);
> if ( ( new = kmalloc (sizeof *new + namelen, GFP_KERNEL) ) == NULL )
> return NULL;
> ...
> if (name) memcpy (new->name, name, namelen);
> in create_entry().
> IOW, ->name is not NUL-terminated.

In fact, it is. Take a look at the declaration of struct devfs_entry
and you'll see that there is one byte already taken up for the name
string. So adding the length of the string yields storage for len+1
bytes. IOW, space for the NULL-terminator. And right after the call to
kmalloc(), I call:
memset (new, 0, sizeof *new + namelen);

which zeros everything, including the terminator.

If I missed something as basic as NULL-termination, the thing probably
wouldn't even boot!


To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:12    [W:1.232 / U:0.016 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site