From fnaumann@mail.cs.uni-magdeburg.de Fri Jan 30 12:59:15 2004 Message-ID: <401A46C4.40307@imperia.net> Date: Fri, 30 Jan 2004 12:57:56 +0100 From: Guido Flohr User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: de, ru, ar, en-us, en, fr MIME-Version: 1.0 To: mint@fishpool.com Subject: Re: [MiNT] SYS_NMLN References: <20040125101601.5315A35450@komp7.euh-e.edu.pl> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed X-Virus-Scanned: by amavisd-new using F-Secure Antivirus at imperia.net Delivered-To: mint@fishpool.com Delivered-To: mint@lists.fishpool.fi X-ecartis-version: Ecartis v1.0.0 Sender: mint-bounce@lists.fishpool.fi Errors-to: mint-bounce@lists.fishpool.fi X-original-sender: guido@imperia.net Precedence: bulk List-help: List-unsubscribe: List-ID: X-List-ID: Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by prinz.cs.uni-magdeburg.de id i0UBxDo01681 Hi, Frank Naumann wrote: > Hello! > > >>>>Brief check gave me that this constan represents length of the >>>>entries of the utsname structure defined in sys/utsname.h. Correct. >>>> >>>>This constant should be also defined in sys/utsname.h and should >>>>be at least 256, so adding No, 256 is a quite large value. It is not a required minimum. >>>> >>>>#define SYS_NMLN 256 >>>> >>>>seems resonable. >>>> >>>>Can the library mainainer(s) express their opinion about it? I'm the ex-maintainer... > After looking at it it's not POSIX (POSIX explicitly state that the length The macro comes from SVID (System V Interface Description). Since it is not ANSI C, it should not be defined unconditionally, but rather like this: #ifdef __USE_SVID # define SYS_NMLN 9 #endif But you should not define that macro at all for the MiNTLib because the definition of that constant suggests that all members of "struct utsname" have a constant length, which is _not_ the case with the MiNTLib. Defining it to a wrong value, may lead to a buffer overflow. The only "safe" definition would be the minimum value 9. So, what's the use of the macro? If it is used as the *constant* size of the structure members, you have to re-write the sources anyhow, since this assumption is wrong for MiNT. If it is used to retrieve the size of a particular member, you can just as well use the sizeof operator. As long as "struct utsname" uses these small sizes, I would rather not define SYS_NMLN at all. This will intentionally provoke compile-time errors, that are easy to fix. Ciao Guido -- Imperia AG, Development Leyboldstr. 10 - D-50354 Hürth - http://www.imperia.net/