[KPhotoAlbum] Patch to speed up scanning for new images

Shawn Willden shawn-kimdaba at willden.org
Fri May 11 05:33:31 BST 2007


On Thursday 10 May 2007 07:13:23 pm Robert L Krawitz wrote:
> You win some and you lose some.  I understand the problem, but it
> doesn't sound like there's really a safe way around it, since
> KPhotoAlbum is threaded.

I don't think it's a such a large concern in this case.  As long as the 
system-defined MAXNAMLEN really is the maximum filename length on the system, 
it's safe, no overflow is possible.  And, actually, it's even safer than that 
since you allocated sizeof(struct dirent) + MAXNAMLEN + 1 bytes, and struct 
dirent already allocates 256 bytes for the name.  So, on my system, your code 
allocates 512 bytes, where no more than 256 should ever be needed.  As the 
security advisory Jan linked to says, some systems have a small dirent 
structure, but the code should be safe even on those, as long as MAXNAMLEN is 
correct.

For a little extra insurance, it might be a good idea to allocate the data 
from the heap rather than the stack.

	Shawn.



More information about the Kphotoalbum mailing list