Sergey:
Yes, the patch works.
However, on further thought, it seems that all occurrences of sp in that
long if statement should really be sp1 -- otherwise they refer to text
after the ']', which doesn't make sense (keep in mind that my knowledge
of the IMAP protocol is next to nil).
Also, I'm a bit uncomfortable with the direct use of the value of sp/sp1.
The value is not documented (at least not in the man page), and in
principle an implementation could store the end of the previous string
there instead of the first character after it.
So, I'd prefer to see the attached patch used instead.
--Paul
On Wed, Feb 18, 2009 at 12:30:55PM +0200, Sergey Poznyakoff wrote:
> Hi Paul,
>
> > However, it seems to be a bug that the third argument to strtok_r()
> > in lines 2431, 2439, and 2446 of libproto/imap/folder.c is &sp instead
> > of &sp1.
>
> Yes, it definitely is. Please try the attached patch. Does it work for
> you?
>
> Regards,
> Sergey
--- mailutils-2.0/libproto/imap/folder.c.orig 2008-12-08 11:06:08.000000000
-0800
+++ mailutils-2.0/libproto/imap/folder.c 2009-02-19 22:40:55.000000000
-0800
@@ -2350,7 +2350,8 @@
/* The human-readable text contains a special alert that
MUST be presented to the user in a fashion that calls
the user's attention to the message. */
- mu_error (_("ALERT: %s"), (sp) ? sp : "");
+ char *value = strtok_r (NULL, "", &sp1);
+ mu_error (_("ALERT: %s"), (value) ? value : "");
}
else if (strcasecmp (subtag, "BADCHARSET") == 0)
{
@@ -2359,7 +2360,8 @@
is not supported by this implementation. If the
optional list of charsets is given, this lists the
charsets that are supported by this implementation. */
- mu_error (_("BAD CHARSET: %s"), (sp) ? sp : "");
+ char *value = strtok_r (NULL, "", &sp1);
+ mu_error (_("BAD CHARSET: %s"), (value) ? value : "");
}
else if (strcasecmp (subtag, "CAPABILITY") == 0)
{
@@ -2368,7 +2370,9 @@
initial capabilities list. This makes it unnecessary
for a client to send a separate CAPABILITY command if
it recognizes this response. */
- parse_capa (f_imap, cruft);
+ char *value = strtok_r (NULL, "", &sp1);
+ if (value)
+ parse_capa (f_imap, value);
}
else if (strcasecmp (subtag, "NEWNAME") == 0)
{
@@ -2378,14 +2382,16 @@
mailbox name. This is a hint to the client that the
operation can succeed if the SELECT or EXAMINE is
reissued with the new mailbox name. */
- mu_error ("NEWNAME: %s", (sp) ? sp : "");
+ char *value = strtok_r (NULL, "", &sp1);
+ mu_error ("NEWNAME: %s", (value) ? value : "");
}
else if (strcasecmp (subtag, "PARSE") == 0)
{
/* The human-readable text represents an error in
parsing the [RFC-822] header or [MIME-IMB] headers
of a message in the mailbox. */
- mu_error ("PARSE: %s", (sp) ? sp : "");
+ char *value = strtok_r (NULL, "", &sp1);
+ mu_error ("PARSE: %s", (value) ? value : "");
}
else if (strcasecmp (subtag, "PERMANENTFLAGS") == 0)
{
@@ -2421,30 +2427,35 @@
other reason). This is a hint to the client that
the operation can succeed if the mailbox is first
created by the CREATE command. */
- mu_error ("TRYCREATE: %s", (sp) ? sp : "");
+ char *value = strtok_r (NULL, "", &sp1);
+ mu_error ("TRYCREATE: %s", (value) ? value : "");
}
else if (strcasecmp (subtag, "UIDNEXT") == 0)
{
/* Followed by a decimal number, indicates the next
unique identifier value. Refer to section 2.3.1.1
for more information. */
- char *value = strtok_r (NULL, " ", &sp);
- f_imap->selected->uidnext = strtol (value, NULL, 10);
+ char *value = strtok_r (NULL, " ", &sp1);
+ if (value)
+ f_imap->selected->uidnext = strtol (value, NULL, 10);
}
else if (strcasecmp (subtag, "UIDVALIDITY") == 0)
{
/* Followed by a decimal number, indicates the unique
identifier validity value. Refer to section 2.3.1.1
for more information. */
- char *value = strtok_r (NULL, " ", &sp);
- f_imap->selected->uidvalidity = strtol (value, NULL, 10);
+ char *value = strtok_r (NULL, " ", &sp1);
+ if (value)
+ f_imap->selected->uidvalidity = strtol (value,
+ NULL, 10);
}
else if (strcasecmp (subtag, "UNSEEN") == 0)
{
/* Followed by a decimal number, indicates the number of
the first message without the \Seen flag set. */
- char *value = strtok_r (NULL, " ", &sp);
- f_imap->selected->unseen = strtol (value, NULL, 10);
+ char *value = strtok_r (NULL, " ", &sp1);
+ if (value)
+ f_imap->selected->unseen = strtol (value, NULL, 10);
}
else
{
_______________________________________________
Bug-mailutils mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-mailutils