summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2003-04-18 12:32:06 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2003-04-18 12:32:06 +0000
commitc9e4611baf7d2b1a0b976e9ff114e9a96be44f73 (patch)
tree914231dae4bedbb522473ae882990e26ec9543da
parentc3bc5251d75642db7f070d14292e2e8d9901e81b (diff)
downloadmailutils-c9e4611baf7d2b1a0b976e9ff114e9a96be44f73.tar.gz
mailutils-c9e4611baf7d2b1a0b976e9ff114e9a96be44f73.tar.bz2
(imap_string): Bugfix. Handle numbers in the input
-rw-r--r--mailbox/imap/folder.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/mailbox/imap/folder.c b/mailbox/imap/folder.c
index f2c65dd73..f9222f354 100644
--- a/mailbox/imap/folder.c
+++ b/mailbox/imap/folder.c
@@ -44,6 +44,7 @@
#include <mailutils/attribute.h>
#include <mailutils/debug.h>
#include <mailutils/error.h>
+#include <mailutils/errno.h>
#include <mailutils/header.h>
#include <mailutils/observer.h>
#include <mailutils/stream.h>
@@ -1071,6 +1072,24 @@ imap_quoted_string (f_imap_t f_imap, char **ptr)
return 0;
}
+/* A number consists of one or more digit characters, and represents a
+ numeric value. */
+
+static int
+imap_digits (f_imap_t f_imap, char **ptr)
+{
+ char *start = *ptr;
+ int len;
+
+ for (++*ptr; **ptr && isdigit(**ptr); ++*ptr)
+ ;
+ len = *ptr - start;
+ stream_write (f_imap->string.stream, start, len,
+ f_imap->string.offset, NULL);
+ f_imap->string.offset += len;
+ return 0;
+}
+
/* Find which type of string the response is: literal or quoted and let the
function fill the string buffer. */
static int
@@ -1093,9 +1112,11 @@ imap_string (f_imap_t f_imap, char **ptr)
status = imap_literal_string (f_imap, ptr);
}
break;
+
case '"':
status = imap_quoted_string (f_imap, ptr);
break;
+
/* NIL */
case 'N':
case 'n':
@@ -1103,9 +1124,13 @@ imap_string (f_imap_t f_imap, char **ptr)
(*ptr)++; /* I|i */
(*ptr)++; /* L|l */
break;
+
default:
- /* Problem. */
- status = 1;
+ if (isdigit (**ptr))
+ status = imap_digits (f_imap, ptr);
+ else
+ /* Problem. FIXME: Return a more appropriate error code */
+ status = MU_ERR_FAILURE;
break;
}
return status;

Return to:

Send suggestions and report system problems to the System administrator.