Subject: Extra checks on maildrivers

From: [email-masked]
Date: Fri, 12 Dec 2003 21:47:03 +0100 (CET)

I know that the maildir maildriver is not officially supported, but I only 
mention it because it pointed out some things in pine that I think can be 
improved.

I've been experiencing crashes when TAB-ing to other folders to see new 
messages. After some debugging here's what I found:

When TAB-ing to the next folder, mail_status() is invoked.
That function returns SAFE_STATUS (dtb,stream,mbx,flags);
SAFE_STATUS is #defined as (*dtb->status) (stream,mbx,flags)
and the maildir driver has this in its driver struct:
  NIL,                          /* status of mailbox */
resulting in a call to a NULL function pointer.

I think that there are 2 reasons that this caused a problem at all.

1) The maildir driver does not implement the status function. This is 
not really important for the people on this list I suppose, I'll take this 
up with someone else.

2) Pine does not always check if the maildriver functions that it uses are 
actually defined in the maildriver structure.

It does in the case of the subscribe function:

  return factory ?
    (factory->subscribe ?
     (*factory->subscribe) (stream,mailbox) : sm_subscribe (mailbox)) : NIL;

But not in the case of status (and several other functions):

  if (!dtb) return NIL;         /* only if valid */
  if (stream && ((dtb != stream->dtb) ||
                 ((dtb->flags & DR_LOCAL) && strcmp (mbx,stream->mailbox) &&
                  strcmp (mbx,stream->original_mailbox))))
    stream = NIL;               /* stream not suitable */
  return SAFE_STATUS (dtb,stream,mbx,flags);

I can imagine that maildrivers are _required_ to implement some functions,
but the least pine could do is check these function pointers _at_startup_
and give a decent error message if it's NIL, so maildriver programmers 
know immediately what's wrong.

For all functions that are optional (i.e. the rest of them), pine should 
check if they are implemented _before_using_them_.

Am I making sense? =]

Best regards,
Maurice van der Pot
-- 
-----------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/pine/pine-info/
-----------------------------------------------------------------