On 24.07.2007, at 18:08, Armin Rigo wrote:
Hi Fijal,
On Mon, Jul 23, 2007 at 02:38:32PM +0200, Maciek Fijalkowski wrote:
The length of the arrays in a struct utsname is unspecified; the fields are terminated by a null byte (?????? ???).
I'm completely confused.
It means that the structure looks like this in lltype notation:
Struct('utsname', ('text1', FixedSizeArray(Char, 10)), ('text2', FixedSizeArray(Char, 20)), ...)
where, annoyingly, the numbers '10' and '20' are platform-dependent and must be obtained by trying to compile snippets of C code using sizeof() and offsetof().
Or are you confused about the bit saying that the fields are zero-terminated? It just means that in the array, characters 0 to N-1 are non-null, charater N is null, and the rest of the characters are undefined.
Which reminds us to implement this carefully and not to rely on the terminating byte, or we will open the door to buffer overflow exploits :-) ciao - chris -- Christian Tismer :^) <mailto:tismer@stackless.com> tismerysoft GmbH : Have a break! Take a ride on Python's Johannes-Niemeyer-Weg 9A : *Starship* http://starship.python.net/ 14109 Berlin : PGP key -> http://wwwkeys.pgp.net/ work +49 30 802 86 56 mobile +49 173 24 18 776 fax +49 30 80 90 57 05 PGP 0x57F3BF04 9064 F4E1 D754 C2FF 1619 305B C09C 5A3B 57F3 BF04 whom do you want to sponsor today? http://www.stackless.com/