diff options
author | Daniel Stenberg <daniel@haxx.se> | 2017-12-01 00:45:46 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2017-12-05 17:05:44 +0100 |
commit | 615edc1f73090f5f876f1491f9658f6429fdf481 (patch) | |
tree | ed060508a315f6ca306a6d1ab492b6687f8f3f40 /lib/imap.c | |
parent | 4401409468f590520dd5d0f0a55607eefa5ff4c1 (diff) | |
download | curl-615edc1f73090f5f876f1491f9658f6429fdf481.tar.gz |
sasl_getmesssage: make sure we have a long enough string to pass
For pop3/imap/smtp, added test 891 to somewhat verify the pop3
case.
For this, I enhanced the pingpong test server to be able to send back
responses with LF-only instead of always using CRLF.
Closes #2150
Diffstat (limited to 'lib/imap.c')
-rw-r--r-- | lib/imap.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lib/imap.c b/lib/imap.c index 1b52f73a4..63a998b2b 100644 --- a/lib/imap.c +++ b/lib/imap.c @@ -344,23 +344,28 @@ static bool imap_endofresp(struct connectdata *conn, char *line, size_t len, */ static void imap_get_message(char *buffer, char **outptr) { - size_t len = 0; + size_t len = strlen(buffer); char *message = NULL; - /* Find the start of the message */ - for(message = buffer + 2; *message == ' ' || *message == '\t'; message++) - ; + if(len > 2) { + /* Find the start of the message */ + for(message = buffer + 2; *message == ' ' || *message == '\t'; message++) + ; - /* Find the end of the message */ - for(len = strlen(message); len--;) - if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' && - message[len] != '\t') - break; + /* Find the end of the message */ + for(len -= 2; len--;) + if(message[len] != '\r' && message[len] != '\n' && message[len] != ' ' && + message[len] != '\t') + break; - /* Terminate the message */ - if(++len) { - message[len] = '\0'; + /* Terminate the message */ + if(++len) { + message[len] = '\0'; + } } + else + /* junk input => zero length output */ + message = &buffer[len]; *outptr = message; } |