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

Bug#308577: partman: devices[index_of_name(name)] is unspecified



Package: partman
Version: 64
Severity: important
Tags: sarge, sid

parted_server has many instances of this sort of code:

        return devices[index_of_name(name)].dev;

However, index_of_name(name) can change the devices pointer, and
according to the C standard the two subexpressions 'devices' and
'index_of_name(name)' may be evaluated in either order. Thus, the
semantics of this code are unspecified, so the compiler is free to
generate code that evaluates 'devices' first, when it's still NULL at
parted_server startup. The practical upshot of this is that
parted_server segfaults immediately on OPEN when compiled with gcc 4.0.

I've fixed this in SVN trunk. I'm not prepared to bet that earlier
versions of gcc will never generate code that evaluates 'devices' before
'index_of_name(name)', so I think we should backport this fix to sarge.

-- 
Colin Watson                                       [cjwatson@debian.org]



Reply to: