OpenSolaris

Printable Version Enter a New Search
Bug ID 6348365
Synopsis S_IFMT comparison abuse in X
State 10-Fix Delivered (Fix available in build)
Category:Subcategory xserver:source
Keywords
Responsible Engineer Alan Coopersmith
Reported Against
Duplicate Of
Introduced In
Commit to Fix snv_30
Fixed In snv_30
Release Fixed solaris_nevada(snv_30)
Related Bugs 6346809 , 6355067
Submit Date 10-November-2005
Last Update Date 16-January-2007
Description
As noted by Casper in ON bug 6346809:

   The st_mode field of "struct stat" includes a field which is the type of the file.

   This type field is several bits wide but since each file can have only one type, 
   it's not a bit mask; it's a value.

   Unfortunately, not all programmers are aware of this and rather  than using:
	S_ISDIR(st_mode)
   or
	(st_mode & S_IFMT) == S_IFDIR

   they use constructs like:

	st_mode & S_IFCHR (which is also true for block devices, event ports and sockets)
	(st_mode & S_IFDIR ) == S_IFDIR  (close but no cigar)

Misuse of these in the Xorg codebase is being fixed in Xorg 6.9 under
https://bugs.freedesktop.org/show_bug.cgi?id=5003

There are a number of places in the rest of the Solaris X code base this needs to be fixed
though.
Work Around
N/A
Comments
N/A