GNU bug report logs - #9077
coreutils-8.12: fiemap.h uses "struct fiemap_extent fm_extents[0];"

Previous Next

Package: coreutils;

Reported by: "Joachim Schmitz" <jojo <at> schmitz-digital.de>

Date: Thu, 14 Jul 2011 07:05:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


Message #22 received at 9077-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 9077-done <at> debbugs.gnu.org, Joachim Schmitz <jojo <at> schmitz-digital.de>
Subject: Re: bug#9077: coreutils-8.12: fiemap.h uses "struct fiemap_extent
	fm_extents[0]; "
Date: Sat, 16 Jul 2011 09:37:38 +0100
On 15/07/11 23:45, Paul Eggert wrote:
> On 07/15/11 02:49, Pádraig Brady wrote:
>> +#ifdef __linux__
>> +  struct fiemap_extent fm_extents[0];
>> +#endif
> 
> This assumes that all GNU/Linux compiles will
> use a compiler that allows size-zero arrays;
> also, it assumes that sizeof (struct fiemap)
> == offsetof (struct fiemap, fm_extents).
> Although both assumptions are probably
> portable in practice in this particular case,
> it's better to avoid them, if avoiding them is easy.
> This will help future-proof the code if we alter the
> data structures, as altering them might cause problems
> such as what I recently encountered in GNU Emacs's C code.
> 
> How about the following further patch?  It should do the trick.

I tested that and it didn't work.
Even though the *fiemap structs are the same in mem
with and without the change, the ioctl() is returning ENOTTY
when the array is of size 1.  I guess this is because
the array element is unpacked for the ioctl which
is then failing kernel checks.

cheers,
Pádraig.




This bug report was last modified 14 years and 8 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.