emacs-devel
[Top][All Lists]
Advanced

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

Re: oops? read/write vs type of length parameter


From: Jim Meyering
Subject: Re: oops? read/write vs type of length parameter
Date: Mon, 11 Apr 2011 23:54:06 +0200

David Kastrup wrote:
> Jim Meyering <address@hidden> writes:
>
>> What about when EMACS_INT is defined to "int"?
>>
>> Someone will inevitably call your write-like function
>> with a length of type size_t -- many existing uses do just that --
>> and by using a signed type, you will have converted their long
>> yet valid (2-4GiB), buffer length, into a negative number.
>
> Resulting in an error or nothing happening.  In contrast, if a negative
> number is turned into a long yet valid (2-4GiB) number, it is very
> likely that unintended memory areas will get stomped over.

Since someone mentioned a goal of being able to edit a 2GiB
file, I thought people here would be sensitive to an API policy
that renders that goal unreachable on some systems.

Of course the extra bit doesn't matter when you start with 64,
but starting with only 32, using an unsigned "length" would
avoid that unnecessary limit.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]