Subject: buffer size checking in rfc822_[write_]address?

From: Vadim Zeitlin <[email-masked]>
Date: Tue, 4 Sep 2001 15:29:28 +0200 (CET)

Hello Mark,

 are there any plans to add checks for the provided buffer size (i.e. an
additional size_t argument) for these 2 functions? I've just seen my
program crash and burn because I got a message sent to a hundred or so
people which overflowed a 4Kb buffer I was using for "To" value so far.
Of course, there was

   // FIXME: there is no way to get the address length from c-client, how to
   //        prevent it from overwriting our buffer??

comment in the code, but 4Kb should be enough for any address, right? Well,
it turned out to be wrong, as usual, so now I'm using 8Kb. But IMNSHO this
is just as wrong - and what if I get a message sent to 200 people tomorrow?

 Thank you,
VZ

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mark Crispin <[email-masked]>
Date: Thu, 27 Sep 2001 15:27:04 -0700 (PDT)

On Tue, 4 Sep 2001, Vadim Zeitlin wrote:
> additional size_t argument) for these 2 functions?

These are very old functions (from the very first version of c-client!)
and, as you discovered, don't buffer check.  It was a kinder gentler world
back then, when nobody sent messages to 100+ addresses unless they were
using a defined mailing list, and you got flamed if you had more than
about 10 lines of header in your message...  :-)

You need to do something like what is done by mail_search_addr() to limit
check your buffer.  Pine does something similar.  Eventually, something
better will be done, but it is low down on my list of priorities since
it'll involve an interface change (meaning compatibility macros, sigh).

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.