Re: [PATCH v2 1/5] ptp-gadget: Fix issue in enum_object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Guennadi,

> On Fri, 9 Apr 2010, Anatolij Gustschin wrote:
>
>> Sometimes not all objects from the image directory are
>> imported. Removing this dentry->d_name zero-termination
>> seems to fix the problem. dentry->d_name is zero-terminated,
>> no need to terminate it.
>
> Sorry, do not understand. The only possibility for this is if the name 
> doesn't fit, and then it overwrites following fields in dentry... So, I'm 
> hesitant to accept this fix. Can you verify exactly which cases fail? on 
> which files?

Check include/linux/dirent.h and you will see

char            d_name[0];

The man-page for readdir(3) says:

  The only fields in the dirent structure that are mandated by POSIX.1
  are: d_name[], of unspecified size, with at most NAME_MAX characters
  preceding the terminating null byte; and (as an XSI extension) d_ino.

So the assignment indeed is a bad idea.  It looks like
sizeof(dentry->d_name) in the testprogram always evaluates to 256,
although d_name is dynamically allocated.  If you modify the testprogram
to write a counter value instead of \0, you will notice that the
substitutions scramble _subsequent_ entries in the list.

All in all Anatolijs patch is a real bugfix.

Cheers
  Detlev

-- 
I will use free software even if it is less powerful, or less reliable,
because freedom is the most important thing, and that is what the Free
Software movement is about.  How we get freedom.
                       -- Richard M. Stallman
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu@xxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux