[Gllug] Off Topic: C File Descriptors
salsaman at xs4all.nl
salsaman at xs4all.nl
Sun Mar 9 23:15:08 UTC 2008
On Mon, March 10, 2008 00:03, Adrian McMenamin wrote:
>
> On Sun, 2008-03-09 at 23:50 +0100, salsaman at xs4all.nl wrote:
>> On Sun, March 9, 2008 23:26, Nix wrote:
>> > On 8 Mar 2008, Richard Jones said:
>> >
>> >> On Fri, Mar 07, 2008 at 02:41:47AM +0100, salsaman at xs4all.nl wrote:
>> >>> something like this (untested, YMMV) should do it:
>> >> [appallingly bad example of C snipped]
>> >
>> > Oh come on, he allocated a whole 512 bytes for the filename and only
>> had
>> > four coredump-inducing bugs, two misunderstandings of the nature of
>> > dynamic memory allocation,, two useless uses of memset() and two
>> blocks
>> > of cut-and-pasted code. I've seen *much* worse.
>>
>> Say what ? 512 is the maximum path length on Linux, I don't see where
>> the
>> bugs were or how I misunderstood dynamic memory allocation (I presume
>> you
>> mean the sprintf). The memset is needed because readlink() does not
>> append
>> a null byte - check the manpage.
>
> /include/linux/limits.h defines the max path length as 4096
>
Hmmm...it must have increased since I last looked...:-/
/me goes and quickly hacks LiVES.
Gabriel.
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list